Skip to content

Commit

Permalink
ci: only go test -race on latest Go+linux, and master
Browse files Browse the repository at this point in the history
Builds of CLs take some time because every entry in the build matrix
runs a go test -race step. Whilst nice, this is probably overkill.

Instead:

* on master commit, run go test -race on all entries in the build
  matrix. No change here.
* for CL builds, only run go test -race for the entry in the build
  matrix that corresponds to the latest stable Go version running on
  Linux.

Change-Id: I83fa2e41a9059a06436c250bfee99a430425dc6c
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8361
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
myitcv committed Jan 29, 2021
1 parent dfaea59 commit 3088513
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ jobs:
run: go generate ./...
- name: Test
run: go test ./...
- name: Test with -race
- if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ci/')
&& matrix.go-version == '1.15.x' && matrix.os == 'ubuntu-18.04' }}
name: Test with -race
run: go test -race ./...
- name: gorelease check
run: go run golang.org/x/exp/cmd/gorelease
Expand Down
22 changes: 14 additions & 8 deletions internal/ci/workflows.cue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (

workflowsDir: *"./" | string @tag(workflowsDir)

_#masterBranch: "master"
_#releaseTagPattern: "v*"

workflows: [...{file: string, schema: (json.#Workflow & {})}]
workflows: [
{
Expand All @@ -33,7 +36,7 @@ test: _#bashWorkflow & {
on: {
push: {
branches: ["**"] // any branch (including '/' namespaced branches)
"tags-ignore": ["v*"]
"tags-ignore": [_#releaseTagPattern]
}
}

Expand All @@ -56,7 +59,9 @@ test: _#bashWorkflow & {
_#cacheGoModules,
_#goGenerate,
_#goTest,
_#goTestRace,
_#goTestRace & {
if: "${{ \(_#isMaster) || \(_#isCLCITestBranch) && matrix.go-version == '\(_#latestStableGo)' && matrix.os == '\(_#linuxMachine)' }}"
},
_#goReleaseCheck,
_#checkGitClean,
_#pullThroughProxy,
Expand Down Expand Up @@ -93,10 +98,10 @@ test: _#bashWorkflow & {

// _#isMaster is an expression that evaluates to true if the
// job is running as a result of a master commit push
_#isMaster: "github.ref == '\(_#branchRefPrefix)master'"
_#isMaster: "github.ref == '\(_#branchRefPrefix+_#masterBranch)'"

_#pullThroughProxy: _#step & {
name: "Pull this commit through the proxy on master"
name: "Pull this commit through the proxy on \(_#masterBranch)"
run: """
v=$(git rev-parse HEAD)
cd $(mktemp -d)
Expand Down Expand Up @@ -181,7 +186,7 @@ test_dispatch: _#bashWorkflow & {
release: _#bashWorkflow & {

name: "Release"
on: push: tags: ["v*"]
on: push: tags: [_#releaseTagPattern]
jobs: {
goreleaser: {
"runs-on": _#linuxMachine
Expand Down Expand Up @@ -239,7 +244,7 @@ release: _#bashWorkflow & {
rebuild_tip_cuelang_org: _#bashWorkflow & {

name: "Push to tip"
on: push: branches: ["master"]
on: push: branches: [_#masterBranch]
jobs: push: {
"runs-on": _#linuxMachine
steps: [{
Expand All @@ -259,7 +264,8 @@ _#job: ((json.#Workflow & {}).jobs & {x: _}).x
_#step: ((_#job & {steps: _}).steps & [_])[0]

// We need at least go1.14 for code generation
_#codeGenGo: "1.14.9"
_#codeGenGo: "1.14.9"
_#latestStableGo: "1.15.x"

_#linuxMachine: "ubuntu-18.04"
_#macosMachine: "macos-10.15"
Expand All @@ -269,7 +275,7 @@ _#testStrategy: {
"fail-fast": false
matrix: {
// Use a stable version of 1.14.x for go generate
"go-version": ["1.13.x", _#codeGenGo, "1.15.x"]
"go-version": ["1.13.x", _#codeGenGo, _#latestStableGo]
os: [_#linuxMachine, _#macosMachine, _#windowsMachine]
}
}
Expand Down

0 comments on commit 3088513

Please sign in to comment.