diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 984dd51..1b61a43 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -162,7 +162,9 @@ jobs: uses: protocol/multiple-go-modules@v1.4 env: GOFLAGS: ${{ format('{0} {1}', env.GOTESTFLAGS, env.GOFLAGS) }} - CGO_ENABLED: ${{ toJSON(fromJSON(steps.config.outputs.json).cgo) != 'false' }} + # go only recognizes CGO_ENABLED values of 0 and 1; anything else + # (e.g. true/false) is ignored in favor of the platform default + CGO_ENABLED: ${{ toJSON(fromJSON(steps.config.outputs.json).cgo) != 'false' && '1' || '0' }} with: run: go test ./... - name: Run tests (32 bit) @@ -175,7 +177,7 @@ jobs: env: GOARCH: 386 GOFLAGS: ${{ format('{0} {1}', env.GO386FLAGS, env.GOFLAGS) }} - CGO_ENABLED: ${{ toJSON(fromJSON(steps.config.outputs.json).cgo) != 'false' }} + CGO_ENABLED: ${{ toJSON(fromJSON(steps.config.outputs.json).cgo) != 'false' && '1' || '0' }} with: run: | export "PATH=$PATH_386:$PATH" @@ -188,7 +190,9 @@ jobs: uses: protocol/multiple-go-modules@v1.4 env: GOFLAGS: ${{ format('{0} {1}', env.GORACEFLAGS, env.GOFLAGS) }} - CGO_ENABLED: ${{ toJSON(fromJSON(steps.config.outputs.json).cgo) != 'false' }} + # the race detector requires cgo, even when the repo disables it + # for the regular test runs + CGO_ENABLED: '1' with: run: go test -race ./... - name: Collect coverage files diff --git a/README.md b/README.md index 93841ee..5473752 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ If you want to disable cgo, you can do so by setting `cgo` to `false` in `.githu "cgo": false } ``` +This applies to the regular and 32-bit test runs. The race detector run always keeps cgo enabled because `go test -race` requires it; set `skipRace` to `true` if your module cannot build with cgo at all. ### Workflow Modification