Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 613f90c

Browse files
authored
ci: send test statistics to DataDog (coder#7786)
1 parent 083449c commit 613f90c

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

.github/actions/setup-go/action.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ runs:
88
with:
99
cache: true
1010
go-version: "~1.20"
11+
- name: Install gotestsum
12+
uses: jaxxstorm/[email protected]
13+
with:
14+
repo: gotestyourself/gotestsum
15+
tag: v1.9.0
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Upload tests to datadog
2+
if: always()
3+
inputs:
4+
api-key:
5+
description: "Datadog API key"
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- shell: bash
11+
run: |
12+
npm install -g @datadog/datadog-ci
13+
datadog-ci junit upload --service coder ./gotests.xml \
14+
--tags os:${{runner.os}} --tags runner_name:${{runner.name}}
15+
env:
16+
DATADOG_API_KEY: ${{ inputs.api-key }}

.github/workflows/ci.yaml

+16-17
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,6 @@ jobs:
199199

200200
- uses: ./.github/actions/setup-go
201201

202-
- name: Install gotestsum
203-
uses: jaxxstorm/[email protected]
204-
env:
205-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
206-
with:
207-
repo: gotestyourself/gotestsum
208-
tag: v1.9.0
209-
210202
- uses: hashicorp/setup-terraform@v2
211203
with:
212204
terraform_version: 1.1.9
@@ -243,6 +235,11 @@ jobs:
243235
path: ./gotests.xml
244236
retention-days: 30
245237

238+
- uses: ./.github/actions/upload-datadog
239+
if: always()
240+
with:
241+
api-key: ${{ secrets.DATADOG_API_KEY }}
242+
246243
- uses: codecov/codecov-action@v3
247244
# This action has a tendency to error out unexpectedly, it has
248245
# the `fail_ci_if_error` option that defaults to `false`, but
@@ -267,14 +264,6 @@ jobs:
267264

268265
- uses: ./.github/actions/setup-go
269266

270-
- name: Install gotestsum
271-
uses: jaxxstorm/[email protected]
272-
env:
273-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
274-
with:
275-
repo: gotestyourself/gotestsum
276-
tag: v1.9.0
277-
278267
- uses: hashicorp/setup-terraform@v2
279268
with:
280269
terraform_version: 1.1.9
@@ -299,6 +288,11 @@ jobs:
299288
path: ./gotests.xml
300289
retention-days: 30
301290

291+
- uses: ./.github/actions/upload-datadog
292+
if: always()
293+
with:
294+
api-key: ${{ secrets.DATADOG_API_KEY }}
295+
302296
- uses: codecov/codecov-action@v3
303297
# This action has a tendency to error out unexpectedly, it has
304298
# the `fail_ci_if_error` option that defaults to `false`, but
@@ -326,7 +320,12 @@ jobs:
326320

327321
- name: Run Tests
328322
run: |
329-
go test -race ./...
323+
gotestsum --junitfile="gotests.xml" -- -race ./...
324+
325+
- uses: ./.github/actions/upload-datadog
326+
if: always()
327+
with:
328+
api-key: ${{ secrets.DATADOG_API_KEY }}
330329

331330
deploy:
332331
name: "deploy"

0 commit comments

Comments
 (0)