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.

chore(ci): cache and parallelize web wasm builds (#6407)

Wolf Mermelsteinc6e1172fb118
diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml
index 9cb651a2d2..98974ef1b6 100644
--- a/.github/workflows/deploy_preview.yml
+++ b/.github/workflows/deploy_preview.yml
@@ -13,6 +13,8 @@ env:
- bun.lock
- apps/web/**
- packages/**
+ - crates/agent_fold/**
+ - crates/agent_runtime_protocol/**
- crates/client/cache-core/**
- crates/client/cache-turso/**
- crates/client/cache-wasm/**
@@ -34,18 +36,55 @@ jobs:
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
with:
cache: nix
- path: /home/runner/.bun/install/cache
+ path: |-
+ /home/runner/.bun/install/cache
+ /home/runner/.cargo/registry
+ /home/runner/.cargo/git
+ /home/runner/.cache/.wasm-pack
continue-on-error: true
- name: Setup Nix
uses: './.github/actions/setup-nix'
- name: Setup
uses: './.github/actions/setup-reqs-web'
+ - name: Configure Namespace remote sccache
+ if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.event.pull_request.head.repo.full_name == github.repository
+ run: |-
+ set -euo pipefail
+ env_file="$(mktemp "$RUNNER_TEMP/namespace-sccache.XXXXXX")"
+ trap 'rm -f "$env_file"' EXIT
+ if nsc cache sccache setup --cache_name web-ci > "$env_file"; then
+ # Register credential values as masked BEFORE exporting: GitHub only
+ # masks `secrets.*`, so without this SCCACHE_WEBDAV_TOKEN — a broad,
+ # ~24h Namespace workspace token (registry + cache write) — printed
+ # verbatim in every subsequent step's env dump. Masking is selective by
+ # key name: masking non-secrets like the endpoint URL or key prefix
+ # would redact those strings everywhere in the logs.
+ while IFS= read -r line; do
+ k="${line%%=*}"
+ v="${line#*=}"
+ [ -n "$v" ] && [ "$k" != "$line" ] || continue
+ case "$k" in
+ *TOKEN*|*SECRET*|*PASSWORD*) echo "::add-mask::$v" ;;
+ esac
+ done < "$env_file"
+ cat "$env_file" >> "$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
+ else
+ echo "::warning::Namespace remote sccache setup failed; using local cache fallback"
+ fi
+ - name: Start sccache server
+ run: sccache --start-server
- name: Build
run: just build-dev
env:
VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}
VITE_POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
working-directory: apps/web
+ - name: show sccache stats
+ if: always()
+ run: sccache --show-stats || true
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b
with:
diff --git a/.github/workflows/deploy_web_app.yml b/.github/workflows/deploy_web_app.yml
index 19c99d5710..cff025b314 100644
--- a/.github/workflows/deploy_web_app.yml
+++ b/.github/workflows/deploy_web_app.yml
@@ -53,12 +53,46 @@ jobs:
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
with:
cache: nix
- path: /home/runner/.bun/install/cache
+ path: |-
+ /home/runner/.bun/install/cache
+ /home/runner/.cargo/registry
+ /home/runner/.cargo/git
+ /home/runner/.cache/.wasm-pack
continue-on-error: true
- name: Setup Nix
uses: ./.github/actions/setup-nix
- name: Setup
uses: ./.github/actions/setup-reqs-web
+ - name: Configure Namespace remote sccache
+ if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.event.pull_request.head.repo.full_name == github.repository
+ run: |-
+ set -euo pipefail
+ env_file="$(mktemp "$RUNNER_TEMP/namespace-sccache.XXXXXX")"
+ trap 'rm -f "$env_file"' EXIT
+ if nsc cache sccache setup --cache_name web-ci > "$env_file"; then
+ # Register credential values as masked BEFORE exporting: GitHub only
+ # masks `secrets.*`, so without this SCCACHE_WEBDAV_TOKEN — a broad,
+ # ~24h Namespace workspace token (registry + cache write) — printed
+ # verbatim in every subsequent step's env dump. Masking is selective by
+ # key name: masking non-secrets like the endpoint URL or key prefix
+ # would redact those strings everywhere in the logs.
+ while IFS= read -r line; do
+ k="${line%%=*}"
+ v="${line#*=}"
+ [ -n "$v" ] && [ "$k" != "$line" ] || continue
+ case "$k" in
+ *TOKEN*|*SECRET*|*PASSWORD*) echo "::add-mask::$v" ;;
+ esac
+ done < "$env_file"
+ cat "$env_file" >> "$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
+ else
+ echo "::warning::Namespace remote sccache setup failed; using local cache fallback"
+ fi
+ - name: Start sccache server
+ run: sccache --start-server
- name: Build
run: just build-${{ inputs.environment }}
env:
@@ -67,6 +101,9 @@ jobs:
VITE_OTEL_EXPORTER_URL: ${{ inputs.environment == 'prod' && 'https://macro-prox-prod.macroverse.workers.dev/i/otlp/v1/traces' || 'https://macro-prox-dev.macroverse.workers.dev/i/otlp/v1/traces' }}
VITE_OTEL_ENV: ${{ inputs.environment == 'prod' && 'prod' || 'development' }}
working-directory: apps/web
+ - name: show sccache stats
+ if: always()
+ run: sccache --show-stats || true
- name: Install infra dependencies
run: bun install
working-directory: infra
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.yml
index 2c404658aa..c6bc44354b 100644
--- a/.github/workflows/web-app-check-main.yml
+++ b/.github/workflows/web-app-check-main.yml
@@ -29,6 +29,8 @@ jobs:
- 'bun.lock'
- 'apps/web/**'
- 'packages/**'
+ - 'crates/agent_fold/**'
+ - 'crates/agent_runtime_protocol/**'
- 'crates/client/cache-core/**'
- 'crates/client/cache-turso/**'
- 'crates/client/cache-wasm/**'
@@ -219,15 +221,52 @@ jobs:
uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
with:
cache: nix
- path: /home/runner/.bun/install/cache
+ path: |-
+ /home/runner/.bun/install/cache
+ /home/runner/.cargo/registry
+ /home/runner/.cargo/git
+ /home/runner/.cache/.wasm-pack
continue-on-error: true
- name: Setup Nix
uses: './.github/actions/setup-nix'
- name: Setup
uses: './.github/actions/setup-reqs-web'
+ - name: Configure Namespace remote sccache
+ if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.event.pull_request.head.repo.full_name == github.repository
+ run: |-
+ set -euo pipefail
+ env_file="$(mktemp "$RUNNER_TEMP/namespace-sccache.XXXXXX")"
+ trap 'rm -f "$env_file"' EXIT
+ if nsc cache sccache setup --cache_name web-ci > "$env_file"; then
+ # Register credential values as masked BEFORE exporting: GitHub only
+ # masks `secrets.*`, so without this SCCACHE_WEBDAV_TOKEN — a broad,
+ # ~24h Namespace workspace token (registry + cache write) — printed
+ # verbatim in every subsequent step's env dump. Masking is selective by
+ # key name: masking non-secrets like the endpoint URL or key prefix
+ # would redact those strings everywhere in the logs.
+ while IFS= read -r line; do
+ k="${line%%=*}"
+ v="${line#*=}"
+ [ -n "$v" ] && [ "$k" != "$line" ] || continue
+ case "$k" in
+ *TOKEN*|*SECRET*|*PASSWORD*) echo "::add-mask::$v" ;;
+ esac
+ done < "$env_file"
+ cat "$env_file" >> "$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
+ else
+ echo "::warning::Namespace remote sccache setup failed; using local cache fallback"
+ fi
+ - name: Start sccache server
+ run: sccache --start-server
- name: Build
run: just build-dev
working-directory: apps/web
+ - name: show sccache stats
+ if: always()
+ run: sccache --show-stats || true
- name: Teardown Nix
if: always()
uses: './.github/actions/teardown-nix'
diff --git a/apps/web/justfile b/apps/web/justfile
index 83ab2396ce..171b0f3f8f 100644
--- a/apps/web/justfile
+++ b/apps/web/justfile
@@ -66,25 +66,36 @@ local-email: ensure-cache-wasm
# without it the cache worker's dynamic import 404s at runtime and the
# normalized cache silently degrades to network-only.
#
+# The two wasm-pack crates do not share artifacts. Build them in parallel
+# with distinct CARGO_TARGET_DIR values so they do not serialize on the
+# workspace cargo lock. CI still always rebuilds (schema/engine changes can
+# alter wasm without a version bump); Namespace `web-ci` sccache makes the
+# rustc invocations cheap across deploys.
+#
# Vite's chunk-rendering can exceed 6GB as the app grows. Leave headroom
# above that peak; CI builds use the same mid-size runner as preview deploys.
node_heap := "--max-old-space-size=8192"
+cache_wasm_target := justfile_directory() / "../../target/cache-wasm"
+agent_fold_wasm_target := justfile_directory() / "../../target/agent-fold-wasm"
+
+[parallel]
+build-wasm: build-cache-wasm build-agent-fold-wasm
-build-dev: build-cache-wasm build-agent-fold-wasm
+build-dev: build-wasm
MODE=development NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
-build-staging: build-cache-wasm build-agent-fold-wasm
+build-staging: build-wasm
MODE=staging NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
-build-prod: build-cache-wasm build-agent-fold-wasm
+build-prod: build-wasm
MODE=production NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
# Tauri build hook (run automatically via beforeBuildCommand) — not meant to be run directly
[private]
-build-tauri: build-cache-wasm build-agent-fold-wasm
+build-tauri: build-wasm
printf production > tauri/src-tauri/.macro-tauri-env
MODE=production NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
@@ -171,7 +182,7 @@ cycles-ci:
# (gitignored). Unconditional — CI app builds must never skip it (schema or
# engine changes alter the wasm without a cache-wasm version bump).
build-cache-wasm:
- wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm --target web --release --out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm
+ CARGO_TARGET_DIR="{{cache_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm --target web --release --out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm
# Build the production browser harness served by Vite preview.
build-cache-wasm-browser-production: build-cache-wasm build-cache-wasm-browser-test-hooks
@@ -182,7 +193,7 @@ build-cache-wasm-browser-production: build-cache-wasm build-cache-wasm-browser-t
# Its distinct name keeps it outside the one-production-cache-WASM deploy gate.
[private]
build-cache-wasm-browser-test-hooks:
- wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm \
+ CARGO_TARGET_DIR="{{cache_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm \
--target web --release \
--out-name cache_wasm_browser_test_hooks \
--out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm-browser-test \
@@ -199,13 +210,13 @@ test-cache-wasm-browser:
# This overwrites the gitignored release wasm package and is intentionally not
# used by application or CI builds.
build-cache-wasm-profile:
- wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm --target web --profile cache-wasm-profiling --out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm
+ CARGO_TARGET_DIR="{{cache_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm --target web --profile cache-wasm-profiling --out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm
# Build the agent-fold wasm module into src/lib/core/agent-fold/wasm
# (gitignored). `--no-default-features` drops the crate's `cli` feature, whose
# tokio/clap do not build for wasm32; the fold itself needs neither.
build-agent-fold-wasm:
- wasm-pack build {{justfile_directory()}}/../../crates/agent_fold --target web --release --out-dir {{justfile_directory()}}/src/lib/core/agent-fold/wasm -- --no-default-features
+ CARGO_TARGET_DIR="{{agent_fold_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/agent_fold --target web --release --out-dir {{justfile_directory()}}/src/lib/core/agent-fold/wasm -- --no-default-features
# Dev fast path: build the agent-fold wasm pkg only when it is missing or any
# fold source is newer than the built artifact. A stale artifact folds with the
diff --git a/tooling/xtask/crates/xtask_cache_wasm/src/main.rs b/tooling/xtask/crates/xtask_cache_wasm/src/main.rs
index eebe0eee5b..a049ff1df2 100644
--- a/tooling/xtask/crates/xtask_cache_wasm/src/main.rs
+++ b/tooling/xtask/crates/xtask_cache_wasm/src/main.rs
@@ -53,8 +53,11 @@ fn run(force: bool) -> Result<()> {
}
}
+ // Same target dir as `just build-cache-wasm` so local ensure and CI
+ // rebuilds share artifacts and do not contend with the fold wasm crate.
let status = Command::new("wasm-pack")
.current_dir(&workspace_dir)
+ .env("CARGO_TARGET_DIR", workspace_dir.join("target/cache-wasm"))
.arg("build")
.arg(CRATE_REL)
.arg("--target")
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs
index 814254cb82..eaa22234a6 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs
@@ -16,6 +16,9 @@ use gh_workflow::{
use crate::workflows::{runners, steps, vars, web_artifact_paths::WEB_ARTIFACT_PATHS};
+#[cfg(test)]
+mod test;
+
const PREVIEW_BUCKET: &str = "macro-preview-assets-dev";
/// Build the workflow.
@@ -50,10 +53,13 @@ fn deploy() -> Job {
.pull_requests(Level::Write),
)
.add_step(checkout())
- .add_step(steps::mount_web_cache_volume(false))
+ .add_step(steps::mount_web_build_cache_volume())
.add_step(steps::setup_nix())
.add_step(steps::setup_reqs_web("Setup", false))
+ .add_step(steps::configure_namespace_sccache(vars::WEB_SCCACHE_NAME))
+ .add_step(steps::start_sccache_server())
.add_step(build())
+ .add_step(steps::show_sccache_stats())
.add_step(configure_aws_credentials())
.add_step(get_or_create_preview_id())
.add_step(validate_bucket_name())
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview/test.rs
new file mode 100644
index 0000000000..23107e4358
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview/test.rs
@@ -0,0 +1,27 @@
+use super::*;
+
+#[test]
+fn preview_build_uses_remote_sccache_and_wasm_cache() {
+ let yaml = deploy_preview().to_string().expect("workflow yaml");
+ let job = yaml.split("\n deploy:\n").nth(1).expect("deploy job");
+ assert!(
+ job.contains("nsc cache sccache setup --cache_name web-ci"),
+ "preview must use the shared web-ci remote sccache: {job}"
+ );
+ let configure = job
+ .find("nsc cache sccache setup")
+ .expect("remote cache configuration");
+ let start = job
+ .find("run: sccache --start-server")
+ .expect("start the server in a separate step with the exported credentials");
+ let build_command = job.find("just build-").expect("web build command");
+ assert!(configure < start && start < build_command);
+ assert!(
+ job.contains(".wasm-pack"),
+ "preview must persist wasm-pack's wasm-opt cache: {job}"
+ );
+ assert!(
+ job.contains("just build-dev"),
+ "preview still builds the vite bundle: {job}"
+ );
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs
index 6969bda417..3059e2931d 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs
@@ -12,6 +12,9 @@ use gh_workflow::{
use crate::workflows::{runners, steps, vars};
+#[cfg(test)]
+mod test;
+
/// Build the workflow. The `workflow_dispatch`/`workflow_call` input blocks
/// are filled in by [`patch`] (choice options + ordered maps).
pub fn deploy_web_app() -> Workflow {
@@ -95,10 +98,13 @@ fn build_deploy() -> Job {
.runs_on(runners::Runner::Mid.with_cache_tag(vars::WEB_CI_CACHE_TAG))
.add_env(("CI", "true"))
.add_step(checkout())
- .add_step(steps::mount_web_cache_volume(false))
+ .add_step(steps::mount_web_build_cache_volume())
.add_step(steps::setup_nix())
.add_step(steps::setup_reqs_web("Setup", false))
+ .add_step(steps::configure_namespace_sccache(vars::WEB_SCCACHE_NAME))
+ .add_step(steps::start_sccache_server())
.add_step(build())
+ .add_step(steps::show_sccache_stats())
.add_step(install_infra_dependencies())
.add_step(configure_aws_credentials())
.add_step(pulumi_up())
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app/test.rs
new file mode 100644
index 0000000000..d8b10b9d7e
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app/test.rs
@@ -0,0 +1,30 @@
+use super::*;
+
+#[test]
+fn deploy_build_uses_remote_sccache_and_wasm_cache() {
+ let yaml = deploy_web_app().to_string().expect("workflow yaml");
+ let job = yaml
+ .split("\n build-deploy:\n")
+ .nth(1)
+ .expect("build-deploy job");
+ assert!(
+ job.contains("nsc cache sccache setup --cache_name web-ci"),
+ "deploy must use the shared web-ci remote sccache: {job}"
+ );
+ let configure = job
+ .find("nsc cache sccache setup")
+ .expect("remote cache configuration");
+ let start = job
+ .find("run: sccache --start-server")
+ .expect("start the server in a separate step with the exported credentials");
+ let build_command = job.find("just build-").expect("web build command");
+ assert!(configure < start && start < build_command);
+ assert!(
+ job.contains(".wasm-pack"),
+ "deploy must persist wasm-pack's wasm-opt cache: {job}"
+ );
+ assert!(
+ job.contains("just build-${{ inputs.environment }}"),
+ "deploy still builds via just: {job}"
+ );
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
index 49b750c42c..25744b386c 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
@@ -297,6 +297,23 @@ pub fn mount_web_cache_volume(with_rust: bool) -> Step<Use> {
})
}
+/// [`mount_web_cache_volume`] for jobs that compile the browser wasm packages
+/// (`just build-*`). Cargo registry/git feed wasm-pack; `.wasm-pack` is the
+/// downloaded `wasm-opt` the same way [`mount_wasm_cache_volume`] keeps the
+/// worker build warm. Compiled objects use Namespace remote sccache.
+pub fn mount_web_build_cache_volume() -> Step<Use> {
+ nscloud_cache_action("Mount Namespace cache volume")
+ .add_with(("cache", "nix"))
+ .add_with((
+ "path",
+ format!(
+ "{}\n/home/runner/.cargo/registry\n/home/runner/.cargo/git\n{}",
+ vars::BUN_CACHE_VOLUME_DIR,
+ xtask_paths::runtime_path!("/home/runner/.cache/.wasm-pack").as_str(),
+ ),
+ ))
+}
+
/// The web-app composite: Nix dev shell (bun, biome, just) + `bun install`.
/// Jobs that run `gen-api` follow this with [`configure_namespace_sccache`].
/// Requires [`setup_nix`] first.
@@ -308,6 +325,13 @@ pub fn setup_reqs_web(name: &str, playwright: bool) -> Step<Use> {
.when(playwright, |step| step.add_with(("playwright", "true")))
}
+/// Start the server before parallel compiler invocations can race to launch it.
+/// Keep this in a separate step after remote configuration so `GITHUB_ENV`
+/// has supplied the selected backend's credentials to the process.
+pub fn start_sccache_server() -> Step<Run> {
+ Step::new("Start sccache server").run("sccache --start-server")
+}
+
/// `sccache --show-stats` at the end of a job (never fails the job).
pub fn show_sccache_stats() -> Step<Run> {
Step::new("show sccache stats")
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/steps/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/steps/test.rs
index 3633d96a72..ac950b2555 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/steps/test.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/steps/test.rs
@@ -67,3 +67,22 @@ fn default_dev_shell_does_not_pass_a_shell_input() {
"unspecified shell must keep the action default so other workflows stay unchanged"
);
}
+
+#[test]
+fn web_build_cache_volume_includes_wasm_pack_and_cargo() {
+ let step = mount_web_build_cache_volume();
+ let with = step.value.with.expect("cache volume should set paths");
+ let path = with
+ .0
+ .get("path")
+ .and_then(|value| value.as_str())
+ .expect("path list");
+ assert!(path.contains("/home/runner/.bun/install/cache"));
+ assert!(path.contains("/home/runner/.cargo/registry"));
+ assert!(path.contains("/home/runner/.cargo/git"));
+ assert!(path.contains("/home/runner/.cache/.wasm-pack"));
+ assert_eq!(
+ with.0.get("cache").and_then(|value| value.as_str()),
+ Some("nix")
+ );
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
index 4cb89afd5c..d314f836ec 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
@@ -20,8 +20,9 @@ fn web_runner() -> String {
runners::Runner::Small.with_cache_tag(vars::WEB_CI_CACHE_TAG)
}
-/// Typechecking can compile the Rust binaries used by `gen-api`, so retain the
-/// mid-size profile while sharing the web CI cache volume and remote sccache.
+/// Typechecking can compile the Rust binaries used by `gen-api`, and the app
+/// build compiles the two browser wasm packages, so retain the mid-size
+/// profile while sharing the web CI cache volume and remote sccache.
fn typecheck_runner() -> String {
runners::Runner::Mid.with_cache_tag(vars::WEB_CI_CACHE_TAG)
}
@@ -124,10 +125,13 @@ fn build() -> Job {
// Match preview/deploy capacity for Vite's chunk-rendering memory peak.
.runs_on(runners::Runner::Mid.with_cache_tag(vars::WEB_CI_CACHE_TAG))
.add_step(checkout("Checkout Repo", false))
- .add_step(steps::mount_web_cache_volume(false))
+ .add_step(steps::mount_web_build_cache_volume())
.add_step(steps::setup_nix())
.add_step(steps::setup_reqs_web("Setup", false))
+ .add_step(steps::configure_namespace_sccache(vars::WEB_SCCACHE_NAME))
+ .add_step(steps::start_sccache_server())
.add_step(run_build())
+ .add_step(steps::show_sccache_stats())
.add_step(steps::teardown_nix())
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs
index b03b14175d..d05b5aaefa 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs
@@ -43,3 +43,59 @@ fn typecheck_runs_lexical_service_check_and_tests() {
"lexical-service steps must run in the service directory: {typescript}"
);
}
+
+#[test]
+fn should_run_includes_fold_wasm_inputs() {
+ let yaml = web_app_check_main().to_string().expect("workflow yaml");
+ let filters = yaml
+ .split("filters: |")
+ .nth(1)
+ .and_then(|rest| rest.split("id: filter").next())
+ .expect("path-check filters");
+ let should_run = filters
+ .split("api_changed:")
+ .next()
+ .expect("should_run block");
+ assert!(
+ should_run.contains("crates/agent_fold/**"),
+ "fold wasm source must rebuild the web artifact: {should_run}"
+ );
+ assert!(
+ should_run.contains("crates/agent_runtime_protocol/**"),
+ "fold wasm path dep must rebuild the web artifact: {should_run}"
+ );
+}
+
+#[test]
+fn build_job_uses_remote_sccache_and_wasm_cache() {
+ let yaml = web_app_check_main().to_string().expect("workflow yaml");
+ let build = yaml
+ .split("\n build:\n")
+ .nth(1)
+ .and_then(|rest| rest.split("\n status-check:").next())
+ .expect("build job");
+ assert!(
+ build.contains("namespace-profile-linux-mid"),
+ "wasm compile needs the mid runner: {build}"
+ );
+ assert!(
+ build.contains("nsc cache sccache setup --cache_name web-ci"),
+ "build must use the shared web-ci remote sccache: {build}"
+ );
+ let configure = build
+ .find("nsc cache sccache setup")
+ .expect("remote cache configuration");
+ let start = build
+ .find("run: sccache --start-server")
+ .expect("start the server in a separate step with the exported credentials");
+ let build_command = build.find("just build-").expect("web build command");
+ assert!(configure < start && start < build_command);
+ assert!(
+ build.contains(".wasm-pack"),
+ "build must persist wasm-pack's wasm-opt cache: {build}"
+ );
+ assert!(
+ build.contains("just build-dev"),
+ "build still produces the vite bundle: {build}"
+ );
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_artifact_paths.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_artifact_paths.rs
index 3f930a4ff3..fc08b12dd4 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_artifact_paths.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_artifact_paths.rs
@@ -2,15 +2,17 @@
use xtask_paths::RepoGlob;
-/// Shared by web checks and preview builds so a cache-WASM or shared-package
-/// change cannot be tested without being built (or built without being
-/// tested). The push-to-main dev deploy is not path-gated at all — see
-/// [`crate::workflows::deploy_on_push`] for why.
+/// Shared by web checks and preview builds so a cache-WASM, fold-WASM, or
+/// shared-package change cannot be tested without being built (or built
+/// without being tested). The push-to-main dev deploy is not path-gated at
+/// all — see [`crate::workflows::deploy_on_push`] for why.
pub const WEB_ARTIFACT_PATHS: &[RepoGlob<'static>] = &[
RepoGlob::new("package.json"),
RepoGlob::new("bun.lock"),
RepoGlob::new("apps/web/**"),
RepoGlob::new("packages/**"),
+ RepoGlob::new("crates/agent_fold/**"),
+ RepoGlob::new("crates/agent_runtime_protocol/**"),
RepoGlob::new("crates/client/cache-core/**"),
RepoGlob::new("crates/client/cache-turso/**"),
RepoGlob::new("crates/client/cache-wasm/**"),