@@ -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
@@ -182,6 +214,8 @@ jobs:
182
214
183
215
test-go :
184
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
@@ -257,6 +286,8 @@ jobs:
257
286
258
287
test-go-pg :
259
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'
260
291
# This timeout must be greater than the timeout set by `go test` in
261
292
# `make test-postgres` to ensure we receive a trace of running
262
293
# goroutines. Setting this to the timeout +5m should work quite well
@@ -310,6 +341,8 @@ jobs:
310
341
311
342
test-go-race :
312
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'
313
346
timeout-minutes :25
314
347
steps :
315
348
-uses :actions/checkout@v3
@@ -355,11 +388,6 @@ jobs:
355
388
-name :Set up Google Cloud SDK
356
389
uses :google-github-actions/setup-gcloud@v1
357
390
358
- -uses :buildjet/setup-go@v4
359
- with :
360
- cache :false
361
- go-version :${{ env.CODER_GO_VERSION }}
362
-
363
391
-uses :./.github/actions/setup-go
364
392
-uses :./.github/actions/setup-node
365
393
@@ -426,13 +454,15 @@ jobs:
426
454
427
455
test-js :
428
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'
429
459
timeout-minutes :20
430
460
steps :
431
461
-uses :actions/checkout@v3
432
462
433
463
-uses :./.github/actions/setup-node
434
464
435
- -run :yarn test:ci --max-workers ${{ steps.cpu-cores.outputs.count }}
465
+ -run :yarn test:ci --max-workers $(nproc)
436
466
working-directory :site
437
467
438
468
-uses :codecov/codecov-action@v3
@@ -448,10 +478,9 @@ jobs:
448
478
flags :unittest-js
449
479
450
480
test-e2e :
451
- needs :
452
- -changes
453
- if :needs.changes.outputs.docs-only == 'false'
454
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'
455
484
timeout-minutes :20
456
485
steps :
457
486
-uses :actions/checkout@v3
@@ -464,10 +493,6 @@ jobs:
464
493
terraform_version :1.1.9
465
494
terraform_wrapper :false
466
495
467
- -uses :buildjet/setup-node@v3
468
- with :
469
- node-version :" 16.16.0"
470
-
471
496
-name :Build
472
497
run :|
473
498
sudo npm install -g prettier
@@ -492,9 +517,8 @@ jobs:
492
517
chromatic :
493
518
# REMARK: this is only used to build storybook and deploy it to Chromatic.
494
519
runs-on :ubuntu-latest
495
- needs :
496
- -changes
497
- 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'
498
522
steps :
499
523
-uses :actions/checkout@v3
500
524
with :
@@ -538,3 +562,15 @@ jobs:
538
562
buildScriptName :" storybook:build"
539
563
projectToken :695c25b6cb65
540
564
workingDir :" ./site"
565
+
566
+ required :
567
+ runs-on :ubuntu-latest
568
+ needs :[test-go, test-go-pg, test-js]
569
+ # allow this job to run even if the previous jobs are skipped
570
+ if :|
571
+ always() &&
572
+ !contains(needs.*.result, 'failure') &&
573
+ !contains(needs.*.result, 'cancelled')
574
+ steps :
575
+ -name :Ensure required checks
576
+ run :echo "Required checks have passed"