Skip to content

Commit 9ec7a67

Browse files
authored
Fix coverage collection with Bazel BWOB (#2182)
Summary: Coverage runs were using remote_download_output=all because thing didn't work with Bazel Build Without the Bytes. It seems that after bazelbuild/bazel#4685 this should work, so this change attempts to shift coverage runs to use BWOB to avoid downloading all outputs. This also fixes some warnings and errors we ran into with the ubuntu 24.04 upgrade which causes lcov 2 to be installed. Relevant Issues: N/A Type of change: /kind bug Test Plan: Will check github actions on this PR. Signed-off-by: Vihang Mehta <vihang@px.dev>
1 parent 117d727 commit 9ec7a67

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ build --remote_download_minimal
2020
test --remote_download_minimal
2121
run --remote_download_outputs=all
2222
coverage --build_runfile_links
23+
coverage --nocache_test_results
2324

2425
# Needed by rules_meta.
2526
# Follow https://github.com/fmeum/rules_meta/issues/1#issuecomment-1255828109
@@ -269,3 +270,4 @@ build:remote --build_metadata=VISIBILITY=PUBLIC
269270
coverage:remote --strategy=CoverageReport=local,remote
270271
coverage:remote --experimental_fetch_all_coverage_outputs
271272
coverage:remote --experimental_split_coverage_postprocessing
273+
coverage:remote --experimental_remote_download_regex=.*/(coverage.dat$|_coverage/_coverage_report.dat$)

ci/collect_coverage.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ check_config
138138
# Print config parameters.
139139
print_config
140140

141-
lcov_opts=(--rc lcov_branch_coverage=1)
141+
# TODO: Try to track down the negative coverage issue.
142+
lcov_opts=(--rc branch_coverage=1 --ignore-errors negative)
142143

143144
cd $(bazel info workspace)
144145

145146
# Get coverage from bazel targets.
146-
bazel coverage --remote_download_outputs=all --combined_report=lcov //src/...
147+
bazel coverage --combined_report=lcov //src/...
147148

148149
# Copy the output file
149150
cp --no-preserve=mode "$(bazel info output_path)/_coverage/_coverage_report.dat" ${COVERAGE_FILE}
@@ -153,13 +154,11 @@ lcov "${lcov_opts[@]}" --summary ${COVERAGE_FILE}
153154

154155
# Remove test files from the coverage files.
155156
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_test.cc' -o ${COVERAGE_FILE}
156-
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_mock.cc' -o ${COVERAGE_FILE}
157157
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_mock.h' -o ${COVERAGE_FILE}
158158
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_test.go' -o ${COVERAGE_FILE}
159159
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*.gen.go' -o ${COVERAGE_FILE}
160160
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*-mock.tsx' -o ${COVERAGE_FILE}
161161
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*-mock.ts' -o ${COVERAGE_FILE}
162-
lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} 'src/ui/src/types/generated/**' -o ${COVERAGE_FILE}
163162

164163
# Print out the final summary.
165164
lcov "${lcov_opts[@]}" --summary ${COVERAGE_FILE}

0 commit comments

Comments
 (0)