Skip to content

Commit 8431755

Browse files
Parse coverage to Cobertura format and upload artifact
In order to submit our coverage to TiCS, we need them parsed in Cobertura format. Since we need to parse this for TiCS, let's reuse the assets and upload those Cobertura reports to Codecov as well.
1 parent 35bd83a commit 8431755

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

.github/workflows/qa.yaml

+34-6
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ jobs:
208208
echo AUTHD_TEST_ARTIFACTS_PATH="${artifacts_dir}" >> $GITHUB_ENV
209209
210210
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+
211225
- name: Run tests (with coverage collection)
212226
if: matrix.test == 'coverage'
213227
env:
@@ -217,9 +231,9 @@ jobs:
217231
218232
# The coverage is not written if the output directory does not exist, so we need to create it.
219233
cov_dir="$(pwd)/coverage"
220-
cod_cov_dir="$(pwd)/coverage/codecov"
234+
codecov_dir="$(pwd)/coverage/codecov"
221235
raw_cov_dir="${cov_dir}/raw"
222-
mkdir -p "${raw_cov_dir}" "${cod_cov_dir}"
236+
mkdir -p "${raw_cov_dir}" "${codecov_dir}"
223237
224238
# Print executed commands to ease debugging
225239
set -x
@@ -237,10 +251,17 @@ jobs:
237251
cat "${raw_cov_dir}/rust-cov/rust2go_coverage" >>"${cov_dir}/coverage.out"
238252
239253
# 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}"
241262
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
244265
245266
- name: Run tests (with race detector)
246267
if: matrix.test == 'race'
@@ -304,9 +325,16 @@ jobs:
304325
if: matrix.test == 'coverage'
305326
uses: codecov/codecov-action@v5
306327
with:
307-
directory: ./coverage/codecov
328+
files: ${{ env.COVERAGE_DIR }}/Cobertura.xml, ${{ env.COVERAGE_DIR }}/Cobertura_C.xml
308329
token: ${{ secrets.CODECOV_TOKEN }}
309330

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+
310338
- name: Upload test artifacts
311339
if: always()
312340
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)