Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
ci(test): cut the Deno step from minutes to seconds by reusing the test build (#9720)
teo9fc4ed7e5ac1
diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.ymlindex 2116aee545..7aab83fdc1 100644--- a/.github/workflows/code_check_cloud_storage.yml+++ b/.github/workflows/code_check_cloud_storage.yml@@ -154,6 +154,11 @@ jobs:esacdone < "$env_file"cat "$env_file" >> "$GITHUB_ENV"+ # The server checks the WebDAV backend before it reports ready, and the+ # client's default 10s wait can run out. This limit has no env var.+ sccache_conf="$RUNNER_TEMP/sccache.toml"+ echo 'server_startup_timeout_ms = 60000' > "$sccache_conf"+ echo "SCCACHE_CONF=$sccache_conf" >> "$GITHUB_ENV"# Force the next compiler invocation to start a server with the new remote# backend even if a setup hook happened to launch one already.sccache --stop-server >/dev/null 2>&1 || true@@ -828,9 +833,21 @@ jobs:# line numbers in our own code.common=(--config 'profile.dev.package."*".debug=false'- --all-features --no-tests=pass --test-threads "$NEXTEST_TEST_THREADS"+ --all-features --no-tests=pass)+ # The Deno tests are ignored by default because they need the pinned runtime. They+ # run from this same script so cargo sees identical flags and selection and reuses+ # what the first run compiled. Only tests in packages this PR selected can match.+ if [ "${NEXTEST_RUN_DENO_TESTS:-}" = "true" ]; then+ common+=(+ --run-ignored only --test-threads 2+ -E 'package(code_execution) or (package(agent_harness_service) and test(authenticated_mcp_runs_javascript_and_persists_source_and_result))'+ )+ else+ common+=(--test-threads "$NEXTEST_TEST_THREADS")+ fi+if [ "$RUST_PACKAGES" = "all" ]; thencargo nextest run --workspace --exclude sync_service --lib --bins --tests "${common[@]}"exit 0@@ -854,9 +871,62 @@ jobs:deno-version: '2.9.6'- name: Test Deno sandbox and authenticated SDK executionif: env.RUST_PACKAGES == 'all' || contains(env.RUST_PACKAGES, 'code_execution') || contains(env.RUST_PACKAGES, 'agent_code_mode') || contains(env.RUST_PACKAGES, 'agent_harness_service')- run: |-- cargo test --locked -p code_execution -- --ignored --test-threads=2- cargo test --locked -p agent_harness_service authenticated_mcp_runs_javascript_and_persists_source_and_result -- --ignored+ run: |+ set -euo pipefail++ # --no-tests=pass: a package filter can legitimately select a crate with no+ # tests; treat that as success, not nextest's default error.+ # sync-service is not part of this suite, and its storage backends are mutually+ # exclusive under --all-features.+ #+ # Package selection uses `cargo nextest run -p`, not `--workspace -E rdeps(...)`.+ # The filterset only decides which tests *run* after a workspace build; `-p`+ # is what keeps an unrelated crate's test binary from being compiled.+ #+ # `--lib --bins --tests` is safe with `--workspace` (cargo skips packages that+ # lack a given target type) but fails with `-p` when any selected package has+ # no lib — xtask binaries such as xtask_nextest_filter / xtask_workflows.+ # Unconstrained `-p` still runs that package's tests.++ : "${RUST_PACKAGES:?RUST_PACKAGES is required}"+ # 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+ )++ # The Deno tests are ignored by default because they need the pinned runtime. They+ # run from this same script so cargo sees identical flags and selection and reuses+ # what the first run compiled. Only tests in packages this PR selected can match.+ if [ "${NEXTEST_RUN_DENO_TESTS:-}" = "true" ]; then+ common+=(+ --run-ignored only --test-threads 2+ -E 'package(code_execution) or (package(agent_harness_service) and test(authenticated_mcp_runs_javascript_and_persists_source_and_result))'+ )+ else+ common+=(--test-threads "$NEXTEST_TEST_THREADS")+ fi++ if [ "$RUST_PACKAGES" = "all" ]; then+ cargo nextest run --workspace --exclude sync_service --lib --bins --tests "${common[@]}"+ exit 0+ fi++ pkg_args=()+ for package in $RUST_PACKAGES; do+ [ "$package" = "sync_service" ] || pkg_args+=(-p "$package")+ done++ if [ "${#pkg_args[@]}" -eq 0 ]; then+ echo "No packages in the test suite were affected"+ exit 0+ fi++ cargo nextest run "${common[@]}" "${pkg_args[@]}"+ env:+ NEXTEST_RUN_DENO_TESTS: 'true'- name: show sccache statsif: always()run: sccache --show-stats || truediff --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.rsindex 41c53d30f0..4cdb3cbf8a 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@@ -220,7 +220,8 @@ fn setup_execution_runtime() -> Step<gh_workflow::Use> {/// Exercise the real permission boundary and authenticated SDK execution in CI.fn test_execution_runtime() -> Step<Run> {Step::new("Test Deno sandbox and authenticated SDK execution")- .run("cargo test --locked -p code_execution -- --ignored --test-threads=2\ncargo test --locked -p agent_harness_service authenticated_mcp_runs_javascript_and_persists_source_and_result -- --ignored")+ .run(include_str!("scripts/run_tests.sh"))+ .add_env(("NEXTEST_RUN_DENO_TESTS", "true")).if_condition(Expression::new("env.RUST_PACKAGES == 'all' || contains(env.RUST_PACKAGES, 'code_execution') || contains(env.RUST_PACKAGES, 'agent_code_mode') || contains(env.RUST_PACKAGES, 'agent_harness_service')",))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.rsindex a15f676963..40c2fbbefd 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@@ -284,6 +284,16 @@ fn schema_changes_run_the_compatibility_check() {assert!(job.contains("graphql-schema-compat --base HEAD^1"), "{job}");}+/// Plain `cargo test` here rebuilt hundreds of crates under different flags to run+/// about four seconds of tests.+#[test]+fn deno_tests_reuse_the_test_run_build() {+ let deno_step = serde_json::to_value(test_execution_runtime()).unwrap();+ let test_step = serde_json::to_value(run_tests()).unwrap();+ assert_eq!(deno_step["run"], test_step["run"]);+ assert_eq!(deno_step["env"]["NEXTEST_RUN_DENO_TESTS"], "true");+}+/// Per-test database creation is the bulk of the test run's time, and the/// settings `configure_postgres` applies only survive its restart on a bind mount.#[test]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.shindex cf449df8a4..6b4a3625b6 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@@ -20,9 +20,21 @@ set -euo pipefail# line numbers in our own code.common=(--config 'profile.dev.package."*".debug=false'- --all-features --no-tests=pass --test-threads "$NEXTEST_TEST_THREADS"+ --all-features --no-tests=pass)+# The Deno tests are ignored by default because they need the pinned runtime. They+# run from this same script so cargo sees identical flags and selection and reuses+# what the first run compiled. Only tests in packages this PR selected can match.+if [ "${NEXTEST_RUN_DENO_TESTS:-}" = "true" ]; then+ common+=(+ --run-ignored only --test-threads 2+ -E 'package(code_execution) or (package(agent_harness_service) and test(authenticated_mcp_runs_javascript_and_persists_source_and_result))'+ )+else+ common+=(--test-threads "$NEXTEST_TEST_THREADS")+fi+if [ "$RUST_PACKAGES" = "all" ]; thencargo nextest run --workspace --exclude sync_service --lib --bins --tests "${common[@]}"exit 0