@@ -30,9 +30,68 @@ concurrency:
30
30
cancel-in-progress : ${{ github.event_name == 'pull_request' }}
31
31
32
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
+
33
90
style-lint-golangci :
34
91
name : style/lint/golangci
35
92
timeout-minutes : 5
93
+ needs : changes
94
+ if : needs.changes.outputs.go == 'true'
36
95
runs-on : ubuntu-latest
37
96
steps :
38
97
- uses : actions/checkout@v3
48
107
name : style/lint/shellcheck
49
108
timeout-minutes : 5
50
109
runs-on : ubuntu-latest
110
+ needs : changes
111
+ if : needs.changes.outputs.sh == 'true'
51
112
steps :
52
113
- uses : actions/checkout@v3
53
114
- name : Run ShellCheck
60
121
style-lint-typescript :
61
122
name : " style/lint/typescript"
62
123
timeout-minutes : 5
124
+ needs : changes
125
+ if : needs.changes.outputs.docs-only == 'false'
63
126
runs-on : ubuntu-latest
64
127
steps :
65
128
- name : Checkout
87
150
name : " style/gen"
88
151
timeout-minutes : 5
89
152
runs-on : ubuntu-latest
153
+ needs : changes
154
+ if : needs.changes.outputs.docs-only == 'false'
90
155
steps :
91
156
- uses : actions/checkout@v3
92
157
@@ -111,6 +176,25 @@ jobs:
111
176
- uses : actions/setup-go@v3
112
177
with :
113
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
+
114
198
- run : |
115
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
116
200
@@ -122,6 +206,8 @@ jobs:
122
206
123
207
style-fmt :
124
208
name : " style/fmt"
209
+ needs : changes
210
+ if : needs.changes.outputs.docs-only == 'false'
125
211
runs-on : ubuntu-latest
126
212
timeout-minutes : 5
127
213
steps :
@@ -154,6 +240,8 @@ jobs:
154
240
155
241
test-go :
156
242
name : " test/go"
243
+ needs : changes
244
+ if : needs.changes.outputs.docs-only == 'false'
157
245
runs-on : ${{ matrix.os }}
158
246
timeout-minutes : 20
159
247
strategy :
@@ -179,7 +267,7 @@ jobs:
179
267
uses : actions/cache@v3
180
268
with :
181
269
path : ${{ steps.go-cache-paths.outputs.go-build }}
182
- key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum ') }}
270
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go ') }}
183
271
184
272
- name : Go Mod Cache
185
273
uses : actions/cache@v3
@@ -201,14 +289,23 @@ jobs:
201
289
terraform_wrapper : false
202
290
203
291
- name : Test with Mock Database
292
+ id : test
204
293
shell : bash
205
- run : gotestsum --junitfile="gotests.xml" --packages="./..." --
206
- -covermode=atomic -coverprofile="gotests.coverage"
207
- -coverpkg=./...
208
- -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
209
306
210
307
- name : Upload DataDog Trace
211
- 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
212
309
env :
213
310
DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
214
311
DD_DATABASE : fake
@@ -217,18 +314,31 @@ jobs:
217
314
run : go run scripts/datadog-cireport/main.go gotests.xml
218
315
219
316
- uses : codecov/codecov-action@v3
220
- if : github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
317
+ # This action has a tendency to error out unexpectedly, it has
318
+ # the `fail_ci_if_error` option that defaults to `false`, but
319
+ # that is no guarantee, see:
320
+ # https://github.com/codecov/codecov-action/issues/788
321
+ continue-on-error : true
322
+ if : steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
221
323
with :
222
324
token : ${{ secrets.CODECOV_TOKEN }}
223
325
files : ./gotests.coverage
224
326
flags : unittest-go-${{ matrix.os }}
225
- # this flakes and sometimes fails the build
226
- fail_ci_if_error : false
227
327
228
328
test-go-postgres :
229
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')
230
336
runs-on : ubuntu-latest
231
- timeout-minutes : 20
337
+ # This timeout must be greater than the timeout set by `go test` in
338
+ # `make test-postgres` to ensure we receive a trace of running
339
+ # goroutines. Setting this to the timeout +5m should work quite well
340
+ # even if some of the preceding steps are slow.
341
+ timeout-minutes : 25
232
342
steps :
233
343
- uses : actions/checkout@v3
234
344
@@ -246,7 +356,7 @@ jobs:
246
356
uses : actions/cache@v3
247
357
with :
248
358
path : ${{ steps.go-cache-paths.outputs.go-build }}
249
- key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
359
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum', '**/**.go' ) }}
250
360
251
361
- name : Go Mod Cache
252
362
uses : actions/cache@v3
@@ -279,19 +389,25 @@ jobs:
279
389
run : go run scripts/datadog-cireport/main.go gotests.xml
280
390
281
391
- uses : codecov/codecov-action@v3
392
+ # This action has a tendency to error out unexpectedly, it has
393
+ # the `fail_ci_if_error` option that defaults to `false`, but
394
+ # that is no guarantee, see:
395
+ # https://github.com/codecov/codecov-action/issues/788
396
+ continue-on-error : true
282
397
if : github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
283
398
with :
284
399
token : ${{ secrets.CODECOV_TOKEN }}
285
400
files : ./gotests.coverage
286
401
flags : unittest-go-postgres-${{ matrix.os }}
287
- # this flakes and sometimes fails the build
288
- fail_ci_if_error : false
289
402
290
403
deploy :
291
404
name : " deploy"
292
405
runs-on : ubuntu-latest
293
406
timeout-minutes : 30
294
- 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'
295
411
permissions :
296
412
contents : read
297
413
id-token : write
@@ -369,7 +485,8 @@ jobs:
369
485
./scripts/build_go_matrix.sh \
370
486
--output ./dist/ \
371
487
--package-linux \
372
- linux:amd64
488
+ linux:amd64 \
489
+ windows:amd64
373
490
374
491
- name : Install Release
375
492
run : |
@@ -387,6 +504,7 @@ jobs:
387
504
name : coder
388
505
path : |
389
506
./dist/*.zip
507
+ ./dist/*.exe
390
508
./dist/*.tar.gz
391
509
./dist/*.apk
392
510
./dist/*.deb
@@ -395,6 +513,8 @@ jobs:
395
513
396
514
test-js :
397
515
name : " test/js"
516
+ needs : changes
517
+ if : needs.changes.outputs.docs-only == 'false'
398
518
runs-on : ubuntu-latest
399
519
timeout-minutes : 20
400
520
steps :
@@ -427,13 +547,16 @@ jobs:
427
547
working-directory : site
428
548
429
549
- uses : codecov/codecov-action@v3
550
+ # This action has a tendency to error out unexpectedly, it has
551
+ # the `fail_ci_if_error` option that defaults to `false`, but
552
+ # that is no guarantee, see:
553
+ # https://github.com/codecov/codecov-action/issues/788
554
+ continue-on-error : true
430
555
if : github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
431
556
with :
432
557
token : ${{ secrets.CODECOV_TOKEN }}
433
558
files : ./site/coverage/lcov.info
434
559
flags : unittest-js
435
- # this flakes and sometimes fails the build
436
- fail_ci_if_error : false
437
560
438
561
- name : Upload DataDog Trace
439
562
if : always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
@@ -445,6 +568,10 @@ jobs:
445
568
446
569
test-e2e :
447
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')
448
575
runs-on : ${{ matrix.os }}
449
576
timeout-minutes : 20
450
577
strategy :
@@ -461,9 +588,7 @@ jobs:
461
588
path : |
462
589
**/node_modules
463
590
.eslintcache
464
- key : js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
465
- restore-keys : |
466
- js-${{ runner.os }}-
591
+ key : js-${{ runner.os }}-e2e-${{ hashFiles('**/yarn.lock') }}
467
592
468
593
# Go is required for uploading the test results to datadog
469
594
- uses : actions/setup-go@v3
@@ -499,6 +624,7 @@ jobs:
499
624
500
625
- name : Build
501
626
run : |
627
+ sudo npm install -g prettier
502
628
make -B site/out/index.html
503
629
504
630
- run : yarn playwright:install
0 commit comments