@@ -60,13 +60,31 @@ jobs:
60
60
echo "${{ toJSON(steps.filter )}}"
61
61
62
62
# Debug step
63
- show-changes :
64
- needs : changes
63
+ debug-inputs :
64
+ needs :
65
+ - changes
66
+ - pr-context
65
67
runs-on : ubuntu-latest
66
68
steps :
67
69
- id : log
68
70
run : |
69
- echo "${{ toJSON(needs.changes) }}"
71
+ echo "${{ toJSON(needs) }}"
72
+ echo "${{ contains(needs.pr-context.outputs.skips, 'postgres') }} "
73
+
74
+ pr-context :
75
+ runs-on : ubuntu-latest
76
+ outputs :
77
+ skips : ${{ steps.pr-context.outputs.skips }}
78
+ steps :
79
+ - uses : actions/checkout@v3
80
+ - uses : actions/setup-go@v3
81
+ with :
82
+ go-version : " ~1.18"
83
+ - id : pr-context
84
+ env :
85
+ GITHUB_CONTEXT : ${{ toJSON(github) }}
86
+ run : |
87
+ go run github.com/coder/coder/.github/workflows/prcontext
70
88
71
89
style-lint-golangci :
72
90
name : style/lint/golangci
@@ -157,6 +175,25 @@ jobs:
157
175
- uses : actions/setup-go@v3
158
176
with :
159
177
go-version : " ~1.18"
178
+
179
+ - name : Echo Go Cache Paths
180
+ id : go-cache-paths
181
+ run : |
182
+ echo "::set-output name=go-build::$(go env GOCACHE)"
183
+ echo "::set-output name=go-mod::$(go env GOMODCACHE)"
184
+
185
+ - name : Go Build Cache
186
+ uses : actions/cache@v3
187
+ with :
188
+ path : ${{ steps.go-cache-paths.outputs.go-build }}
189
+ key : ${{ github.job }}-go-build-${{ hashFiles('**/go.sum', '**/**.go') }}
190
+
191
+ - name : Go Mod Cache
192
+ uses : actions/cache@v3
193
+ with :
194
+ path : ${{ steps.go-cache-paths.outputs.go-mod }}
195
+ key : ${{ github.job }}-go-mod-${{ hashFiles('**/go.sum') }}
196
+
160
197
- run : |
161
198
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
162
199
@@ -229,7 +266,7 @@ jobs:
229
266
uses : actions/cache@v3
230
267
with :
231
268
path : ${{ steps.go-cache-paths.outputs.go-build }}
232
- key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum ') }}
269
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go ') }}
233
270
234
271
- name : Go Mod Cache
235
272
uses : actions/cache@v3
@@ -251,14 +288,23 @@ jobs:
251
288
terraform_wrapper : false
252
289
253
290
- name : Test with Mock Database
291
+ id : test
254
292
shell : bash
255
- run : gotestsum --junitfile="gotests.xml" --packages="./..." --
256
- -covermode=atomic -coverprofile="gotests.coverage"
257
- -coverpkg=./...,github.com/coder/coder/codersdk
258
- -timeout=5m -short -failfast
293
+ run : |
294
+ # Code coverage is more computationally expensive and also
295
+ # prevents test caching, so we disable it on alternate operating
296
+ # systems.
297
+ if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
298
+ echo ::set-output name=cover::true
299
+ export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...,github.com/coder/coder/codersdk'
300
+ else
301
+ echo ::set-output name=cover::false
302
+ fi
303
+ set -x
304
+ gotestsum --junitfile="gotests.xml" --packages="./..." -- -parallel=8 -timeout=5m -short -failfast $COVERAGE_FLAGS
259
305
260
306
- name : Upload DataDog Trace
261
- if : always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
307
+ if : github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
262
308
env :
263
309
DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
264
310
DD_DATABASE : fake
@@ -272,16 +318,20 @@ jobs:
272
318
# that is no guarantee, see:
273
319
# https://github.com/codecov/codecov-action/issues/788
274
320
continue-on-error : true
275
- if : github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
321
+ if : steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
276
322
with :
277
323
token : ${{ secrets.CODECOV_TOKEN }}
278
324
files : ./gotests.coverage
279
325
flags : unittest-go-${{ matrix.os }}
280
326
281
327
test-go-postgres :
282
328
name : " test/go/postgres"
283
- needs : changes
284
- if : needs.changes.outputs.docs-only == 'false'
329
+ needs :
330
+ - changes
331
+ - pr-context
332
+ if : >
333
+ needs.changes.outputs.docs-only == 'false' &&
334
+ contains(needs.pr-context.outputs.skips, github.job) == 'false'
285
335
runs-on : ubuntu-latest
286
336
# This timeout must be greater than the timeout set by `go test` in
287
337
# `make test-postgres` to ensure we receive a trace of running
@@ -305,7 +355,7 @@ jobs:
305
355
uses : actions/cache@v3
306
356
with :
307
357
path : ${{ steps.go-cache-paths.outputs.go-build }}
308
- key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
358
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum', '**/**.go' ) }}
309
359
310
360
- name : Go Mod Cache
311
361
uses : actions/cache@v3
@@ -517,8 +567,10 @@ jobs:
517
567
518
568
test-e2e :
519
569
name : " test/e2e/${{ matrix.os }}"
520
- needs : changes
521
- if : needs.changes.outputs.docs-only == 'false'
570
+ needs :
571
+ - changes
572
+ - pr-context
573
+ if : needs.changes.outputs.docs-only == 'false' && !contains(needs.pr-context.outputs.skips, 'test/e2e')
522
574
runs-on : ${{ matrix.os }}
523
575
timeout-minutes : 20
524
576
strategy :
@@ -535,9 +587,7 @@ jobs:
535
587
path : |
536
588
**/node_modules
537
589
.eslintcache
538
- key : js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
539
- restore-keys : |
540
- js-${{ runner.os }}-
590
+ key : js-${{ runner.os }}-e2e-${{ hashFiles('**/yarn.lock') }}
541
591
542
592
# Go is required for uploading the test results to datadog
543
593
- uses : actions/setup-go@v3
@@ -573,6 +623,7 @@ jobs:
573
623
574
624
- name : Build
575
625
run : |
626
+ sudo npm install -g prettier
576
627
make -B site/out/index.html
577
628
578
629
- run : yarn playwright:install
0 commit comments