Skip to content

Commit 8da35a9

Browse files
authored
Merge branch 'main' into 59-support-orderedmaprange-callbacks-mutating-the-map
2 parents dc2152d + 8b49103 commit 8da35a9

File tree

10 files changed

+100
-30
lines changed

10 files changed

+100
-30
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ updates:
1313
- package-ecosystem: github-actions
1414
directory: /
1515
schedule:
16-
interval: daily
16+
interval: "weekly"

.github/workflows/codeql.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
name: "CodeQL Advanced"
1313

1414
on:
15+
# For Branch-Protection check. Only the default branch is supported. See
16+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
17+
#branch_protection_rule:
1518
push:
1619
branches: [ "main" ]
1720
pull_request:
21+
# The branches below must be a subset of the branches above
1822
branches: [ "main" ]
23+
# To guarantee Maintained check is occasionally updated. See
24+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
1925
schedule:
2026
- cron: '45 6 * * 6'
2127

22-
# permissions:
23-
# contents: read
24-
28+
# Declare default permissions as read only.
2529
permissions:
2630
contents: read
2731

@@ -34,6 +38,7 @@ jobs:
3438
# - https://gh.io/using-larger-runners (GitHub.com only)
3539
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
3640
runs-on: ubuntu-latest
41+
# timeout-minutes: 360
3742
permissions:
3843
# required for all workflows
3944
security-events: write
@@ -75,10 +80,17 @@ jobs:
7580
# or others). This is typically only required for manual builds.
7681
# - name: Setup runtime (example)
7782
# uses: actions/setup-example@v1
83+
- name: Set up required Go version
84+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
85+
with:
86+
go-version: 1.24
87+
88+
- name: Ensure actual Go version
89+
run: go version
7890

7991
# Initializes the CodeQL tools for scanning.
8092
- name: Initialize CodeQL
81-
uses: github/codeql-action/init@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
93+
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
8294
with:
8395
languages: ${{ matrix.language }}
8496
build-mode: ${{ matrix.build-mode }}
@@ -89,13 +101,12 @@ jobs:
89101
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
90102
# queries: security-extended,security-and-quality
91103

92-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
104+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
93105
# If this step fails, then you should remove it and run the build manually (see below)
94106
- name: Autobuild
95-
uses: github/codeql-action/autobuild@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
107+
uses: github/codeql-action/autobuild@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
96108
# If the Autobuild fails above, remove it and uncomment the following three lines.
97109
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
98-
99110
# - run: |
100111
# echo "Run, Build Application using script"
101112
# ./location_of_script_within_repo/buildscript.sh
@@ -116,10 +127,8 @@ jobs:
116127
echo ' make bootstrap'
117128
echo ' make release'
118129
exit 1
119-
120-
121-
- name: Perform CodeQL Analysis
130+
122131
- name: Perform CodeQL Analysis
123-
uses: github/codeql-action/analyze@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
132+
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
124133
with:
125134
category: "/language:${{matrix.language}}"

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- name: 'Checkout Repository'
2525
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2626
- name: 'Dependency Review'
27-
uses: actions/dependency-review-action@595b5aeba73380359d98a5e087f648dbb0edce1b # v4.7.3
27+
uses: actions/dependency-review-action@56339e523c0409420f6c2c9a2f4292bbb3c07dd3 # v4.8.0

.github/workflows/scorecard.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,21 @@ jobs:
6161
# of the value entered here.
6262
publish_results: true
6363

64+
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
65+
# file_mode: git
66+
6467
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
6568
# format to the repository Actions tab.
6669
- name: "Upload artifact"
6770
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
6871
with:
69-
name: SARIF file
72+
name: SARIF-file
7073
path: results.sarif
7174
retention-days: 5
7275

7376
# Upload the results to GitHub's code scanning dashboard (optional).
7477
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
7578
- name: "Upload to code-scanning"
76-
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
79+
uses: github/codeql-action/upload-sarif@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
7780
with:
7881
sarif_file: results.sarif

.github/workflows/workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
with:
2727
go-version: 1.24
2828

29-
- name: Test
29+
- name: Test and cover
3030
# We don't need the benchmarks to run for long, just enough for coverage.
31-
run: mkdir -p coverage; go test -v -race -run=. -bench=. -benchtime=1ms -coverprofile=./coverage/cover.out -covermode=atomic ./...
31+
run: mkdir -p coverage; make cover
3232

3333
- name: Upload coverage to Codecov
3434
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1

