6
6
- main
7
7
tags :
8
8
- " *"
9
- paths-ignore :
10
- - " docs/**"
11
9
12
10
pull_request :
13
11
@@ -32,9 +30,68 @@ concurrency:
32
30
cancel-in-progress : ${{ github.event_name == 'pull_request' }}
33
31
34
32
jobs :
33
+ changes :
34
+ runs-on : ubuntu-latest
35
+ outputs :
36
+ docs-only : ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
37
+ go : ${{ steps.filter.outputs.go }}
38
+ sh : ${{ steps.filter.outputs.sh }}
39
+ steps :
40
+ - uses : actions/checkout@v3
41
+ # For pull requests it's not necessary to checkout the code
42
+ - uses : dorny/paths-filter@v2
43
+ id : filter
44
+ with :
45
+ filters : |
46
+ all:
47
+ - '**'
48
+ docs:
49
+ - 'docs/**'
50
+ # For testing:
51
+ # - '.github/**'
52
+ go:
53
+ - "**.go"
54
+ - "**.mod"
55
+ - "**.sum"
56
+ sh:
57
+ - "**.sh"
58
+ - id : debug
59
+ run : |
60
+ echo "${{ toJSON(steps.filter )}}"
61
+
62
+ # Debug step
63
+ debug-inputs :
64
+ needs :
65
+ - changes
66
+ - pr-context
67
+ runs-on : ubuntu-latest
68
+ steps :
69
+ - id : log
70
+ run : |
71
+ echo "${{ toJSON(needs) }}"
72
+ echo "${{ contains(needs.pr-context.outputs.skips, 'test/go/postgres') }} "
73
+ echo "${{ contains(needs.pr-context.outputs.skips, 'test/e2e') }} "
74
+
75
+ pr-context :
76
+ runs-on : ubuntu-latest
77
+ outputs :
78
+ skips : ${{ steps.pr-context.outputs.skips }}
79
+ steps :
80
+ - uses : actions/checkout@v3
81
+ - uses : actions/setup-go@v3
82
+ with :
83
+ go-version : " ~1.18"
84
+ - id : pr-context
85
+ env :
86
+ GITHUB_CONTEXT : ${{ toJSON(github) }}
87
+ run : |
88
+ go run github.com/coder/coder/.github/workflows/prcontext
89
+
35
90
style-lint-golangci :
36
91
name : style/lint/golangci
37
92
timeout-minutes : 5
93
+ needs : changes
94
+ if : needs.changes.outputs.go == 'true'
38
95
runs-on : ubuntu-latest
39
96
steps :
40
97
- uses : actions/checkout@v3
50
107
name : style/lint/shellcheck
51
108
timeout-minutes : 5
52
109
runs-on : ubuntu-latest
110
+ needs : changes
111
+ if : needs.changes.outputs.sh == 'true'
53
112
steps :
54
113
- uses : actions/checkout@v3
55
114
- name : Run ShellCheck
62
121
style-lint-typescript :
63
122
name : " style/lint/typescript"
64
123
timeout-minutes : 5
124
+ needs : changes
125
+ if : needs.changes.outputs.docs-only == 'false'
65
126
runs-on : ubuntu-latest
66
127
steps :
67
128
- name : Checkout
@@ -87,8 +148,10 @@ jobs:
87
148
88
149
gen :
89
150
name : " style/gen"
90
- timeout-minutes : 5
151
+ timeout-minutes : 8
91
152
runs-on : ubuntu-latest
153
+ needs : changes
154
+ if : needs.changes.outputs.docs-only == 'false'
92
155
steps :
93
156
- uses : actions/checkout@v3
94
157
@@ -113,6 +176,25 @@ jobs:
113
176
- uses : actions/setup-go@v3
114
177
with :
115
178
go-version : " ~1.18"
179
+
180
+ - name : Echo Go Cache Paths
181
+ id : go-cache-paths
182
+ run : |
183
+ echo "::set-output name=go-build::$(go env GOCACHE)"
184
+ echo "::set-output name=go-mod::$(go env GOMODCACHE)"
185
+
186
+ - name : Go Build Cache
187
+ uses : actions/cache@v3
188
+ with :
189
+ path : ${{ steps.go-cache-paths.outputs.go-build }}
190
+ key : ${{ github.job }}-go-build-${{ hashFiles('**/go.sum', '**/**.go') }}
191
+
192
+ - name : Go Mod Cache
193
+ uses : actions/cache@v3
194
+ with :
195
+ path : ${{ steps.go-cache-paths.outputs.go-mod }}
196
+ key : ${{ github.job }}-go-mod-${{ hashFiles('**/go.sum') }}
197
+
116
198
- run : |
117
199
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.13.0/sqlc_1.13.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
118
200
@@ -124,6 +206,8 @@ jobs:
124
206
125
207
style-fmt :
126
208
name : " style/fmt"
209
+ needs : changes
210
+ if : needs.changes.outputs.docs-only == 'false'
127
211
runs-on : ubuntu-latest
128
212
timeout-minutes : 5
129
213
steps :
@@ -156,6 +240,8 @@ jobs:
156
240
157
241
test-go :
158
242
name : " test/go"
243
+ needs : changes
244
+ if : needs.changes.outputs.docs-only == 'false'
159
245
runs-on : ${{ matrix.os }}
160
246
timeout-minutes : 20
161
247
strategy :
@@ -181,7 +267,7 @@ jobs:
181
267
uses : actions/cache@v3
182
268
with :
183
269
path : ${{ steps.go-cache-paths.outputs.go-build }}
184
- key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum ') }}
270
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go ') }}
185
271
186
272
- name : Go Mod Cache
187
273
uses : actions/cache@v3
@@ -203,14 +289,23 @@ jobs:
203
289
terraform_wrapper : false
204
290
205
291
- name : Test with Mock Database
292
+ id : test
206
293
shell : bash
207
- run : gotestsum --junitfile="gotests.xml" --packages="./..." --
208
- -covermode=atomic -coverprofile="gotests.coverage"
209
- -coverpkg=./...,github.com/coder/coder/codersdk
210
- -timeout=5m -short -failfast
294
+ run : |
295
+ # Code coverage is more computationally expensive and also
296
+ # prevents test caching, so we disable it on alternate operating
297
+ # systems.
298
+ if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
299
+ echo ::set-output name=cover::true
300
+ export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...'
301
+ else
302
+ echo ::set-output name=cover::false
303
+ fi
304
+ set -x
305
+ gotestsum --junitfile="gotests.xml" --packages="./..." -- -parallel=8 -timeout=5m -short -failfast $COVERAGE_FLAGS
211
306
212
307
- name : Upload DataDog Trace
213
- if : always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
308
+ if : github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
214
309
env :
215
310
DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
216
311
DD_DATABASE : fake
@@ -224,14 +319,20 @@ jobs:
224
319
# that is no guarantee, see:
225
320
# https://github.com/codecov/codecov-action/issues/788
226
321
continue-on-error : true
227
- if : github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
322
+ if : steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
228
323
with :
229
324
token : ${{ secrets.CODECOV_TOKEN }}
230
325
files : ./gotests.coverage
231
326
flags : unittest-go-${{ matrix.os }}
232
327
233
328
test-go-postgres :
234
329
name : " test/go/postgres"
330
+ needs :
331
+ - changes
332
+ - pr-context
333
+ if : >
334
+ needs.changes.outputs.docs-only == 'false' &&
335
+ !contains(needs.pr-context.outputs.skips, 'test/go/postgres')
235
336
runs-on : ubuntu-latest
236
337
# This timeout must be greater than the timeout set by `go test` in
237
338
# `make test-postgres` to ensure we receive a trace of running
@@ -255,7 +356,7 @@ jobs:
255
356
uses : actions/cache@v3
256
357
with :
257
358
path : ${{ steps.go-cache-paths.outputs.go-build }}
258
- key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
359
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum', '**/**.go' ) }}
259
360
260
361
- name : Go Mod Cache
261
362
uses : actions/cache@v3
@@ -303,7 +404,10 @@ jobs:
303
404
name : " deploy"
304
405
runs-on : ubuntu-latest
305
406
timeout-minutes : 30
306
- if : github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
407
+ needs : changes
408
+ if : |
409
+ github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
410
+ && needs.changes.outputs.docs-only == 'false'
307
411
permissions :
308
412
contents : read
309
413
id-token : write
@@ -409,6 +513,8 @@ jobs:
409
513
410
514
test-js :
411
515
name : " test/js"
516
+ needs : changes
517
+ if : needs.changes.outputs.docs-only == 'false'
412
518
runs-on : ubuntu-latest
413
519
timeout-minutes : 20
414
520
steps :
@@ -462,6 +568,10 @@ jobs:
462
568
463
569
test-e2e :
464
570
name : " test/e2e/${{ matrix.os }}"
571
+ needs :
572
+ - changes
573
+ - pr-context
574
+ if : needs.changes.outputs.docs-only == 'false' && !contains(needs.pr-context.outputs.skips, 'test/e2e')
465
575
runs-on : ${{ matrix.os }}
466
576
timeout-minutes : 20
467
577
strategy :
@@ -478,9 +588,7 @@ jobs:
478
588
path : |
479
589
**/node_modules
480
590
.eslintcache
481
- key : js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
482
- restore-keys : |
483
- js-${{ runner.os }}-
591
+ key : js-${{ runner.os }}-e2e-${{ hashFiles('**/yarn.lock') }}
484
592
485
593
# Go is required for uploading the test results to datadog
486
594
- uses : actions/setup-go@v3
@@ -516,6 +624,7 @@ jobs:
516
624
517
625
- name : Build
518
626
run : |
627
+ sudo npm install -g prettier
519
628
make -B site/out/index.html
520
629
521
630
- run : yarn playwright:install
0 commit comments