@@ -208,6 +208,20 @@ jobs:
208
208
echo AUTHD_TEST_ARTIFACTS_PATH="${artifacts_dir}" >> $GITHUB_ENV
209
209
210
210
echo ASAN_OPTIONS="log_path=${artifacts_dir}/asan.log:print_stats=true" >> $GITHUB_ENV
211
+
212
+ - name : Install coverage collection dependencies
213
+ if : matrix.test == 'coverage'
214
+ run : |
215
+ set -eu
216
+
217
+ # Dependendencies for C coverage collection
218
+ sudo apt install -y gcovr
219
+
220
+ # Dependendencies for Go coverage collection
221
+ go install github.com/AlekSi/gocov-xml@latest
222
+ go install github.com/axw/gocov/gocov@latest
223
+ dotnet tool install -g dotnet-reportgenerator-globaltool
224
+
211
225
- name : Run tests (with coverage collection)
212
226
if : matrix.test == 'coverage'
213
227
env :
@@ -217,9 +231,9 @@ jobs:
217
231
218
232
# The coverage is not written if the output directory does not exist, so we need to create it.
219
233
cov_dir="$(pwd)/coverage"
220
- cod_cov_dir ="$(pwd)/coverage/codecov"
234
+ codecov_dir ="$(pwd)/coverage/codecov"
221
235
raw_cov_dir="${cov_dir}/raw"
222
- mkdir -p "${raw_cov_dir}" "${cod_cov_dir }"
236
+ mkdir -p "${raw_cov_dir}" "${codecov_dir }"
223
237
224
238
# Print executed commands to ease debugging
225
239
set -x
@@ -237,10 +251,17 @@ jobs:
237
251
cat "${raw_cov_dir}/rust-cov/rust2go_coverage" >>"${cov_dir}/coverage.out"
238
252
239
253
# Filter out the testutils package and the pb.go file
240
- grep -v -e "testutils" -e "pb.go" "${cov_dir}/coverage.out" >"${cod_cov_dir}/coverage.out.filtered"
254
+ grep -v -e "testutils" -e "pb.go" -e "testsdetection" "${cov_dir}/coverage.out" >"${cov_dir}/coverage.out.filtered"
255
+
256
+ # Generate the Cobertura report for Go and Rust
257
+ gocov convert "${cov_dir}/coverage.out.filtered" | gocov-xml > "${cov_dir}/coverage.xml"
258
+ reportgenerator -reports:"${cov_dir}/coverage.xml" -targetdir:"${codecov_dir}" -reporttypes:Cobertura
259
+
260
+ # Generate the Cobertura report for C
261
+ gcovr --cobertura "${codecov_dir}/Cobertura_C.xml" "${raw_cov_dir}"
241
262
242
- # Move gcov output to coverage dir
243
- mv "${raw_cov_dir}"/*.gcov "${cod_cov_dir}"
263
+ # Store the coverage directory for the next steps
264
+ echo COVERAGE_DIR= "${codecov_dir}" >> $GITHUB_ENV
244
265
245
266
- name : Run tests (with race detector)
246
267
if : matrix.test == 'race'
@@ -304,9 +325,16 @@ jobs:
304
325
if : matrix.test == 'coverage'
305
326
uses : codecov/codecov-action@v5
306
327
with :
307
- directory : ./coverage/codecov
328
+ files : ${{ env.COVERAGE_DIR }}/Cobertura.xml, ${{ env.COVERAGE_DIR }}/Cobertura_C.xml
308
329
token : ${{ secrets.CODECOV_TOKEN }}
309
330
331
+ - name : Upload coverage artifacts
332
+ if : matrix.test == 'coverage' && github.ref == 'refs/heads/main'
333
+ uses : actions/upload-artifact@v4
334
+ with :
335
+ name : coverage.zip
336
+ path : ${{ env.COVERAGE_DIR }}
337
+
310
338
- name : Upload test artifacts
311
339
if : always()
312
340
uses : actions/upload-artifact@v4
0 commit comments