.idea/vcs.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
all: lint build
2+
3+
.PHONY: lint test build
4+
lint:
5+
go tool staticcheck ./...
6+
7+
.PHONY: fuzz-smoke
8+
fuzz-smoke: lint
9+
# Smoke tests on fuzzing targets.
10+
go test -fuzz='\QFuzzBasicMapAdd\E' -fuzztime=10s ./set
11+
go test -fuzz='\QFuzzBasicMapItems\E' -fuzztime=10s ./set
12+
go test -fuzz='\QFuzzBasicMapUnion\E' -fuzztime=10s ./set
13+
14+
.PHONY: bench
15+
bench:
16+
# Run this when modifying the code to obtain data to update BENCHMARKS.md
17+
go test -bench=Benchmark ./...
18+
19+
.PHONY: cover
20+
cover:
21+
# This runs the benchmarks just once, as unit tests, for coverage reporting only.
22+
# It does not replace running "make bench".
23+
go test -v -race -run=. -bench=. -benchtime=1x -coverprofile=coverage/cover.out -covermode=atomic ./...
24+
25+
.PHONY: test
26+
test:
27+
# This includes the fuzz tests in unit test mode
28+
go test -race ./...
29+
30+
.PHONY: build
31+
build: test fuzz-smoke
32+
go build ./...

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,28 +125,39 @@ for i := 0; i < 2; i++ {
125125
}
126126
```
127127

128-
### Running tests
129-
#### Normal tests: unit and benchmarks
128+
### Development
130129

131-
The complete test coverage requires running not only the unit tests, but also
132-
the benchmarks, like:
130+
Since this is a library, it has no install process, but you can build it to ensure correctness, with:
133131

134132
```
135-
go test -race -run=. -bench=. -coverprofile=cover.out -covermode=atomic ./...
133+
make lint # Run staticcheck linting checks
134+
make build # Build the library. Include test and fuzz-smoke targets.
135+
make # Shortcut for make lint && make build
136136
```
137137

138-
This will also run the fuzz tests in unit test mode, without triggering the fuzzing logic.
138+
#### Running normal tests: unit and benchmarks
139+
140+
For the simple version, without generating coverage reports, run:
141+
```
142+
make test # Unit tests, fast
143+
make coverage # Coverage report in cover.out. A bit longer.
144+
make bench # Benchmarks: run to update BENCHMARKS.md
145+
make fuzz-smoke # Fuzz tests as smoke tests: 10 seconds only, for CI builds
146+
```
147+
148+
This will also run the fuzz tests in unit test mode,
149+
without triggering the fuzzing logic.
139150

140151

141-
#### Fuzz tests
152+
#### Running fuzz tests
142153

143154
Fuzz tests are not run by CI, but you can run them on-demand during development with:
144155

145156
```
146-
go test -run='^$' -fuzz='^\QFuzzBasicMapAdd\E$' -fuzztime=20s ./set
147-
go test -run='^$' -fuzz='^\QFuzzBasicMapItems\E$' -fuzztime=20s ./set
148-
go test -run='^$' -fuzz='^\QFuzzBasicMapUnion\E$' -fuzztime=20s ./set
157+
go test -fuzz='\QFuzzBasicMapAdd\E' -fuzztime=20s ./set
158+
go test -fuzz='\QFuzzBasicMapItems\E' -fuzztime=20s ./set
159+
go test -fuzz='\QFuzzBasicMapUnion\E' -fuzztime=20s ./set
149160
```
150161

151162
- Adjust `-fuzztime` duration as relevant: 20 seconds is just a smoke test.
152-
- Be sure to escape the `^$` and `\Q\E` characters in the `-fuzz` argument in your shell.
163+
- Be sure to escape the `\Q\E` characters in the `-fuzz` argument in your shell.

go.mod

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ go 1.24.7
55
require github.com/google/go-cmp v0.7.0
66

77
require (
8+
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
9+
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect
810
golang.org/x/mod v0.28.0 // indirect
911
golang.org/x/sync v0.17.0 // indirect
1012
golang.org/x/tools v0.37.0 // indirect
13+
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
14+
honnef.co/go/tools v0.6.1 // indirect
1115
)
1216

13-
tool golang.org/x/tools/cmd/stringer
17+
tool (
18+
golang.org/x/tools/cmd/stringer
19+
honnef.co/go/tools/cmd/staticcheck
20+
)

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
2+
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
13
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
24
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5+
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=
6+
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
37
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
48
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
59
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
610
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
711
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
812
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
13+
golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
14+
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
15+
honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI=
16+
honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4=

0 commit comments

Comments
 (0)