@@ -216,6 +216,20 @@ jobs:
216
216
echo AUTHD_TEST_ARTIFACTS_PATH="${artifacts_dir}" >> $GITHUB_ENV
217
217
218
218
echo ASAN_OPTIONS="log_path=${artifacts_dir}/asan.log:print_stats=true" >> $GITHUB_ENV
219
+
220
+ - name : Install coverage collection dependencies
221
+ if : matrix.test == 'coverage'
222
+ run : |
223
+ set -eu
224
+
225
+ # Dependendencies for C coverage collection
226
+ sudo apt install -y gcovr
227
+
228
+ # Dependendencies for Go coverage collection
229
+ go install github.com/AlekSi/gocov-xml@latest
230
+ go install github.com/axw/gocov/gocov@latest
231
+ dotnet tool install -g dotnet-reportgenerator-globaltool
232
+
219
233
- name : Run tests (with coverage collection)
220
234
if : matrix.test == 'coverage'
221
235
env :
@@ -224,10 +238,10 @@ jobs:
224
238
set -euo pipefail
225
239
226
240
# The coverage is not written if the output directory does not exist, so we need to create it.
227
- cov_dir="$(pwd) /coverage"
228
- cod_cov_dir="$(pwd)/coverage/ codecov"
229
- raw_cov_dir=" ${cov_dir}/raw"
230
- mkdir -p "${raw_cov_dir}" "${cod_cov_dir }"
241
+ cov_dir=${PWD} /coverage
242
+ codecov_dir=${cov_dir}/ codecov
243
+ raw_cov_dir=${cov_dir}/raw
244
+ mkdir -p "${raw_cov_dir}" "${codecov_dir }"
231
245
232
246
# Print executed commands to ease debugging
233
247
set -x
@@ -245,10 +259,17 @@ jobs:
245
259
cat "${raw_cov_dir}/rust-cov/rust2go_coverage" >>"${cov_dir}/coverage.out"
246
260
247
261
# Filter out the testutils package and the pb.go file
248
- grep -v -e "testutils" -e "pb.go" "${cov_dir}/coverage.out" >"${cod_cov_dir}/coverage.out.filtered"
262
+ grep -v -e "testutils" -e "pb.go" -e "testsdetection" "${cov_dir}/coverage.out" >"${cov_dir}/coverage.out.filtered"
263
+
264
+ # Generate the Cobertura report for Go and Rust
265
+ gocov convert "${cov_dir}/coverage.out.filtered" | gocov-xml > "${cov_dir}/coverage.xml"
266
+ reportgenerator -reports:"${cov_dir}/coverage.xml" -targetdir:"${codecov_dir}" -reporttypes:Cobertura
267
+
268
+ # Generate the Cobertura report for C
269
+ gcovr --cobertura "${codecov_dir}/Cobertura_C.xml" "${raw_cov_dir}"
249
270
250
- # Move gcov output to coverage dir
251
- mv "${raw_cov_dir}"/*.gcov "${cod_cov_dir}"
271
+ # Store the coverage directory for the next steps
272
+ echo COVERAGE_DIR= "${codecov_dir}" >> ${GITHUB_ENV}
252
273
253
274
- name : Run tests (with race detector)
254
275
if : matrix.test == 'race'
@@ -312,9 +333,16 @@ jobs:
312
333
if : matrix.test == 'coverage'
313
334
uses : codecov/codecov-action@v5
314
335
with :
315
- directory : ./coverage/codecov
336
+ files : ${{ env.COVERAGE_DIR }}/Cobertura.xml, ${{ env.COVERAGE_DIR }}/Cobertura_C.xml
316
337
token : ${{ secrets.CODECOV_TOKEN }}
317
338
339
+ - name : Upload coverage artifacts
340
+ if : matrix.test == 'coverage' && github.ref == 'refs/heads/main'
341
+ uses : actions/upload-artifact@v4
342
+ with :
343
+ name : coverage.zip
344
+ path : ${{ env.COVERAGE_DIR }}
345
+
318
346
- name : Upload test artifacts
319
347
if : always()
320
348
uses : actions/upload-artifact@v4
0 commit comments