Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

ci: compile raw coverage on source changes\n

ANISAYAK MITRAb0b50e6d5e5a
diff --git a/scripts/__tests__/coverage-runner-status.test.mjs b/scripts/__tests__/coverage-runner-status.test.mjs
index 631809a883..0564ddf997 100644
--- a/scripts/__tests__/coverage-runner-status.test.mjs
+++ b/scripts/__tests__/coverage-runner-status.test.mjs
@@ -245,3 +245,36 @@ test("required-features matching is exact, not substring — a superset name doe
assert.doesNotMatch(res.output, /RAN-THE-TARGET/, res.output);
assert.match(res.output, /rc=0/, res.output);
});
+
+test("source changes compile the aggregate raw coverage target", () => {
+ const res = withRunnerFunctions(
+ ["compile_raw_coverage_target"],
+ [
+ "PRODUCT_FEATURES='voice web3'",
+ "log() { printf '%s\\n' \"$*\"; }",
+ "bash() { printf 'BASH_ARGS'; printf ' <%s>' \"$@\"; printf '\\n'; }",
+ ].join("\n"),
+ "compile_raw_coverage_target",
+ );
+
+ assert.equal(res.status, 0, res.output);
+ assert.match(
+ res.output,
+ /BASH_ARGS <scripts\/ci-cancel-aware\.sh> <cargo> <test> <--features> <voice web3> <--test> <raw_coverage_all> <--no-run>/,
+ );
+});
+
+test("raw coverage compile failures fail the source-change guard", () => {
+ const res = withRunnerFunctions(
+ ["compile_raw_coverage_target"],
+ [
+ "PRODUCT_FEATURES='voice web3'",
+ "log() { :; }",
+ "bash() { return 17; }",
+ ].join("\n"),
+ "compile_raw_coverage_target && exit 1; rc=$?; echo \"rc=${rc}\"",
+ );
+
+ assert.equal(res.status, 0, res.output);
+ assert.match(res.output, /rc=17/);
+});
diff --git a/scripts/ci/rust-coverage-changed.sh b/scripts/ci/rust-coverage-changed.sh
index 402a3c752e..dd3658e033 100755
--- a/scripts/ci/rust-coverage-changed.sh
+++ b/scripts/ci/rust-coverage-changed.sh
@@ -218,6 +218,13 @@ run_integration_target() {
fi
}
+compile_raw_coverage_target() {
+ log "compiling raw coverage integration target for src/** change"
+ bash scripts/ci-cancel-aware.sh cargo test \
+ --features "${PRODUCT_FEATURES}" \
+ --test raw_coverage_all --no-run
+}
+
run_full() {
log "running FULL instrumented suite (reason: $1)"
llvm_cov clean --workspace
@@ -257,6 +264,8 @@ while IFS= read -r f; do
done < <(printf '%s\n' "${CHANGED_FILES}" | xargs -n1 printf '%s\n' 2>/dev/null || true)
log "received ${#files[@]} changed rust file(s)"
+src_changed=false
+
if [ "${#files[@]}" -eq 0 ]; then
run_full "empty changed-file list — scoping unsafe"
fi
@@ -267,6 +276,9 @@ fi
lib_filters_raw=""
test_targets_raw=""
for f in "${files[@]}"; do
+ case "${f}" in
+ src/*) src_changed=true ;;
+ esac
if [ ! -e "${f}" ]; then
# dorny/paths-filter includes deleted paths. They contain no changed lines
# to cover and, for tests, no longer correspond to runnable Cargo targets.
@@ -375,6 +387,13 @@ if [ "${#lib_filters[@]}" -eq 0 ] && [ "${#test_targets[@]}" -eq 0 ]; then
run_full "no scoped test targets derivable from the change set"
fi
+if [ "${src_changed}" = true ]; then
+ # Scoped lib tests cannot compile integration targets that are not selected by
+ # a domain mapping. Build the aggregate raw-coverage target on every src/**
+ # change so source-only PRs cannot leave a broken integration suite behind.
+ compile_raw_coverage_target
+fi
+
# Drop artifacts from previous coverage runs so merged profdata only reflects
# this run (build cache for dependencies is unaffected).
llvm_cov clean --workspace