Skip to content

Commit

Permalink
internal/ci: run most tests on 32 bits too
Browse files Browse the repository at this point in the history
Ensure that the entire build and all tests succeed on a 32-bit platform
as well. This should catch if any of the code or test cases rely on
bit sizes, such as int being 64 bits, which could cause portability bugs
for 32-bit platforms.

While GOARCH=386 isn't particularly popular anymore, it can run
on an amd64 machine, and the Linux runners on GitHub Actions use amd64.

Running just the short tests is enough for now.

While here, better document why we only run the tests with -race
on a single platform and Go version too.

Fixes #3540.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I09dd367434f835e983ad53d5106b9102646f1811
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1203194
Reviewed-by: Roger Peppe <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mvdan committed Oct 31, 2024
1 parent 00bd25b commit 0516cc6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/trybot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ jobs:
((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"')))) || !(matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
run: go test ./...
- name: Test with -race
- if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
name: Test with -race
env:
GORACE: atexit_sleep_ms=10
if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
run: go test -race ./...
- if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
name: Test on 32 bits
env:
GOARCH: "386"
run: go test -short ./...
- name: Test with -tags=cuewasm
run: go test -tags cuewasm ./cmd/cue/cmd ./cue/interpreter/wasm
- name: gcloud auth for end-to-end tests
Expand Down
23 changes: 20 additions & 3 deletions internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ workflows: trybot: _repo.bashWorkflow & {
_goTest & {
if: "\(_repo.isProtectedBranch) || !\(_isLatestLinux)"
},
_goTestRace & {
if: _isLatestLinux
},
_goTestRace,
_goTest32bit,
_goTestWasm,
for v in _e2eTestSteps {v},
_goCheck,
Expand Down Expand Up @@ -208,11 +207,29 @@ workflows: trybot: _repo.bashWorkflow & {
}

_goTestRace: githubactions.#Step & {
// Windows and Mac on CI are slower than Linux, and most data races are not specific
// to any OS or Go version in particular, so only run all tests with -race on Linux
// to not slow down CI unnecessarily.
if: _isLatestLinux
name: "Test with -race"
env: GORACE: "atexit_sleep_ms=10" // Otherwise every Go package being tested sleeps for 1s; see https://go.dev/issues/20364.
run: "go test -race ./..."
}

_goTest32bit: githubactions.#Step & {
// Ensure that the entire build and all tests succeed on a 32-bit platform as well.
// This should catch if any of the code or test cases rely on bit sizes,
// such as int being 64 bits, which could cause portability bugs for 32-bit platforms.
// While GOARCH=386 isn't particularly popular anymore, it can run on an amd64 machine,
// and the Linux runners on GitHub Actions use amd64.
//
// Running just the short tests is enough for now.
if: _isLatestLinux
name: "Test on 32 bits"
env: GOARCH: "386"
run: "go test -short ./..."
}

_goTestWasm: githubactions.#Step & {
name: "Test with -tags=cuewasm"
// The wasm interpreter is only bundled into cmd/cue with the cuewasm build tag.
Expand Down

0 comments on commit 0516cc6

Please sign in to comment.