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: set up sync service ci (#5265)

Wolf Mermelstein418ed7163e57
diff --git a/.github/workflows/deploy_sync_service.yml b/.github/workflows/deploy_sync_service.yml
new file mode 100644
index 0000000000..95c11883b5
--- /dev/null
+++ b/.github/workflows/deploy_sync_service.yml
@@ -0,0 +1,81 @@
+# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).
+# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs
+name: Deploy Sync Service
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - .github/workflows/deploy_sync_service.yml
+ - services/sync-service/**
+ - crates/macro_sync_service_jwt/**
+ - Cargo.toml
+ - Cargo.lock
+ - rust-toolchain.toml
+ workflow_call:
+ inputs:
+ environment:
+ required: true
+ type: string
+ description: The environment to deploy to. e.g. (dev, prod)
+ secrets:
+ CLOUDFLARE_API_TOKEN:
+ required: true
+ workflow_dispatch:
+ inputs:
+ environment:
+ required: true
+ type: choice
+ default: dev
+ options:
+ - dev
+ - prod
+ description: The environment to deploy to
+jobs:
+ deploy:
+ name: Deploy to Cloudflare
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=sync-service-deploy
+ steps:
+ - name: Checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ clean: 'false'
+ persist-credentials: 'false'
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: rust
+ path: |-
+ ${{ github.workspace }}/target
+ /home/runner/.cargo/bin
+ /home/runner/.cache/.wasm-pack
+ continue-on-error: true
+ - name: Setup Rust
+ uses: ./.github/actions/setup-rust
+ with:
+ sccache: 'false'
+ rust-cache: 'false'
+ - name: Add wasm32 target
+ run: rustup target add wasm32-unknown-unknown
+ - name: Setup Node
+ uses: actions/setup-node@v4
+ with:
+ node-version: '22'
+ - name: Install dependencies
+ run: npm ci
+ working-directory: services/sync-service
+ - name: Apply D1 migrations
+ run: npx wrangler d1 migrations apply USER_PEER_MAPPING --env ${{ inputs.environment || 'dev' }} --remote
+ env:
+ CI: 'true'
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
+ working-directory: services/sync-service
+ - name: Deploy with wrangler
+ run: npx wrangler deploy --env ${{ inputs.environment || 'dev' }}
+ env:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
+ working-directory: services/sync-service
+concurrency:
+ group: deploy-sync-service-${{ inputs.environment || 'dev' }}
diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml
index 68b3a496fa..f5a6680c73 100644
--- a/.github/workflows/release-production.yml
+++ b/.github/workflows/release-production.yml
@@ -24,6 +24,15 @@ jobs:
DD_API_KEY: ${{ secrets.DD_API_KEY }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ deploy-sync-service:
+ name: Deploy Sync Service
+ # The worker calls DSS/SPS at prod URLs, so don't ship it ahead of them.
+ needs: [deploy-cloud-storage]
+ uses: ./.github/workflows/deploy_sync_service.yml
+ with:
+ environment: prod
+ secrets: inherit
+
build:
name: Build Web App
runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
diff --git a/Cargo.lock b/Cargo.lock
index 252f7e6087..4bf965dece 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5424,7 +5424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -7595,7 +7595,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
dependencies = [
"hermit-abi",
"libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -7765,13 +7765,12 @@ dependencies = [
[[package]]
name = "js-sys"
-version = "0.3.98"
+version = "0.3.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08"
+checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102"
dependencies = [
"cfg-if",
"futures-util",
- "once_cell",
"wasm-bindgen",
]
@@ -10008,7 +10007,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -11515,7 +11514,7 @@ checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4"
dependencies = [
"bytes",
"heck 0.5.0",
- "itertools 0.10.5",
+ "itertools 0.12.1",
"log",
"multimap",
"once_cell",
@@ -11535,7 +11534,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1"
dependencies = [
"anyhow",
- "itertools 0.10.5",
+ "itertools 0.12.1",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -12491,7 +12490,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.12.1",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -12562,7 +12561,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -14572,7 +14571,7 @@ dependencies = [
"getrandom 0.4.2",
"once_cell",
"rustix 1.1.4",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -15779,9 +15778,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
[[package]]
name = "wasm-bindgen"
-version = "0.2.121"
+version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790"
+checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4"
dependencies = [
"cfg-if",
"once_cell",
@@ -15792,9 +15791,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
-version = "0.4.71"
+version = "0.4.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "96492d0d3ffba25305a7dc88720d250b1401d7edca02cc3bcd50633b424673b8"
+checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -15802,9 +15801,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.121"
+version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578"
+checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -15812,9 +15811,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.121"
+version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2"
+checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e"
dependencies = [
"bumpalo",
"proc-macro2",
@@ -15825,18 +15824,18 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.121"
+version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441"
+checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24"
dependencies = [
"unicode-ident",
]
[[package]]
name = "wasm-bindgen-test"
-version = "0.3.71"
+version = "0.3.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af5ec93229ad9ccd0a545a516dec76dc276613f278f6a91aa6b463d5b33d42d0"
+checksum = "2a0d555ca874445df8d314f94f5c948a4e74e5418f332c89f660a3d8310a96f4"
dependencies = [
"async-trait",
"cast",
@@ -15856,9 +15855,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-test-macro"
-version = "0.3.71"
+version = "0.3.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c81b9fef827e575e0e54431736d1baa0d700315d8c62cfef1f61fa3aad0cbeb"
+checksum = "94eb68555b95bcea5e8cf4abe280b529049479fa995bfc23734af96a6aedc120"
dependencies = [
"proc-macro2",
"quote",
@@ -15867,9 +15866,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-test-shared"
-version = "0.2.121"
+version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f4d8ae7ad5440360e9799dfd42857d126454a88441ddf72d288ef83fa47f527"
+checksum = "c31d56021e873866c968588ed85ccdf56db5c426e44afdb4618c39895104b920"
[[package]]
name = "wasm-encoder"
@@ -15920,9 +15919,9 @@ dependencies = [
[[package]]
name = "web-sys"
-version = "0.3.98"
+version = "0.3.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b572dff8bcf38bad0fa19729c89bb5748b2b9b1d8be70cf90df697e3a8f32aa"
+checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -16081,7 +16080,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.48.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -16649,7 +16648,6 @@ dependencies = [
"idna",
"indexmap 2.14.0",
"ipnet",
- "itertools 0.10.5",
"lazy_static",
"libc",
"linux-raw-sys 0.12.1",
diff --git a/Cargo.toml b/Cargo.toml
index 8c89ef3bf3..6809e8f9b3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -259,7 +259,9 @@ utoipa = { version = "5.4.0", features = [
] }
utoipa-swagger-ui = { version = "9", features = ["axum", "vendored"] }
uuid = { version = "1.15.1", features = ["fast-rng", "serde", "v4", "v5", "v7"] }
-wasm-bindgen = "0.2"
+# worker-build (see services/sync-service/wrangler.toml) refuses to build against
+# anything older than 0.2.123, so keep this floor above that.
+wasm-bindgen = "0.2.123"
wasm-bindgen-futures = "0.4"
# this is pinned to match axum 0.7.9 dependency requirements
async-stripe = { version = "0.41", default-features = false, features = [
diff --git a/crates/workspace-hack/Cargo.toml b/crates/workspace-hack/Cargo.toml
index a3b482f810..370cd52490 100644
--- a/crates/workspace-hack/Cargo.toml
+++ b/crates/workspace-hack/Cargo.toml
@@ -192,7 +192,6 @@ hyper-rustls-adf3d7031871b0af = { package = "hyper-rustls", version = "0.24", de
hyper-util = { version = "0.1", features = ["client-legacy", "client-proxy", "http1", "http2", "server", "service"] }
idna = { version = "1" }
indexmap = { version = "2", features = ["serde"] }
-itertools = { version = "0.10" }
lazy_static = { version = "1", default-features = false, features = ["spin_no_std"] }
libc = { version = "0.2", features = ["extra_traits"] }
log = { version = "0.4", default-features = false, features = ["std"] }
diff --git a/services/sync-service/justfile b/services/sync-service/justfile
index ae667fa8ee..6851c9874e 100644
--- a/services/sync-service/justfile
+++ b/services/sync-service/justfile
@@ -46,5 +46,12 @@ deploy-playground-dry:
deploy-dev-dry:
npx wrangler deploy --env dev --dry-run
-deploy-prod:
+deploy-prod-dry:
+ npx wrangler deploy --env prod --dry-run
+
+migrate-d1-prod:
+ CI=true npx wrangler d1 migrations apply USER_PEER_MAPPING --env prod --remote
+
+# CI runs the same two steps (.github/workflows/deploy_sync_service.yml)
+deploy-prod: migrate-d1-prod
npx wrangler deploy --env prod
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs
new file mode 100644
index 0000000000..caa26568a6
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs
@@ -0,0 +1,131 @@
+//! `Deploy Sync Service` — deploys the `sync_service` Cloudflare Worker
+//! (`services/sync-service`) via wrangler, applying its D1 migrations first.
+//! Unlike [`crate::workflows::deploy_ai_editing_worker`] this worker is Rust, so
+//! the job needs a toolchain and the wasm target. Generated into
+//! `deploy_sync_service.yml`.
+
+use anyhow::Result;
+use gh_workflow::{Concurrency, Event, Expression, Job, Push, Run, Step, Use, Workflow};
+
+use crate::workflows::{runners, steps, vars};
+
+const ENVIRONMENT: &str = "${{ inputs.environment || 'dev' }}";
+
+pub fn deploy_sync_service() -> Workflow {
+ Workflow::new("Deploy Sync Service")
+ .on(Event::default()
+ // Only redeploy when the worker, its one path dependency, or the
+ // workspace's Rust pinning changes.
+ .push(
+ Push::default()
+ .add_branch("main")
+ .add_path(xtask_paths::repo_glob!(
+ ".github/workflows/deploy_sync_service.yml"
+ ))
+ .add_path(xtask_paths::repo_glob!("services/sync-service/**"))
+ .add_path(xtask_paths::repo_glob!("crates/macro_sync_service_jwt/**"))
+ .add_path(xtask_paths::repo_glob!("Cargo.toml"))
+ .add_path(xtask_paths::repo_glob!("Cargo.lock"))
+ .add_path(xtask_paths::repo_glob!("rust-toolchain.toml")),
+ ))
+ // The `workflow_call` / `workflow_dispatch` input blocks are filled in
+ // by `patch` below.
+ .concurrency(
+ // Literal prefix rather than `github.workflow`: for workflow_call
+ // runs that expression expands to the *caller's* name.
+ Concurrency::new(Expression::new(format!(
+ "deploy-sync-service-{ENVIRONMENT}"
+ ))),
+ )
+ .add_job("deploy", deploy())
+}
+
+pub fn patch(root: &mut serde_yaml::Value) -> Result<()> {
+ let on = root
+ .get_mut("on")
+ .and_then(serde_yaml::Value::as_mapping_mut)
+ .ok_or_else(|| anyhow::anyhow!("rendered workflow has no `on` mapping"))?;
+ on.insert(
+ "workflow_call".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ inputs:
+ environment:
+ required: true
+ type: string
+ description: The environment to deploy to. e.g. (dev, prod)
+ secrets:
+ CLOUDFLARE_API_TOKEN:
+ required: true
+ "#})?,
+ );
+ on.insert(
+ "workflow_dispatch".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ inputs:
+ environment:
+ required: true
+ type: choice
+ default: 'dev'
+ options:
+ - dev
+ - prod
+ description: The environment to deploy to
+ "#})?,
+ );
+ Ok(())
+}
+
+fn deploy() -> Job {
+ Job::default()
+ .name("Deploy to Cloudflare")
+ .runs_on(runners::Runner::Mid.with_cache_tag(vars::SYNC_SERVICE_CACHE_TAG))
+ .add_step(steps::checkout(false, false))
+ .add_step(steps::mount_wasm_cache_volume())
+ .add_step(steps::setup_rust_light())
+ .add_step(add_wasm_target())
+ .add_step(setup_node())
+ .add_step(install_deps())
+ .add_step(apply_d1_migrations())
+ .add_step(deploy_step())
+}
+
+/// [`steps::setup_rust_light`] installs the channel explicitly, which skips
+/// `rust-toolchain.toml`'s `targets`.
+fn add_wasm_target() -> Step<Run> {
+ Step::new("Add wasm32 target").run("rustup target add wasm32-unknown-unknown")
+}
+
+fn setup_node() -> Step<Use> {
+ Step::new("Setup Node")
+ .uses("actions", "setup-node", "v4")
+ .add_with(("node-version", "22"))
+}
+
+/// sync-service keeps its own `package-lock.json` rather than joining the root
+/// bun workspace, so install it here instead of relying on hoisting.
+fn install_deps() -> Step<Run> {
+ Step::new("Install dependencies")
+ .run("npm ci")
+ .working_directory(xtask_paths::repo_dir!("services/sync-service"))
+}
+
+/// Migrate first: new code against an already-migrated D1 is safe, the reverse
+/// is a live error.
+fn apply_d1_migrations() -> Step<Run> {
+ Step::new("Apply D1 migrations")
+ .run(format!(
+ "npx wrangler d1 migrations apply USER_PEER_MAPPING --env {ENVIRONMENT} --remote"
+ ))
+ .working_directory(xtask_paths::repo_dir!("services/sync-service"))
+ .add_env(("CI", "true"))
+ .add_env(("CLOUDFLARE_API_TOKEN", vars::CLOUDFLARE_API_TOKEN))
+ .add_env(("CLOUDFLARE_ACCOUNT_ID", vars::CLOUDFLARE_ACCOUNT_ID))
+}
+
+fn deploy_step() -> Step<Run> {
+ Step::new("Deploy with wrangler")
+ .run(format!("npx wrangler deploy --env {ENVIRONMENT}"))
+ .working_directory(xtask_paths::repo_dir!("services/sync-service"))
+ .add_env(("CLOUDFLARE_API_TOKEN", vars::CLOUDFLARE_API_TOKEN))
+ .add_env(("CLOUDFLARE_ACCOUNT_ID", vars::CLOUDFLARE_ACCOUNT_ID))
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
index c8330d0fa2..67b279235e 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
@@ -28,6 +28,7 @@ mod deploy_all_services;
mod deploy_cloud_storage_on_push;
mod deploy_fusionauth_instance;
mod deploy_preview;
+mod deploy_sync_service;
mod deploy_web_app;
mod deploy_web_app_dev_push;
mod path_validation;
@@ -203,6 +204,16 @@ const WORKFLOWS: &[WorkflowFile] = &[
file_name: "deploy_preview.yml",
render_yaml: || render_gh_workflow(deploy_preview::deploy_preview)(),
},
+ WorkflowFile {
+ slug: "deploy_sync_service",
+ file_name: "deploy_sync_service.yml",
+ render_yaml: || {
+ render_patched(
+ deploy_sync_service::deploy_sync_service,
+ deploy_sync_service::patch,
+ )
+ },
+ },
WorkflowFile {
slug: "deploy_web_app",
file_name: "deploy_web_app.yml",
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
index 5794bf215a..08ae28d9cb 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
@@ -122,14 +122,21 @@ pub fn setup_cachix_dev_shell() -> Step<Use> {
/// `continue-on-error` because the volume is a pure optimization — a failure
/// just means cold Cargo/Nix state, never a wrong build.
pub fn mount_cache_volume() -> Step<Use> {
- Step::new("Mount Namespace cache volume")
+ nscloud_cache_action("Mount Namespace cache volume")
+ .add_with(("cache", "rust"))
+ .add_with(("path", xtask_paths::runtime_path!("/nix").as_str()))
+}
+
+/// The pinned `nscloud-cache-action`, shared by every mount helper below.
+/// `continue-on-error` because a cache volume is always a pure optimization — a
+/// failure just means cold state, never a wrong build.
+fn nscloud_cache_action(name: &str) -> Step<Use> {
+ Step::new(name)
.uses(
"namespacelabs",
"nscloud-cache-action",
"15799a6b54e5765f85b2aac25b3f0df43ed571c0", // v1.4.3
)
- .add_with(("cache", "rust"))
- .add_with(("path", xtask_paths::runtime_path!("/nix").as_str()))
.continue_on_error(true)
}
@@ -142,12 +149,7 @@ pub fn mount_cache_volume() -> Step<Use> {
/// The volume is a block-device mount, so multi-GB trees cost nothing to save
/// or restore when it hits.
pub fn mount_cache_volume_with_cargo_target() -> Step<Use> {
- Step::new("Mount Namespace cache volume")
- .uses(
- "namespacelabs",
- "nscloud-cache-action",
- "15799a6b54e5765f85b2aac25b3f0df43ed571c0", // v1.4.3
- )
+ nscloud_cache_action("Mount Namespace cache volume")
.add_with(("cache", "nix"))
.add_with((
"path",
@@ -156,7 +158,24 @@ pub fn mount_cache_volume_with_cargo_target() -> Step<Use> {
vars::PREVIEW_SNAPSHOT_VOLUME_DIR,
),
))
- .continue_on_error(true)
+}
+
+/// [`mount_cache_volume`] for the wasm worker build. `target/` is listed
+/// explicitly for the same reason [`mount_cache_volume_with_cargo_target`] does
+/// it — `cache: rust` alone is only relied on for the registry/git here. The
+/// last two paths are what wrangler's `[build]` line otherwise redoes every
+/// run: the pinned `worker-build` binary and wasm-pack's downloaded `wasm-opt`.
+pub fn mount_wasm_cache_volume() -> Step<Use> {
+ nscloud_cache_action("Mount Namespace cache volume")
+ .add_with(("cache", "rust"))
+ .add_with((
+ "path",
+ format!(
+ "${{{{ github.workspace }}}}/target\n{}\n{}",
+ xtask_paths::runtime_path!("/home/runner/.cargo/bin").as_str(),
+ xtask_paths::runtime_path!("/home/runner/.cache/.wasm-pack").as_str(),
+ ),
+ ))
}
/// Configure Namespace's official artifact-backed remote sccache. Call this
@@ -215,12 +234,7 @@ fi"#
/// OpenAPI-binary build; compiled objects live in Namespace's remote sccache.
/// `continue-on-error` for the same reason as [`mount_cache_volume`].
pub fn mount_web_cache_volume(with_rust: bool) -> Step<Use> {
- Step::new("Mount Namespace cache volume")
- .uses(
- "namespacelabs",
- "nscloud-cache-action",
- "15799a6b54e5765f85b2aac25b3f0df43ed571c0", // v1.4.3
- )
+ nscloud_cache_action("Mount Namespace cache volume")
.add_with(("cache", "nix"))
.map(|step| {
if with_rust {
@@ -235,7 +249,6 @@ pub fn mount_web_cache_volume(with_rust: bool) -> Step<Use> {
step.add_with(("path", vars::BUN_CACHE_VOLUME_DIR))
}
})
- .continue_on_error(true)
}
/// The web-app composite: Nix dev shell (bun, biome, just) + `bun install`.
@@ -329,14 +342,7 @@ pub fn upload_handoff_artifact(file: &str, service_expr: &str) -> Step<Run> {
/// version-pinned by infra/ and identical across services; a cold volume just
/// re-downloads (~45s). Requires the job to pin `PULUMI_HOME: /pulumi`.
pub fn cache_pulumi_plugins() -> Step<Use> {
- Step::new("Cache Pulumi plugins")
- .uses(
- "namespacelabs",
- "nscloud-cache-action",
- "15799a6b54e5765f85b2aac25b3f0df43ed571c0", // v1.4.3
- )
- .add_with(("path", "/pulumi/plugins"))
- .continue_on_error(true)
+ nscloud_cache_action("Cache Pulumi plugins").add_with(("path", "/pulumi/plugins"))
}
/// Make PULUMI_HOME (/pulumi) and its mounted plugins subdir writable so
@@ -374,14 +380,7 @@ pub fn checkout_ref(ref_expr: &str) -> Step<Use> {
/// Mount only the `/nix` store cache volume (no cargo/sccache). Used by the
/// desktop builds that delegate entirely to Nix.
pub fn mount_nix_cache_volume() -> Step<Use> {
- Step::new("Mount /nix cache volume")
- .uses(
- "namespacelabs",
- "nscloud-cache-action",
- "15799a6b54e5765f85b2aac25b3f0df43ed571c0", // v1.4.3
- )
- .add_with(("cache", "nix"))
- .continue_on_error(true)
+ nscloud_cache_action("Mount /nix cache volume").add_with(("cache", "nix"))
}
/// Configure Cachix (without entering a dev shell).
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
index 26a1eae59f..cc59718369 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
@@ -77,6 +77,11 @@ pub const WEB_CI_CACHE_TAG: &str = "web-ci";
/// a different workload and runner profile.
pub const WEB_SCCACHE_NAME: &str = "web-ci";
+/// Namespace cache tag for the sync-service worker deploy. Its own pool: this
+/// job compiles for `wasm32-unknown-unknown`, so nothing in the host-target
+/// volumes ([`CI_CACHE_TAG`]) would serve it anyway.
+pub const SYNC_SERVICE_CACHE_TAG: &str = "sync-service-deploy";
+
/// Bun's global package cache. Mounted explicitly because Bun is supplied by
/// the Nix dev shell and is not available to Namespace's cache planner yet.
pub const BUN_CACHE_VOLUME_DIR: &str = "/home/runner/.bun/install/cache";