From 0516cc68fe39ecf464f46e86b0d839716f624229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 28 Oct 2024 10:07:49 +0000 Subject: [PATCH] internal/ci: run most tests on 32 bits too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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í Change-Id: I09dd367434f835e983ad53d5106b9102646f1811 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1203194 Reviewed-by: Roger Peppe TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine --- .github/workflows/trybot.yaml | 9 +++++++-- internal/ci/github/trybot.cue | 23 ++++++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/trybot.yaml b/.github/workflows/trybot.yaml index 951a70abc4f..da54f2b3abf 100644 --- a/.github/workflows/trybot.yaml +++ b/.github/workflows/trybot.yaml @@ -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 diff --git a/internal/ci/github/trybot.cue b/internal/ci/github/trybot.cue index 2f302eac24c..222c2c31fd7 100644 --- a/internal/ci/github/trybot.cue +++ b/internal/ci/github/trybot.cue @@ -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, @@ -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.