@@ -27,6 +27,71 @@ concurrency:
2727cancel-in-progress :${{ github.event_name == 'pull_request' }}
2828
2929jobs :
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+
3095lint :
3196runs-on :${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
3297steps :
@@ -79,44 +144,11 @@ jobs:
79144 -name :Check for AGPL code importing Enterprise...
80145run :./scripts/check_enterprise_imports.sh
81146
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-
115147gen :
116148timeout-minutes :8
117149runs-on :${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
118150needs :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'
120152steps :
121153 -uses :actions/checkout@v3
122154
@@ -182,6 +214,8 @@ jobs:
182214
183215test-go :
184216runs-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'
185219timeout-minutes :20
186220strategy :
187221matrix :
@@ -192,11 +226,6 @@ jobs:
192226steps :
193227 -uses :actions/checkout@v3
194228
195- -uses :buildjet/setup-go@v4
196- with :
197- cache :false
198- go-version :${{ env.CODER_GO_VERSION }}
199-
200229 -uses :./.github/actions/setup-go
201230
202231 -uses :hashicorp/setup-terraform@v2
@@ -257,6 +286,8 @@ jobs:
257286
258287test-go-pg :
259288runs-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'
260291# This timeout must be greater than the timeout set by `go test` in
261292# `make test-postgres` to ensure we receive a trace of running
262293# goroutines. Setting this to the timeout +5m should work quite well
@@ -310,6 +341,8 @@ jobs:
310341
311342test-go-race :
312343runs-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'
313346timeout-minutes :25
314347steps :
315348 -uses :actions/checkout@v3
@@ -355,11 +388,6 @@ jobs:
355388 -name :Set up Google Cloud SDK
356389uses :google-github-actions/setup-gcloud@v1
357390
358- -uses :buildjet/setup-go@v4
359- with :
360- cache :false
361- go-version :${{ env.CODER_GO_VERSION }}
362-
363391 -uses :./.github/actions/setup-go
364392 -uses :./.github/actions/setup-node
365393
@@ -426,13 +454,15 @@ jobs:
426454
427455test-js :
428456runs-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'
429459timeout-minutes :20
430460steps :
431461 -uses :actions/checkout@v3
432462
433463 -uses :./.github/actions/setup-node
434464
435- -run :yarn test:ci --max-workers ${{ steps.cpu-cores.outputs.count }}
465+ -run :yarn test:ci --max-workers $(nproc)
436466working-directory :site
437467
438468 -uses :codecov/codecov-action@v3
@@ -448,10 +478,9 @@ jobs:
448478flags :unittest-js
449479
450480test-e2e :
451- needs :
452- -changes
453- if :needs.changes.outputs.docs-only == 'false'
454481runs-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'
455484timeout-minutes :20
456485steps :
457486 -uses :actions/checkout@v3
@@ -464,10 +493,6 @@ jobs:
464493terraform_version :1.1.9
465494terraform_wrapper :false
466495
467- -uses :buildjet/setup-node@v3
468- with :
469- node-version :" 16.16.0"
470-
471496 -name :Build
472497run :|
473498 sudo npm install -g prettier
@@ -492,9 +517,8 @@ jobs:
492517chromatic :
493518# REMARK: this is only used to build storybook and deploy it to Chromatic.
494519runs-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'
498522steps :
499523 -uses :actions/checkout@v3
500524with :
@@ -538,3 +562,15 @@ jobs:
538562buildScriptName :" storybook:build"
539563projectToken :695c25b6cb65
540564workingDir :" ./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"