Skip to content

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

fix(ci): preserve coverage reports when tests fail

Steven Enamakela4fe98cabebb
diff --git a/scripts/__tests__/self-hosted-lanes.test.mjs b/scripts/__tests__/self-hosted-lanes.test.mjs
index 917efbe80e..eff6deaef9 100644
--- a/scripts/__tests__/self-hosted-lanes.test.mjs
+++ b/scripts/__tests__/self-hosted-lanes.test.mjs
@@ -237,7 +237,7 @@ test("the complete suites run, not subsets", () => {
assert.match(runs, /bash scripts\/ci\/rust-coverage\.sh/);
assert.match(
runs,
- /cargo llvm-cov nextest .*--no-rustc-wrapper --manifest-path crates\/openhuman-app\/Cargo\.toml/,
+ /cargo llvm-cov nextest .*--manifest-path crates\/openhuman-app\/Cargo\.toml/,
);
});
@@ -408,7 +408,8 @@ test("private lanes reuse checkout targets, preserve mold through RUSTFLAGS rese
for (const lane of rust) {
assert.match(lane.targetDir, /^target\/ci-private-/);
assert.equal(lane.env.CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER, "/usr/local/bin/rust-mold-linker");
- assert.equal(lane.env.RUSTC_WRAPPER, "");
+ assert.equal(lane.env.RUSTC_WRAPPER, undefined);
+ assert.equal(lane.env.RUSTC_WORKSPACE_WRAPPER, undefined);
}
assert.notEqual(rust.find((l) => l.name === "rust-cov").targetDir, rust.find((l) => l.name === "rust-lint").targetDir);
assert.ok(buildPlan({ profile: "hosted", areas: ALL }).lanes.every((l) => !l.targetDir));
@@ -421,6 +422,8 @@ test("private gates-off, storage, and Tauri execute equivalent coverage suites w
assert.match(c.run, /cargo llvm-cov nextest/);
assert.match(c.run, /--no-tests=fail/);
assert.match(c.run, /--lcov --output-path ci-out\/lcov\//);
+ assert.match(c.run, /--no-report .*\|\| rc=\$\?; cargo llvm-cov report/);
+ assert.match(c.run, /exit "\$rc"$/);
}
}
const checks = Object.fromEntries(plan.lanes.flatMap((l) => l.checks.map((c) => [c.name, c])));
diff --git a/scripts/ci/self-hosted/lanes-plan.mjs b/scripts/ci/self-hosted/lanes-plan.mjs
index 8d69b45d6a..abe12f9d38 100644
--- a/scripts/ci/self-hosted/lanes-plan.mjs
+++ b/scripts/ci/self-hosted/lanes-plan.mjs
@@ -141,8 +141,6 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
: null;
const rustEnv = ex63 ? {
CARGO_INCREMENTAL: "0",
- RUSTC_WRAPPER: "",
- RUSTC_WORKSPACE_WRAPPER: "",
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: "/usr/local/bin/rust-mold-linker",
} : {
CARGO_INCREMENTAL: "0",
@@ -588,6 +586,9 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
// filters; union those filters in nextest's expression syntax. --no-clean
// retains prior instrumentation, while every suite writes its own report.
if (ex63) {
+ const coverageSuite = (args, output, manifest = "Cargo.toml") =>
+ `rc=0; cargo llvm-cov nextest --profile ci --no-fail-fast --no-tests=fail --no-clean --no-report ${args} || rc=$?; ` +
+ `cargo llvm-cov report --manifest-path ${manifest} --lcov --output-path ci-out/lcov/${output} || { report_rc=$?; if [ "$rc" -eq 0 ]; then rc=$report_rc; fi; }; exit "$rc"`;
for (const lane of lanes) {
if (!["rust-gates-off", "storage-drivers"].includes(lane.name)) continue;
for (const check of lane.checks) {
@@ -609,12 +610,12 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
expression = ` -E '${terms ? `(${terms})` : "all()"}${exclude.map((f) => ` & not test(${f})`).join("")}'`;
}
check.env = { ...covEnv, CARGO_BUILD_TARGET_DIR: "target/ci-private-coverage" };
- check.run = `cargo llvm-cov nextest --profile ci --no-fail-fast --no-tests=fail --no-clean ${args}${expression}${serial} --lcov --output-path ci-out/lcov/lcov-${check.name}.info`;
+ check.run = coverageSuite(`${args}${expression}${serial}`, `lcov-${check.name}.info`);
}
}
const tauri = lanes.find((l) => l.name === "tauri").checks.find((c) => c.name === "tauri-coverage");
tauri.env = { ...covEnv, CARGO_BUILD_TARGET_DIR: "target/ci-private-coverage" };
- tauri.run = "unset RUSTFLAGS RUSTC_WRAPPER && cargo llvm-cov nextest --profile ci --no-fail-fast --no-tests=fail --no-clean --no-rustc-wrapper --manifest-path crates/openhuman-app/Cargo.toml --lcov --output-path ci-out/lcov/lcov-tauri.info";
+ tauri.run = "unset RUSTFLAGS; " + coverageSuite("--manifest-path crates/openhuman-app/Cargo.toml", "lcov-tauri.info", "crates/openhuman-app/Cargo.toml");
}
for (const lane of lanes) {