@@ -37,11 +37,17 @@ workflows: trybot: _repo.bashWorkflow & {
37
37
38
38
jobs : {
39
39
test : {
40
- strategy : _testStrategy
41
- " runs-on " : " ${{ matrix.runner }} "
40
+ strategy : {
41
+ " fail-fast " : false
42
+ matrix : {
43
+ (_repo .matrixRunnerName ): [_repo .linuxMachine , _repo .macosMachine , _repo .windowsMachine ]
44
+ (_repo .matrixGoVersionName ): [_repo .previousGo , _repo .latestGo ]
45
+ }
46
+ }
47
+ " runs-on " : " ${{ \(_repo .matrixRunnerExpr ) }} "
42
48
43
49
let installGo = _repo .installGo & {
44
- #setupGo : with : " go-version " : goVersionVal
50
+ #setupGo : with : " go-version " : " ${{ \( _repo . matrixGoVersionExpr ) }} "
45
51
_
46
52
}
47
53
@@ -60,10 +66,10 @@ workflows: trybot: _repo.bashWorkflow & {
60
66
_repo .earlyChecks & {
61
67
// These checks don't vary based on the Go version or OS,
62
68
// so we only need to run them on one of the matrix jobs.
63
- if : _isLatestLinux
69
+ if : _repo . isLatestGoLinux
64
70
},
65
71
_goTest & {
66
- if : " \(_repo .isProtectedBranch ) || !\(_isLatestLinux ) "
72
+ if : " \(_repo .isProtectedBranch ) || !\(_repo . isLatestGoLinux ) "
67
73
},
68
74
_goTestRace ,
69
75
_goTest32bit ,
@@ -82,30 +88,12 @@ workflows: trybot: _repo.bashWorkflow & {
82
88
}
83
89
}
84
90
85
- let matrixRunner = " matrix.runner "
86
- let goVersion = " matrix.go-version "
87
- let goVersionVal = " ${{ \(goVersion ) }} "
88
-
89
- _testStrategy : {
90
- " fail-fast " : false
91
- matrix : {
92
- " go-version " : [_repo .previousGo , _repo .latestGo ]
93
- runner : [_repo .linuxMachine , _repo .macosMachine , _repo .windowsMachine ]
94
- }
95
- }
96
-
97
- // _isLatestLinux returns a GitHub expression that evaluates to true if the job
98
- // is running on Linux with the latest version of Go. This expression is often
99
- // used to run certain steps just once per CI workflow, to avoid duplicated
100
- // work.
101
- _isLatestLinux : " (\(goVersion ) == '\(_repo .latestGo )' && \(matrixRunner ) == '\(_repo .linuxMachine )') "
102
-
103
91
_goGenerate : githubactions .#Step & {
104
92
name : " Generate "
105
93
run : " go generate ./... "
106
94
// The Go version corresponds to the precise version specified in
107
95
// the matrix. Skip windows for now until we work out why re-gen is flaky
108
- if : _isLatestLinux
96
+ if : _repo . isLatestGoLinux
109
97
}
110
98
111
99
_goTest : githubactions .#Step & {
@@ -117,7 +105,7 @@ workflows: trybot: _repo.bashWorkflow & {
117
105
// The end-to-end tests require a github token secret and are a bit slow,
118
106
// so we only run them on pushes to protected branches and on one
119
107
// environment in the source repo.
120
- if : " github.repository == '\(_repo .githubRepositoryPath )' && (\(_repo .isProtectedBranch ) || \(_repo .isTestDefaultBranch )) && \(_isLatestLinux ) "
108
+ if : " github.repository == '\(_repo .githubRepositoryPath )' && (\(_repo .isProtectedBranch ) || \(_repo .isTestDefaultBranch )) && \(_repo . isLatestGoLinux ) "
121
109
}] & [
122
110
// Two setup steps per the upstream docs:
123
111
// https://github.com/google-github-actions/setup-gcloud#service-account-key-json
@@ -157,15 +145,15 @@ workflows: trybot: _repo.bashWorkflow & {
157
145
// However, CUE does not have any such build tags yet, and we don't use
158
146
// dependencies that vary wildly between platforms.
159
147
// For now, to save CI resources, just run the checks on one matrix job.
160
- if : _isLatestLinux
148
+ if : _repo . isLatestGoLinux
161
149
}] & [
162
150
_repo .goChecks ,
163
151
{
164
152
name : " Verify the end-to-end tests still build "
165
153
// Ensure that the end-to-end tests in ./internal/_e2e, which are only run
166
154
// on pushes to protected branches, still build correctly before merging.
167
155
" working-directory " : " ./internal/_e2e "
168
- run : " go test -run=- "
156
+ run : " go test -run=- "
169
157
},
170
158
// Note that we don't want tooling dependencies in the go.mod file,
171
159
// given how many downstreams rely on the cue module having few dependencies.
@@ -179,7 +167,7 @@ workflows: trybot: _repo.bashWorkflow & {
179
167
// We use `git ls-remote` to list all tags from each remote git repository
180
168
// because it does not depend on custom REST API endpoints and is very fast.
181
169
// Note that it sorts tag names as strings, which is not the best, but works OK.
182
- if : " (\(_repo .isProtectedBranch ) || \(_repo .isTestDefaultBranch )) && \(_isLatestLinux ) "
170
+ if : " (\(_repo .isProtectedBranch ) || \(_repo .isTestDefaultBranch )) && \(_repo . isLatestGoLinux ) "
183
171
name : " Check all git tags are available "
184
172
run : """
185
173
cd $(mktemp -d)
@@ -202,7 +190,7 @@ workflows: trybot: _repo.bashWorkflow & {
202
190
// Windows and Mac on CI are slower than Linux, and most data races are not specific
203
191
// to any OS or Go version in particular, so only run all tests with -race on Linux
204
192
// to not slow down CI unnecessarily.
205
- if : _isLatestLinux
193
+ if : _repo . isLatestGoLinux
206
194
name : " Test with -race "
207
195
env : GORACE : " atexit_sleep_ms=10 " // Otherwise every Go package being tested sleeps for 1s; see https://go.dev/issues/20364.
208
196
run : " go test -race ./... "
@@ -218,7 +206,7 @@ workflows: trybot: _repo.bashWorkflow & {
218
206
// We skip this step when testing CLs and PRs, as Linux on the latest Go is the slowest
219
207
// job in the matrix due to the use of `go test -race`. 32-bit bugs should be rare,
220
208
// so them only getting caught once a patch is merged into master is not a big problem.
221
- if : " (\(_repo .isProtectedBranch ) || \(_repo .isTestDefaultBranch )) && \(_isLatestLinux ) "
209
+ if : " (\(_repo .isProtectedBranch ) || \(_repo .isTestDefaultBranch )) && \(_repo . isLatestGoLinux ) "
222
210
name : " Test on 32 bits "
223
211
env : GOARCH : " 386 "
224
212
run : " go test -short ./... "
0 commit comments