@@ -135,19 +135,31 @@ jobs:
135135 with :
136136 go-version : " ^1.17"
137137
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
139146 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') }}
149149
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
151163
152164 - uses : hashicorp/setup-terraform@v1
153165 with :
@@ -162,7 +174,7 @@ jobs:
162174 run : gotestsum --junitfile="gotests.xml" --packages="./..." --
163175 -covermode=atomic -coverprofile="gotests.coverage"
164176 -coverpkg=./...,github.com/coder/coder/codersdk
165- -timeout=3m -count=$GOCOUNT -race - short -failfast
177+ -timeout=3m -count=$GOCOUNT -short -failfast
166178
167179 - name : Upload DataDog Trace
168180 if : (success() || failure()) && github.actor != 'dependabot[bot]'
@@ -173,29 +185,91 @@ jobs:
173185 GIT_COMMIT_MESSAGE : ${{ github.event.head_commit.message }}
174186 run : go run scripts/datadog-cireport/main.go gotests.xml
175187
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+
176259 - 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="./..." --
179261 -covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
180262 -coverpkg=./...,github.com/coder/coder/codersdk
181- -count=1 -parallel=2 -failfast
263+ -count=1 -parallel=2 -race - failfast
182264
183265 - name : Upload DataDog Trace
184- if : (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
266+ if : (success() || failure()) && github.actor != 'dependabot[bot]'
185267 env :
186268 DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
187269 DD_DATABASE : postgresql
188270 GIT_COMMIT_MESSAGE : ${{ github.event.head_commit.message }}
189271 run : go run scripts/datadog-cireport/main.go gotests.xml
190272
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-
199273 deploy :
200274 name : " deploy"
201275 runs-on : ubuntu-latest
@@ -339,17 +413,23 @@ jobs:
339413 with :
340414 install-only : true
341415
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
343424 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') }}
353433
354434 - run : make build
355435
0 commit comments