@@ -27,6 +27,71 @@ concurrency:
27
27
cancel-in-progress : ${{ github.event_name == 'pull_request' }}
28
28
29
29
jobs :
30
+ changes :
31
+ runs-on : ubuntu-latest
32
+ outputs :
33
+ docs-only : ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
34
+ go : ${{ steps.filter.outputs.go }}
35
+ ts : ${{ steps.filter.outputs.ts }}
36
+ k8s : ${{ steps.filter.outputs.k8s }}
37
+ ci : ${{ steps.filter.outputs.ci }}
38
+ steps :
39
+ - uses : actions/checkout@v3
40
+ # For pull requests it's not necessary to checkout the code
41
+ - uses : dorny/paths-filter@v2
42
+ id : filter
43
+ with :
44
+ filters : |
45
+ all:
46
+ - "**"
47
+ docs:
48
+ - "docs/**"
49
+ - "README.md"
50
+ # For testing:
51
+ # - ".github/**"
52
+ go:
53
+ - "**.sql"
54
+ - "**.go"
55
+ - "**.golden"
56
+ - "go.mod"
57
+ - "go.sum"
58
+ # Other non-Go files that may affect Go code:
59
+ - "**.rego"
60
+ - "**.sh"
61
+ - "**.tpl"
62
+ - "**.gotmpl"
63
+ - "**.gotpl"
64
+ - "Makefile"
65
+ - "site/static/error.html"
66
+ # Main repo directories for completeness in case other files are
67
+ # touched:
68
+ - "agent/**"
69
+ - "cli/**"
70
+ - "cmd/**"
71
+ - "coderd/**"
72
+ - "enterprise/**"
73
+ - "examples/**"
74
+ - "provisioner/**"
75
+ - "provisionerd/**"
76
+ - "provisionersdk/**"
77
+ - "pty/**"
78
+ - "scaletest/**"
79
+ - "tailnet/**"
80
+ - "testutil/**"
81
+ ts:
82
+ - "site/**"
83
+ - "Makefile"
84
+ k8s:
85
+ - "helm/**"
86
+ - "scripts/Dockerfile"
87
+ - "scripts/Dockerfile.base"
88
+ - "scripts/helm.sh"
89
+ ci:
90
+ - ".github/**"
91
+ - id : debug
92
+ run : |
93
+ echo "${{ toJSON(steps.filter )}}"
94
+
30
95
lint :
31
96
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
32
97
steps :
@@ -79,44 +144,11 @@ jobs:
79
144
- name : Check for AGPL code importing Enterprise...
80
145
run : ./scripts/check_enterprise_imports.sh
81
146
82
- changes :
83
- runs-on : ubuntu-latest
84
- outputs :
85
- docs-only : ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
86
- sh : ${{ steps.filter.outputs.sh }}
87
- ts : ${{ steps.filter.outputs.ts }}
88
- k8s : ${{ steps.filter.outputs.k8s }}
89
- steps :
90
- - uses : actions/checkout@v3
91
- # For pull requests it's not necessary to checkout the code
92
- - uses : dorny/paths-filter@v2
93
- id : filter
94
- with :
95
- filters : |
96
- all:
97
- - '**'
98
- docs:
99
- - 'docs/**'
100
- # For testing:
101
- # - '.github/**'
102
- sh:
103
- - "**.sh"
104
- ts:
105
- - 'site/**'
106
- k8s:
107
- - 'helm/**'
108
- - scripts/Dockerfile
109
- - scripts/Dockerfile.base
110
- - scripts/helm.sh
111
- - id : debug
112
- run : |
113
- echo "${{ toJSON(steps.filter )}}"
114
-
115
147
gen :
116
148
timeout-minutes : 8
117
149
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
118
150
needs : changes
119
- if : needs.changes.outputs.docs-only == 'false'
151
+ if : needs.changes.outputs.docs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
120
152
steps :
121
153
- uses : actions/checkout@v3
122
154
@@ -181,7 +213,9 @@ jobs:
181
213
run : ./scripts/check_unstaged.sh
182
214
183
215
test-go :
184
- runs-on : ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-4vcpu-ubuntu-2204' || matrix.os == 'windows-2019' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }}
216
+ runs-on : ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-4vcpu-ubuntu-2204' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xl' || matrix.os == 'windows-2019' && github.repository_owner == 'coder' && 'windows-latest-8-cores' || matrix.os }}
217
+ needs : changes
218
+ if : needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
185
219
timeout-minutes : 20
186
220
strategy :
187
221
matrix :
@@ -192,11 +226,6 @@ jobs:
192
226
steps :
193
227
- uses : actions/checkout@v3
194
228
195
- - uses : buildjet/setup-go@v4
196
- with :
197
- cache : false
198
- go-version : ${{ env.CODER_GO_VERSION }}
199
-
200
229
- uses : ./.github/actions/setup-go
201
230
202
231
- uses : hashicorp/setup-terraform@v2
@@ -218,8 +247,18 @@ jobs:
218
247
echo "cover=false" >> $GITHUB_OUTPUT
219
248
fi
220
249
250
+ # By default Go will use the number of logical CPUs, which
251
+ # is a fine default.
252
+ PARALLEL_FLAG=""
253
+ if [ "${{ matrix.os }}" == "windows-2019" ]; then
254
+ # Windows appears more I/O bound, so we increase parallelism
255
+ # to make better use of CPU.
256
+ PARALLEL_FLAG="-parallel=16"
257
+ fi
258
+
221
259
export TS_DEBUG_DISCO=true
222
- gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" --packages="./..." -- -parallel=8 -timeout=7m -short -failfast $COVERAGE_FLAGS
260
+ gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
261
+ --packages="./..." -- $PARALLEL_FLAG -short -failfast $COVERAGE_FLAGS
223
262
224
263
- name : Print test stats
225
264
if : success() || failure()
@@ -228,13 +267,6 @@ jobs:
228
267
# so we need to print the test stats to the log.
229
268
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
230
269
231
- - uses : actions/upload-artifact@v3
232
- if : success() || failure()
233
- with :
234
- name : gotests-${{ matrix.os }}.xml
235
- path : ./gotests.xml
236
- retention-days : 30
237
-
238
270
- uses : ./.github/actions/upload-datadog
239
271
if : always()
240
272
with :
@@ -254,6 +286,8 @@ jobs:
254
286
255
287
test-go-pg :
256
288
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
289
+ needs : changes
290
+ if : needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
257
291
# This timeout must be greater than the timeout set by `go test` in
258
292
# `make test-postgres` to ensure we receive a trace of running
259
293
# goroutines. Setting this to the timeout +5m should work quite well
@@ -307,6 +341,8 @@ jobs:
307
341
308
342
test-go-race :
309
343
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
344
+ needs : changes
345
+ if : needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
310
346
timeout-minutes : 25
311
347
steps :
312
348
- uses : actions/checkout@v3
@@ -352,11 +388,6 @@ jobs:
352
388
- name : Set up Google Cloud SDK
353
389
uses : google-github-actions/setup-gcloud@v1
354
390
355
- - uses : buildjet/setup-go@v4
356
- with :
357
- cache : false
358
- go-version : ${{ env.CODER_GO_VERSION }}
359
-
360
391
- uses : ./.github/actions/setup-go
361
392
- uses : ./.github/actions/setup-node
362
393
@@ -423,13 +454,15 @@ jobs:
423
454
424
455
test-js :
425
456
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
457
+ needs : changes
458
+ if : needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
426
459
timeout-minutes : 20
427
460
steps :
428
461
- uses : actions/checkout@v3
429
462
430
463
- uses : ./.github/actions/setup-node
431
464
432
- - run : yarn test:ci --max-workers ${{ steps.cpu-cores.outputs.count }}
465
+ - run : yarn test:ci --max-workers $(nproc)
433
466
working-directory : site
434
467
435
468
- uses : codecov/codecov-action@v3
@@ -445,10 +478,9 @@ jobs:
445
478
flags : unittest-js
446
479
447
480
test-e2e :
448
- needs :
449
- - changes
450
- if : needs.changes.outputs.docs-only == 'false'
451
481
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
482
+ needs : changes
483
+ if : needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
452
484
timeout-minutes : 20
453
485
steps :
454
486
- uses : actions/checkout@v3
@@ -461,10 +493,6 @@ jobs:
461
493
terraform_version : 1.1.9
462
494
terraform_wrapper : false
463
495
464
- - uses : buildjet/setup-node@v3
465
- with :
466
- node-version : " 16.16.0"
467
-
468
496
- name : Build
469
497
run : |
470
498
sudo npm install -g prettier
@@ -489,9 +517,8 @@ jobs:
489
517
chromatic :
490
518
# REMARK: this is only used to build storybook and deploy it to Chromatic.
491
519
runs-on : ubuntu-latest
492
- needs :
493
- - changes
494
- if : needs.changes.outputs.ts == 'true'
520
+ needs : changes
521
+ if : needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
495
522
steps :
496
523
- uses : actions/checkout@v3
497
524
with :
@@ -535,3 +562,28 @@ jobs:
535
562
buildScriptName : " storybook:build"
536
563
projectToken : 695c25b6cb65
537
564
workingDir : " ./site"
565
+
566
+ required :
567
+ runs-on : ubuntu-latest
568
+ needs : [gen, test-go, test-go-pg, test-go-race, test-js]
569
+ # Allow this job to run even if the needed jobs fail, are skipped or
570
+ # cancelled.
571
+ if : always()
572
+ steps :
573
+ - name : Ensure required checks
574
+ run : |
575
+ echo "Checking required checks"
576
+ echo "- gen: ${{ needs.gen.result }}"
577
+ echo "- test-go: ${{ needs.test-go.result }}"
578
+ echo "- test-go-pg: ${{ needs.test-go-pg.result }}"
579
+ echo "- test-go-race: ${{ needs.test-go-race.result }}"
580
+ echo "- test-js: ${{ needs.test-js.result }}"
581
+ echo
582
+
583
+ # We allow skipped jobs to pass, but not failed or cancelled jobs.
584
+ if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
585
+ echo "One of the required checks has failed or has been cancelled"
586
+ exit 1
587
+ fi
588
+
589
+ echo "Required checks have passed"
0 commit comments