@@ -60,24 +60,56 @@ jobs:
60
60
needs : [ tests ]
61
61
runs-on : ubuntu-latest
62
62
steps :
63
+ - name : Checkout code
64
+ uses : actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
65
+
63
66
- uses : actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
64
67
with :
65
68
node-version : 20
66
69
70
+ - name : Set up Go
71
+ uses : actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
72
+ with :
73
+ go-version : ' ^1.22'
74
+ cache : true
75
+
67
76
- name : Download artifacts
68
77
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
69
78
70
79
- name : Install junit-report-merger
71
80
run : npm install -g junit-report-merger
72
81
73
- - name : Merge reports
82
+ - name : Install gocovmerge
83
+ run : go install github.com/wadey/gocovmerge@latest
84
+
85
+ # Note -- we're intentionally including this in the same job as the running of the tests themselves. This is to
86
+ # future proof for when Datadog supports tracing of Go tests rather than just uploading coverage results.
87
+ # Ref: https://docs.datadoghq.com/continuous_integration/setup_tests/
88
+ - name : prepare datadog-ci
89
+ run : |
90
+ curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64" --output "/usr/local/bin/datadog-ci"
91
+ chmod +x /usr/local/bin/datadog-ci
92
+
93
+ - name : Merge coverage reports
94
+ run : |
95
+ gocovmerge junit-test-summary-0/cover.out > merged-coverage.out
96
+
97
+ - name : Merge junit reports
74
98
run : jrm ./ci-summary.xml "junit-test-summary-0/*.xml"
75
99
76
100
- name : Upload test artifacts
77
101
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
78
102
with :
79
103
name : junit-test-summary
80
104
path : ./ci-summary.xml
105
+
106
+ - name : upload coverage
107
+ env :
108
+ DATADOG_API_KEY : " ${{ secrets.TF_WORKFLOW_DATADOG_API_KEY }}"
109
+ DD_ENV : ci
110
+ run : |
111
+ coverage=$(go tool cover -func merged-coverage.out | tail -n 1 | awk '{print $3}' | tr -d -c 0-9.)
112
+ datadog-ci junit upload --service "$GITHUB_REPOSITORY" --report-measures=test.code_coverage.lines_pct:$coverage ./ci-summary.xml
81
113
82
114
tests-summarize :
83
115
name : Summarize Tests
0 commit comments