|
@@ -140,6 +140,13 @@ jobs:
|
|
|
env:
|
|
|
CMAKE_GENERATOR: Ninja
|
|
|
|
|
|
+ go_mod_tidy:
|
|
|
+ runs-on: ubuntu-latest
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v4
|
|
|
+ - name: check that 'go mod tidy' is clean
|
|
|
+ run: go mod tidy --diff || (echo "Please run 'go mod tidy'." && exit 1)
|
|
|
+
|
|
|
test:
|
|
|
strategy:
|
|
|
matrix:
|
|
@@ -149,14 +156,81 @@ jobs:
|
|
|
CGO_ENABLED: '1'
|
|
|
GOEXPERIMENT: 'synctest'
|
|
|
steps:
|
|
|
- - uses: actions/checkout@v4
|
|
|
- - uses: actions/setup-go@v5
|
|
|
+ - name: checkout
|
|
|
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
|
|
|
+
|
|
|
+ - name: cache restore
|
|
|
+ uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
|
|
|
+ with:
|
|
|
+ # Note: unlike the other setups, this is only grabbing the mod download
|
|
|
+ # cache, rather than the whole mod directory, as the download cache
|
|
|
+ # contains zips that can be unpacked in parallel faster than they can be
|
|
|
+ # fetched and extracted by tar
|
|
|
+ path: |
|
|
|
+ ~/.cache/go-build
|
|
|
+ ~/go/pkg/mod/cache
|
|
|
+ ~\AppData\Local\go-build
|
|
|
+ # NOTE: The -3- here should be incremented when the scheme of data to be
|
|
|
+ # cached changes (e.g. path above changes).
|
|
|
+ key: ${{ github.job }}-${{ runner.os }}-${{ matrix.goarch }}-${{ matrix.buildflags }}-go-3-${{ hashFiles('**/go.sum') }}-${{ github.run_id }}
|
|
|
+ restore-keys: |
|
|
|
+ ${{ github.job }}-${{ runner.os }}-${{ matrix.goarch }}-${{ matrix.buildflags }}-go-3-${{ hashFiles('**/go.sum') }}
|
|
|
+ ${{ github.job }}-${{ runner.os }}-${{ matrix.goarch }}-${{ matrix.buildflags }}-go-3-
|
|
|
+
|
|
|
+ - name: Setup Go
|
|
|
+ uses: actions/setup-go@v5
|
|
|
with:
|
|
|
+ # The caching strategy of setup-go is less than ideal, and wastes
|
|
|
+ # time by not saving artifacts due to small failures like the linter
|
|
|
+ # complaining, etc. This means subsequent have to rebuild their world
|
|
|
+ # again until all checks pass. For instance, if you mispell a word,
|
|
|
+ # you're punished until you fix it. This is more hostile than
|
|
|
+ # helpful.
|
|
|
+ cache: false
|
|
|
+
|
|
|
go-version-file: go.mod
|
|
|
+
|
|
|
+ # TODO(bmizerany): replace this heavy tool with just the
|
|
|
+ # tools/checks/binaries we want and then make them all run in parallel
|
|
|
+ # across jobs, not on a single tiny vm on Github Actions.
|
|
|
- uses: golangci/golangci-lint-action@v6
|
|
|
with:
|
|
|
args: --timeout 10m0s -v
|
|
|
- - run: go test ./...
|
|
|
+
|
|
|
+ - name: go test
|
|
|
+ # Do not skip tests in the face of linter errors, or 'go mod tidy'
|
|
|
+ # checks, which are secondary to the tests. Tests trump linters.
|
|
|
+ if: always()
|
|
|
+ run: go test -count=1 -benchtime=1x ./...
|
|
|
+
|
|
|
+ # It is tempting to run this in a platform independent way, but the past
|
|
|
+ # shows this codebase will see introductions of platform specific code
|
|
|
+ # generation, and so we need to check this per platform to ensure we
|
|
|
+ # don't abuse go generate on specific platforms.
|
|
|
+ - name: check that 'go generate' is clean
|
|
|
+ run: |
|
|
|
+ go generate ./...
|
|
|
+ git diff --name-only --exit-code || (echo "Please run 'go generate ./...'." && exit 1)
|
|
|
+
|
|
|
+ - name: cache save
|
|
|
+ # Always save the cache, even if the job fails. The artifacts produced
|
|
|
+ # during the building of test binaries are not all for naught. They can
|
|
|
+ # be used to speed up subsequent runs.
|
|
|
+ if: always()
|
|
|
+
|
|
|
+ uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
|
|
|
+ with:
|
|
|
+ # Note: unlike the other setups, this is only grabbing the mod download
|
|
|
+ # cache, rather than the whole mod directory, as the download cache
|
|
|
+ # contains zips that can be unpacked in parallel faster than they can be
|
|
|
+ # fetched and extracted by tar
|
|
|
+ path: |
|
|
|
+ ~/.cache/go-build
|
|
|
+ ~/go/pkg/mod/cache
|
|
|
+ ~\AppData\Local\go-build
|
|
|
+ # NOTE: The -3- here should be incremented when the scheme of data to be
|
|
|
+ # cached changes (e.g. path above changes).
|
|
|
+ key: ${{ github.job }}-${{ runner.os }}-${{ matrix.goarch }}-${{ matrix.buildflags }}-go-3-${{ hashFiles('**/go.sum') }}-${{ github.run_id }}
|
|
|
|
|
|
patches:
|
|
|
runs-on: ubuntu-latest
|