Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

ci: faster Rust test builds (no dependency debuginfo, sccache stays up) (#7354)

Wolf Mermelstein538a33c7cb6a
diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.yml
index a2f6361cd6..4834e6b750 100644
--- a/.github/workflows/code_check_cloud_storage.yml
+++ b/.github/workflows/code_check_cloud_storage.yml
@@ -315,6 +315,7 @@ jobs:
RUST_PACKAGES: ${{ needs.path-check.outputs.rust_packages }}
NEXTEST_TEST_THREADS: '32'
RUSTFLAGS: '-Dwarnings -C link-arg=-fuse-ld=mold'
+ SCCACHE_IDLE_TIMEOUT: '0'
services:
postgres:
image: pgvector/pgvector:pg18
@@ -374,6 +375,8 @@ jobs:
else
echo "::warning::Namespace remote sccache setup failed; using local cache fallback"
fi
+ - name: Start sccache server
+ run: sccache --start-server
- name: configure postgres for concurrent tests
run: |
postgres_container="$(docker ps --format '{{.ID}} {{.Image}}' | awk '$2 == "pgvector/pgvector:pg18" { print $1; exit }')"
@@ -417,7 +420,13 @@ jobs:
# Unconstrained `-p` still runs that package's tests.
: "${RUST_PACKAGES:?RUST_PACKAGES is required}"
- common=(--all-features --no-tests=pass --test-threads "$NEXTEST_TEST_THREADS")
+ # Dependencies build without debug info, which cuts compile, link and disk cost.
+ # Workspace crates keep CARGO_PROFILE_*_DEBUG=limited, so backtraces still carry
+ # line numbers in our own code.
+ common=(
+ --config 'profile.dev.package."*".debug=false'
+ --all-features --no-tests=pass --test-threads "$NEXTEST_TEST_THREADS"
+ )
if [ "$RUST_PACKAGES" = "all" ]; then
cargo nextest run --workspace --exclude sync_service --lib --bins --tests "${common[@]}"
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
index 1192e620b8..3a6ba50ad1 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
@@ -102,6 +102,9 @@ fn test() -> Job {
))
.add_env(("NEXTEST_TEST_THREADS", vars::NEXTEST_TEST_THREADS))
.add_env(("RUSTFLAGS", "-Dwarnings -C link-arg=-fuse-ld=mold"))
+ // The default 10-minute idle timeout can stop the server during long
+ // link or test phases, which resets the stats reported at the end.
+ .add_env(("SCCACHE_IDLE_TIMEOUT", "0"))
.add_service("postgres", postgres_service())
.add_service("redis", redis_service())
.add_step(steps::checkout(false, false))
@@ -109,6 +112,7 @@ fn test() -> Job {
.add_step(steps::setup_nix())
.add_step(steps::setup_dev_shell())
.add_step(steps::configure_namespace_sccache(vars::CI_SCCACHE_NAME))
+ .add_step(steps::start_sccache_server())
.add_step(configure_postgres())
.add_step(prepare_tests())
.add_step(run_tests())
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs
index d01445ed0b..9adc05b093 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs
@@ -72,3 +72,37 @@ fn test_job_honors_skip_tests() {
"path-check must export skip_tests: {yaml}"
);
}
+
+#[test]
+fn tests_build_dependencies_without_debug_info() {
+ let script = include_str!("../scripts/run_tests.sh");
+ assert!(
+ script.contains(r#"--config 'profile.dev.package."*".debug=false'"#),
+ "the test build must drop dependency debug info: {script}"
+ );
+}
+
+#[test]
+fn test_job_keeps_one_sccache_server_for_the_whole_run() {
+ let job = serde_json::to_value(test()).unwrap();
+ assert_eq!(job["env"]["SCCACHE_IDLE_TIMEOUT"], "0");
+ let step_names: Vec<&str> = job["steps"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .filter_map(|step| step["name"].as_str())
+ .collect();
+ let start = step_names
+ .iter()
+ .position(|name| *name == "Start sccache server")
+ .expect("test job must start the sccache server explicitly");
+ let configure = step_names
+ .iter()
+ .position(|name| *name == "Configure Namespace remote sccache")
+ .unwrap();
+ let run = step_names
+ .iter()
+ .position(|name| *name == "run tests")
+ .unwrap();
+ assert!(configure < start && start < run, "{step_names:?}");
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/run_tests.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/run_tests.sh
index 02702d1a24..cf449df8a4 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/run_tests.sh
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/run_tests.sh
@@ -15,7 +15,13 @@ set -euo pipefail
# Unconstrained `-p` still runs that package's tests.
: "${RUST_PACKAGES:?RUST_PACKAGES is required}"
-common=(--all-features --no-tests=pass --test-threads "$NEXTEST_TEST_THREADS")
+# Dependencies build without debug info, which cuts compile, link and disk cost.
+# Workspace crates keep CARGO_PROFILE_*_DEBUG=limited, so backtraces still carry
+# line numbers in our own code.
+common=(
+ --config 'profile.dev.package."*".debug=false'
+ --all-features --no-tests=pass --test-threads "$NEXTEST_TEST_THREADS"
+)
if [ "$RUST_PACKAGES" = "all" ]; then
cargo nextest run --workspace --exclude sync_service --lib --bins --tests "${common[@]}"