Skip to content

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

feat(self-hosted): enable sccache for instrumented coverage on ex63

Steven Enamakel819268d0bc10
diff --git a/scripts/__tests__/self-hosted-lanes.test.mjs b/scripts/__tests__/self-hosted-lanes.test.mjs
index fb55843288..3d84214151 100644
--- a/scripts/__tests__/self-hosted-lanes.test.mjs
+++ b/scripts/__tests__/self-hosted-lanes.test.mjs
@@ -186,17 +186,45 @@ test("ex63 needs a scratch dir and gives every Rust lane its own target dir unde
);
});
-test("instrumented coverage never runs under a rustc wrapper", () => {
+test("instrumented coverage uses sccache on ex63 and no wrapper on hosted", () => {
for (const plan of plans()) {
+ const ex63 = plan.profile === "ex63";
const cov = plan.lanes.find((l) => l.name === "rust-cov");
- assert.equal(cov.env.RUSTC_WRAPPER, undefined);
+ assert.equal(cov.env.RUSTC_WRAPPER, ex63 ? "sccache" : undefined);
const tauriCov = plan.lanes
.find((l) => l.name === "tauri")
.checks.find((c) => c.name === "tauri-coverage");
- assert.match(tauriCov.run, /^unset RUSTFLAGS RUSTC_WRAPPER/);
+ assert.equal(tauriCov.env.RUSTC_WRAPPER, ex63 ? "sccache" : undefined);
+ // The linker flag always goes: llvm-cov sets RUSTFLAGS itself.
+ assert.match(
+ tauriCov.run,
+ ex63 ? /^unset RUSTFLAGS &&/ : /^unset RUSTFLAGS RUSTC_WRAPPER &&/,
+ );
+ assert.match(tauriCov.run, /--no-rustc-wrapper/);
}
});
+test("sccache summary reports hit rate and the store in use", () => {
+ assert.equal(sccacheSummary(null), null);
+ assert.equal(
+ sccacheSummary({
+ stats: {
+ cache_hits: { counts: { Rust: 30 } },
+ cache_misses: { counts: { Rust: 10 } },
+ },
+ cache_location: "webdav, name: , prefix: /",
+ }),
+ "sccache (shared store): 30 Rust hits, 10 misses (75%).",
+ );
+ assert.equal(
+ sccacheSummary({
+ stats: { cache_hits: { counts: {} }, cache_misses: { counts: {} } },
+ cache_location: "Local disk: \"/cache/sccache\"",
+ }),
+ "sccache (slot disk): 0 Rust hits, 0 misses.",
+ );
+});
+
test("area flags are read strictly from CI_AREA_*", () => {
const areas = areasFromEnv({
CI_AREA_RUST_CORE: "true",
diff --git a/scripts/ci/self-hosted/lanes-plan.mjs b/scripts/ci/self-hosted/lanes-plan.mjs
index 3a7fccf84a..af66509095 100644
--- a/scripts/ci/self-hosted/lanes-plan.mjs
+++ b/scripts/ci/self-hosted/lanes-plan.mjs
@@ -85,7 +85,10 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
const core = areas.rustCore;
// ex63: one throwaway target dir per lane so lanes never queue on cargo's
- // build-dir lock; sccache (on the capped /cache disk) warms the deps.
+ // build-dir lock; sccache warms the build from the host's shared, capped
+ // store (or the slot's /cache disk when the store is down). sccache keys
+ // include the target dir, so a lane shares with the same lane of every
+ // earlier job on any VM, not with the other lanes.
// hosted: cargo's default target dirs, which Swatinem/rust-cache restores.
const targetDir = (lane) => (ex63 ? `${scratch}/target/${lane}` : null);
const sccache = ex63 ? { RUSTC_WRAPPER: "sccache" } : {};
@@ -93,14 +96,17 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
CARGO_INCREMENTAL: "0",
RUSTFLAGS: "-C link-arg=-fuse-ld=mold",
};
- // Instrumented builds: no sccache (cargo-llvm-cov owns the wrapper and
- // RUSTFLAGS, exactly as in ci-lite), no DWARF, a large test stack, and on
- // hosted the serialized build ci-lite needs to fit the runner's disk.
+ // Instrumented builds: no DWARF, a large test stack, and on hosted the
+ // serialized build ci-lite needs to fit the runner's disk. On ex63 they go
+ // through sccache too: cargo-llvm-cov chains an existing RUSTC_WRAPPER in
+ // both its wrapper and RUSTFLAGS modes, and cache hits give byte-identical
+ // lcov (checked with cargo-llvm-cov 0.8 and sccache 0.10). Hosted keeps
+ // ci-lite's wrapper-free setup.
const covEnv = {
...rustEnv,
CARGO_PROFILE_DEV_DEBUG: "0",
RUST_MIN_STACK: "67108864",
- ...(ex63 ? {} : { CARGO_BUILD_JOBS: "1" }),
+ ...(ex63 ? sccache : { CARGO_BUILD_JOBS: "1" }),
};
const modulesDir = ex63
? `${scratch}/test-modules`
@@ -402,13 +408,14 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
run: "cargo clippy --manifest-path crates/openhuman-app/Cargo.toml -- -D warnings",
},
{
- // llvm-cov's RUSTFLAGS mode, with the linker flag cleared, exactly as
- // ci-lite: a rustc wrapper would silently drop .profraw output.
+ // llvm-cov's RUSTFLAGS mode with the linker flag cleared, as in
+ // ci-lite. ci-lite also clears RUSTC_WRAPPER because its container
+ // config installs sccache; on ex63 covEnv sets sccache on purpose.
name: "tauri-coverage",
when: areas.rustTauri,
env: { ...covEnv },
run:
- "unset RUSTFLAGS RUSTC_WRAPPER" +
+ (ex63 ? "unset RUSTFLAGS" : "unset RUSTFLAGS RUSTC_WRAPPER") +
" && cargo llvm-cov clean --manifest-path crates/openhuman-app/Cargo.toml" +
" && cargo llvm-cov --no-rustc-wrapper --manifest-path crates/openhuman-app/Cargo.toml" +
" --lcov --output-path ci-out/lcov/lcov-tauri.info",
diff --git a/scripts/ci/self-hosted/lanes.mjs b/scripts/ci/self-hosted/lanes.mjs
index cde17e99d1..c200f9990e 100644
--- a/scripts/ci/self-hosted/lanes.mjs
+++ b/scripts/ci/self-hosted/lanes.mjs
@@ -125,6 +125,20 @@ export function orderProblems(plan) {
return problems;
}
+/** One line on sccache's Rust hit rate and where its cache lives, or null. */
+export function sccacheSummary(sccache) {
+ const stats = sccache?.stats;
+ if (!stats) return null;
+ const hits = stats.cache_hits?.counts?.Rust ?? 0;
+ const misses = stats.cache_misses?.counts?.Rust ?? 0;
+ const total = hits + misses;
+ const rate = total ? ` (${Math.round((100 * hits) / total)}%)` : "";
+ const where = /webdav/i.test(sccache.cache_location ?? "")
+ ? "shared store"
+ : "slot disk";
+ return `sccache (${where}): ${hits} Rust hits, ${misses} misses${rate}.`;
+}
+
/** Render the per-check outcome table for $GITHUB_STEP_SUMMARY. */
export function renderSummary(results) {
const rows = [
@@ -155,6 +169,8 @@ export function renderSummary(results) {
"",
`VM memory: ${(mem.totalMiB / 1024).toFixed(1)} GiB, lowest available ${mem.minAvailableMiB == null ? "?" : `${(mem.minAvailableMiB / 1024).toFixed(1)} GiB`}; heavy-compile slots: ${results.heavySlots ?? "uncapped"}.`,
);
+ const sc = sccacheSummary(results.sccache);
+ if (sc) rows.push("", sc);
rows.push(
"",
"`skipped` = area untouched; `blocked` = a check it needs did not succeed. Neither is a pass for the check itself.",