@@ -135,19 +135,31 @@ jobs:
135
135
with :
136
136
go-version : " ^1.17"
137
137
138
- - uses : actions/cache@v3
138
+ - name : Echo Go Cache Paths
139
+ id : go-cache-paths
140
+ run : |
141
+ echo "::set-output name=go-build::$(go env GOCACHE)"
142
+ echo "::set-output name=go-mod::$(go env GOMODCACHE)"
143
+
144
+ - name : Go Build Cache
145
+ uses : actions/cache@v3
139
146
with :
140
- # Go mod cache, Linux build cache, Mac build cache, Windows build cache
141
- path : |
142
- ~/go/pkg/mod
143
- ~/.cache/go-build
144
- ~/Library/Caches/go-build
145
- %LocalAppData%\go-build
146
- key : ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
147
- restore-keys : |
148
- ${{ matrix.os }}-go-
147
+ path : ${{ steps.go-cache-paths.outputs.go-build }}
148
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
149
149
150
- - run : go install gotest.tools/gotestsum@latest
150
+ - name : Go Mod Cache
151
+ uses : actions/cache@v3
152
+ with :
153
+ path : ${{ steps.go-cache-paths.outputs.go-mod }}
154
+ key : ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
155
+
156
+ - name : Install goreleaser
157
+
158
+ env :
159
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
160
+ with :
161
+ repo : gotestyourself/gotestsum
162
+ tag : v1.7.0
151
163
152
164
- uses : hashicorp/setup-terraform@v1
153
165
with :
@@ -162,7 +174,7 @@ jobs:
162
174
run : gotestsum --junitfile="gotests.xml" --packages="./..." --
163
175
-covermode=atomic -coverprofile="gotests.coverage"
164
176
-coverpkg=./...,github.com/coder/coder/codersdk
165
- -timeout=3m -count=$GOCOUNT -race - short -failfast
177
+ -timeout=3m -count=$GOCOUNT -short -failfast
166
178
167
179
- name : Upload DataDog Trace
168
180
if : (success() || failure()) && github.actor != 'dependabot[bot]'
@@ -173,29 +185,91 @@ jobs:
173
185
GIT_COMMIT_MESSAGE : ${{ github.event.head_commit.message }}
174
186
run : go run scripts/datadog-cireport/main.go gotests.xml
175
187
188
+ - uses : codecov/codecov-action@v2
189
+ if : github.actor != 'dependabot[bot]'
190
+ with :
191
+ token : ${{ secrets.CODECOV_TOKEN }}
192
+ files : ./gotests.coverage
193
+ flags : unittest-go-${{ matrix.os }}
194
+ fail_ci_if_error : true
195
+
196
+ test-go-postgres :
197
+ name : " test/go/postgres"
198
+ runs-on : ubuntu-latest
199
+ steps :
200
+ - uses : actions/checkout@v3
201
+
202
+ - uses : actions/setup-go@v2
203
+ with :
204
+ go-version : " ^1.17"
205
+
206
+ - name : Echo Go Cache Paths
207
+ id : go-cache-paths
208
+ run : |
209
+ echo "::set-output name=go-build::$(go env GOCACHE)"
210
+ echo "::set-output name=go-mod::$(go env GOMODCACHE)"
211
+
212
+ - name : Go Build Cache
213
+ uses : actions/cache@v3
214
+ with :
215
+ path : ${{ steps.go-cache-paths.outputs.go-build }}
216
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
217
+
218
+ - name : Go Mod Cache
219
+ uses : actions/cache@v3
220
+ with :
221
+ path : ${{ steps.go-cache-paths.outputs.go-mod }}
222
+ key : ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
223
+
224
+ - name : Install goreleaser
225
+
226
+ env :
227
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
228
+ with :
229
+ repo : gotestyourself/gotestsum
230
+ tag : v1.7.0
231
+
232
+ - uses : hashicorp/setup-terraform@v1
233
+ with :
234
+ terraform_version : 1.1.2
235
+ terraform_wrapper : false
236
+
237
+ - name : Start PostgreSQL Database
238
+ env :
239
+ POSTGRES_PASSWORD : postgres
240
+ POSTGRES_USER : postgres
241
+ POSTGRES_DB : postgres
242
+ PGDATA : /tmp
243
+ run : |
244
+ docker run \
245
+ -e POSTGRES_PASSWORD=postgres \
246
+ -e POSTGRES_USER=postgres \
247
+ -e POSTGRES_DB=postgres \
248
+ -e PGDATA=/tmp \
249
+ -p 5432:5432 \
250
+ -d postgres:11 \
251
+ -c shared_buffers=1GB \
252
+ -c max_connections=1000
253
+ while ! pg_isready -h 127.0.0.1
254
+ do
255
+ echo "$(date) - waiting for database to start"
256
+ sleep 0.5
257
+ done
258
+
176
259
- name : Test with PostgreSQL Database
177
- if : runner.os == 'Linux'
178
- run : DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
260
+ run : DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." --
179
261
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
180
262
-coverpkg=./...,github.com/coder/coder/codersdk
181
- -count=1 -parallel=2 -failfast
263
+ -count=1 -parallel=2 -race - failfast
182
264
183
265
- name : Upload DataDog Trace
184
- if : (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
266
+ if : (success() || failure()) && github.actor != 'dependabot[bot]'
185
267
env :
186
268
DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
187
269
DD_DATABASE : postgresql
188
270
GIT_COMMIT_MESSAGE : ${{ github.event.head_commit.message }}
189
271
run : go run scripts/datadog-cireport/main.go gotests.xml
190
272
191
- - uses : codecov/codecov-action@v2
192
- if : github.actor != 'dependabot[bot]'
193
- with :
194
- token : ${{ secrets.CODECOV_TOKEN }}
195
- files : ./gotests.coverage
196
- flags : unittest-go-${{ matrix.os }}
197
- fail_ci_if_error : true
198
-
199
273
deploy :
200
274
name : " deploy"
201
275
runs-on : ubuntu-latest
@@ -339,17 +413,23 @@ jobs:
339
413
with :
340
414
install-only : true
341
415
342
- - uses : actions/cache@v3
416
+ - name : Echo Go Cache Paths
417
+ id : go-cache-paths
418
+ run : |
419
+ echo "::set-output name=go-build::$(go env GOCACHE)"
420
+ echo "::set-output name=go-mod::$(go env GOMODCACHE)"
421
+
422
+ - name : Go Build Cache
423
+ uses : actions/cache@v3
343
424
with :
344
- # Go mod cache, Linux build cache, Mac build cache, Windows build cache
345
- path : |
346
- ~/go/pkg/mod
347
- ~/.cache/go-build
348
- ~/Library/Caches/go-build
349
- %LocalAppData%\go-build
350
- key : ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
351
- restore-keys : |
352
- ${{ matrix.os }}-go-
425
+ path : ${{ steps.go-cache-paths.outputs.go-build }}
426
+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
427
+
428
+ - name : Go Mod Cache
429
+ uses : actions/cache@v3
430
+ with :
431
+ path : ${{ steps.go-cache-paths.outputs.go-mod }}
432
+ key : ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
353
433
354
434
- run : make build
355
435
0 commit comments