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): migrate web ap pr checks to namespace cargo x workflows (#4499)

teo9e7925c73494
diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml
index 05ecfb5386..d2dda02130 100644
--- a/.github/actionlint.yaml
+++ b/.github/actionlint.yaml
@@ -3,6 +3,8 @@ self-hosted-runner:
- linux-extra-beefy
- linux-latest-middy
- namespace-profile-linux-mid
+ - namespace-profile-linux-mid;overrides.cache-tag=web-ci
- namespace-profile-linux-small
+ - namespace-profile-linux-tiny-no-cache
- namespace-profile-linux-rust-ci
- namespace-profile-linux-rust-ci;overrides.cache-tag=sccache-ci
diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml
deleted file mode 100644
index 6a94e17520..0000000000
--- a/.github/workflows/deploy-preview.yml
+++ /dev/null
@@ -1,90 +0,0 @@
-# Frontend Preview Deployments
-#
-# Deploys a preview build to <branch>-<nanoid>-preview.macro.com
-# Built identical to dev.macro.com (MODE=development, points to dev services)
-#
-# NOTE: This workflow should NOT be added to required status checks.
-# PRs should be mergeable regardless of preview deploy status.
-
-name: Deploy Preview
-
-on:
- pull_request:
- types: [opened, synchronize]
- paths:
- - 'js/app/**'
-
-concurrency:
- group: preview-${{ github.event.pull_request.number }}
- cancel-in-progress: true
-
-env:
- PREVIEW_BUCKET: macro-preview-assets-dev
-
-jobs:
- deploy:
- runs-on: linux-extra-beefy
- permissions:
- contents: read
- pull-requests: write
- steps:
- - uses: actions/checkout@v6
-
- - name: Setup
- uses: ./.github/actions/setup-reqs-web
- with:
- cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- sccache-bucket: ${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}
-
- # Build identical to dev.macro.com deployment
- - name: Build
- working-directory: js/app
- run: just build-dev
- env:
- VITE_DD_WEB_APP_TOKEN: ${{ secrets.DD_WEB_APP_TOKEN }}
- VITE_DD_HASH: ${{ github.sha }}
- VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}
- VITE_POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
-
- - name: Configure AWS Credentials
- uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b
- with:
- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- aws-region: us-east-1
-
- - name: Get or create preview ID
- id: preview-id
- working-directory: js/app
- run: |
- PREVIEW_ID=$(bun scripts/preview/get-or-create-id.ts \
- --pr ${{ github.event.pull_request.number }} \
- --repo ${{ github.repository }} \
- --token ${{ secrets.GITHUB_TOKEN }} \
- --branch "${{ github.head_ref }}")
- echo "id=$PREVIEW_ID" >> $GITHUB_OUTPUT
- echo "Preview ID: $PREVIEW_ID"
-
- - name: Validate bucket name
- run: |
- if [[ "${{ env.PREVIEW_BUCKET }}" != "macro-preview-assets-dev" ]]; then
- echo "ERROR: PREVIEW_BUCKET must be 'macro-preview-assets-dev'"
- exit 1
- fi
-
- - name: Deploy to S3
- working-directory: js/app
- run: |
- bun scripts/preview/deploy.ts \
- --preview-id ${{ steps.preview-id.outputs.id }} \
- --skip-build
-
- - name: Comment on PR
- working-directory: js/app
- run: |
- bun scripts/preview/post-comment.ts \
- --pr ${{ github.event.pull_request.number }} \
- --repo ${{ github.repository }} \
- --token ${{ secrets.GITHUB_TOKEN }} \
- --preview-id ${{ steps.preview-id.outputs.id }} \
- --sha ${{ github.sha }}
diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml
new file mode 100644
index 0000000000..fd92d80f4e
--- /dev/null
+++ b/.github/workflows/deploy_preview.yml
@@ -0,0 +1,82 @@
+# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
+# Source: rust/cloud-storage/tools/xtask/src/workflows/deploy_preview.rs
+name: Deploy Preview
+env:
+ PREVIEW_BUCKET: macro-preview-assets-dev
+'on':
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ paths:
+ - js/app/**
+jobs:
+ deploy:
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
+ permissions:
+ contents: read
+ pull-requests: write
+ steps:
+ - name: Checkout Repo
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: bun
+ path: /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
+ - name: Setup
+ uses: './.github/actions/setup-reqs-web'
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ - name: Build
+ run: just build-dev
+ env:
+ VITE_DD_WEB_APP_TOKEN: ${{ secrets.DD_WEB_APP_TOKEN }}
+ VITE_DD_HASH: ${{ github.sha }}
+ VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}
+ VITE_POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
+ working-directory: js/app
+ - name: Configure AWS Credentials
+ uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b
+ with:
+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ aws-region: us-east-1
+ - id: preview-id
+ name: Get or create preview ID
+ run: |
+ PREVIEW_ID=$(bun scripts/preview/get-or-create-id.ts \
+ --pr ${{ github.event.pull_request.number }} \
+ --repo ${{ github.repository }} \
+ --token ${{ secrets.GITHUB_TOKEN }} \
+ --branch "${{ github.head_ref }}")
+ echo "id=$PREVIEW_ID" >> $GITHUB_OUTPUT
+ echo "Preview ID: $PREVIEW_ID"
+ working-directory: js/app
+ - name: Validate bucket name
+ run: |
+ if [[ "${{ env.PREVIEW_BUCKET }}" != "macro-preview-assets-dev" ]]; then
+ echo "ERROR: PREVIEW_BUCKET must be 'macro-preview-assets-dev'"
+ exit 1
+ fi
+ - name: Deploy to S3
+ run: |
+ bun scripts/preview/deploy.ts \
+ --preview-id ${{ steps.preview-id.outputs.id }} \
+ --skip-build
+ working-directory: js/app
+ - name: Comment on PR
+ run: |
+ bun scripts/preview/post-comment.ts \
+ --pr ${{ github.event.pull_request.number }} \
+ --repo ${{ github.repository }} \
+ --token ${{ secrets.GITHUB_TOKEN }} \
+ --preview-id ${{ steps.preview-id.outputs.id }} \
+ --sha ${{ github.sha }}
+ working-directory: js/app
+concurrency:
+ group: preview-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.yml
index 71eb769392..fdb6663bef 100644
--- a/.github/workflows/web-app-check-main.yml
+++ b/.github/workflows/web-app-check-main.yml
@@ -52,36 +52,35 @@ jobs:
- path-check
if: needs.path-check.outputs.should_run == 'true' || needs.path-check.outputs.api_changed == 'true'
name: Typecheck
- runs-on: linux-extra-beefy
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
steps:
- name: Checkout Repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: bun,rust
+ path: |-
+ /home/runner/.cache/sccache
+ /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
- name: Setup Prereqs
uses: './.github/actions/setup-reqs-web'
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- sccache-bucket: ${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}
- - name: Cache Rust
- if: needs.path-check.outputs.api_changed == 'true'
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- with:
- workspaces: rust/cloud-storage
- shared-key: cloud-storage-gen-api
- cache-on-failure: 'true'
- cache-targets: 'true'
+ - name: Point sccache at the cache volume
+ run: |-
+ echo "SCCACHE_DIR=/home/runner/.cache/sccache" >> "$GITHUB_ENV"
+ echo "SCCACHE_CACHE_SIZE=20G" >> "$GITHUB_ENV"
- name: Generate API Types
if: needs.path-check.outputs.api_changed == 'true'
run: bun run gen-api -- --check
- env:
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID || secrets.AWS_ACCESS_KEY }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
working-directory: js/app
- name: show sccache stats
if: always() && needs.path-check.outputs.api_changed == 'true'
run: sccache --show-stats || true
- env:
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID || secrets.AWS_ACCESS_KEY }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Check Types
run: bun run --bun --silent tsc --project ./packages/app/tsconfig.json
working-directory: js/app
@@ -90,18 +89,24 @@ jobs:
- path-check
if: needs.path-check.outputs.should_run == 'true'
name: Biome Check
- runs-on: linux-latest-middy
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
steps:
- name: Checkout Repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
fetch-depth: '0'
+ - name: Mount /nix cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ path: /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
- name: Setup Nix dev shell
uses: './.github/actions/setup-cachix'
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
dev-shell: 'true'
- sccache-bucket: ${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}
- name: Run Biome
run: biome ci --changed --no-errors-on-unmatched --error-on-warnings
working-directory: js/app
@@ -110,17 +115,24 @@ jobs:
- path-check
if: needs.path-check.outputs.should_run == 'true'
name: Theme Hygiene Inspector
- runs-on: linux-latest-middy
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
steps:
- name: Checkout Repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
fetch-depth: '0'
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: bun
+ path: /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
- name: Setup Prereqs
uses: './.github/actions/setup-reqs-web'
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- sccache-bucket: ${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}
- name: Check Tailwind Classes
run: just check-tailwind
working-directory: js/app
@@ -129,15 +141,22 @@ jobs:
- path-check
if: needs.path-check.outputs.should_run == 'true'
name: Test
- runs-on: linux-latest-middy
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
steps:
- name: Checkout Repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: bun
+ path: /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
- name: Setup
uses: './.github/actions/setup-reqs-web'
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- sccache-bucket: ${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}
playwright: 'true'
- name: Test
run: bunx vitest
@@ -147,16 +166,22 @@ jobs:
- path-check
if: needs.path-check.outputs.should_run == 'true'
name: Cycles Import Check
- runs-on: linux-latest-middy
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Mount /nix cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ path: /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
- name: Setup Nix dev shell
uses: './.github/actions/setup-cachix'
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
dev-shell: 'true'
- sccache-bucket: ${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}
- name: Cycles Import Check
run: biome lint --changed --no-errors-on-unmatched --only=suspicious/noImportCycles
working-directory: js/app
@@ -165,15 +190,22 @@ jobs:
- path-check
if: needs.path-check.outputs.should_run == 'true'
name: Build
- runs-on: linux-latest-middy
+ runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
steps:
- name: Checkout Repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: bun
+ path: /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
- name: Setup
uses: './.github/actions/setup-reqs-web'
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- sccache-bucket: ${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}
- name: Build
run: bun run build
working-directory: js/app
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/deploy_preview.rs b/rust/cloud-storage/tools/xtask/src/workflows/deploy_preview.rs
new file mode 100644
index 0000000000..4ba2900775
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/src/workflows/deploy_preview.rs
@@ -0,0 +1,139 @@
+//! `Deploy Preview` — frontend feature-branch preview deployments.
+//! Generated into `deploy_preview.yml` (replaces the hand-written
+//! `deploy-preview.yml`; safe to rename since this is deliberately not a
+//! required status check).
+//!
+//! Deploys a preview build to `<branch>-<nanoid>-preview.macro.com`, built
+//! identically to dev.macro.com (MODE=development, points at dev services).
+//!
+//! NOTE: this workflow must NOT be added to required status checks — PRs
+//! should be mergeable regardless of preview deploy status.
+
+use gh_workflow::{
+ Concurrency, Env, Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType,
+ Run, Step, Use, Workflow,
+};
+
+use crate::workflows::{runners, steps, vars};
+
+const PREVIEW_BUCKET: &str = "macro-preview-assets-dev";
+
+/// Build the workflow.
+pub fn deploy_preview() -> Workflow {
+ Workflow::new("Deploy Preview")
+ .on(Event::default().pull_request(
+ PullRequest::default()
+ .add_type(PullRequestType::Opened)
+ .add_type(PullRequestType::Synchronize)
+ .add_path("js/app/**"),
+ ))
+ .concurrency(
+ Concurrency::new(Expression::new(
+ "preview-${{ github.event.pull_request.number }}",
+ ))
+ .cancel_in_progress(true),
+ )
+ .add_env(("PREVIEW_BUCKET", PREVIEW_BUCKET))
+ .add_job("deploy", deploy())
+}
+
+fn deploy() -> Job {
+ Job::default()
+ .runs_on(runners::Runner::Mid.with_cache_tag(vars::WEB_CI_CACHE_TAG))
+ .permissions(
+ Permissions::default()
+ .contents(Level::Read)
+ .pull_requests(Level::Write),
+ )
+ .add_step(checkout())
+ .add_step(steps::mount_web_cache_volume(false))
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_reqs_web("Setup", false))
+ .add_step(build())
+ .add_step(configure_aws_credentials())
+ .add_step(get_or_create_preview_id())
+ .add_step(validate_bucket_name())
+ .add_step(deploy_to_s3())
+ .add_step(comment_on_pr())
+}
+
+fn checkout() -> Step<Use> {
+ Step::new("Checkout Repo").uses(
+ "actions",
+ "checkout",
+ "df4cb1c069e1874edd31b4311f1884172cec0e10",
+ ) // v6
+}
+
+/// Build identical to the dev.macro.com deployment.
+fn build() -> Step<Run> {
+ Step::new("Build")
+ .run("just build-dev")
+ .working_directory("js/app")
+ .add_env(Env::new("VITE_DD_WEB_APP_TOKEN", vars::DD_WEB_APP_TOKEN))
+ .add_env(Env::new("VITE_DD_HASH", "${{ github.sha }}"))
+ .add_env(Env::new(
+ "VITE_SEGMENT_WRITE_KEY",
+ vars::SEGMENT_WRITE_KEY_PRODUCTION,
+ ))
+ .add_env(Env::new("VITE_POSTHOG_API_KEY", vars::POSTHOG_API_KEY))
+}
+
+fn configure_aws_credentials() -> Step<Use> {
+ Step::new("Configure AWS Credentials")
+ .uses(
+ "aws-actions",
+ "configure-aws-credentials",
+ "e7f100cf4c008499ea8adda475de1042d6975c7b",
+ ) // v5
+ .add_with(("aws-access-key-id", vars::AWS_ACCESS_KEY))
+ .add_with(("aws-secret-access-key", vars::AWS_SECRET_ACCESS_KEY))
+ .add_with(("aws-region", "us-east-1"))
+}
+
+fn get_or_create_preview_id() -> Step<Run> {
+ Step::new("Get or create preview ID")
+ .run(indoc::indoc! {r#"
+ PREVIEW_ID=$(bun scripts/preview/get-or-create-id.ts \
+ --pr ${{ github.event.pull_request.number }} \
+ --repo ${{ github.repository }} \
+ --token ${{ secrets.GITHUB_TOKEN }} \
+ --branch "${{ github.head_ref }}")
+ echo "id=$PREVIEW_ID" >> $GITHUB_OUTPUT
+ echo "Preview ID: $PREVIEW_ID"
+ "#})
+ .id("preview-id")
+ .working_directory("js/app")
+}
+
+fn validate_bucket_name() -> Step<Run> {
+ Step::new("Validate bucket name").run(indoc::indoc! {r#"
+ if [[ "${{ env.PREVIEW_BUCKET }}" != "macro-preview-assets-dev" ]]; then
+ echo "ERROR: PREVIEW_BUCKET must be 'macro-preview-assets-dev'"
+ exit 1
+ fi
+ "#})
+}
+
+fn deploy_to_s3() -> Step<Run> {
+ Step::new("Deploy to S3")
+ .run(indoc::indoc! {r#"
+ bun scripts/preview/deploy.ts \
+ --preview-id ${{ steps.preview-id.outputs.id }} \
+ --skip-build
+ "#})
+ .working_directory("js/app")
+}
+
+fn comment_on_pr() -> Step<Run> {
+ Step::new("Comment on PR")
+ .run(indoc::indoc! {r#"
+ bun scripts/preview/post-comment.ts \
+ --pr ${{ github.event.pull_request.number }} \
+ --repo ${{ github.repository }} \
+ --token ${{ secrets.GITHUB_TOKEN }} \
+ --preview-id ${{ steps.preview-id.outputs.id }} \
+ --sha ${{ github.sha }}
+ "#})
+ .working_directory("js/app")
+}
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs b/rust/cloud-storage/tools/xtask/src/workflows/mod.rs
index a629d0cf04..a7c69e26ef 100644
--- a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs
+++ b/rust/cloud-storage/tools/xtask/src/workflows/mod.rs
@@ -17,6 +17,7 @@ mod build_dmg_on_tag;
mod check_generated;
mod check_node_modules_nix;
mod code_check_cloud_storage;
+mod deploy_preview;
mod runners;
mod steps;
mod vars;
@@ -77,6 +78,11 @@ const WORKFLOWS: &[WorkflowFile] = &[
file_name: "code_check_cloud_storage.yml",
render_yaml: || render_gh_workflow(code_check_cloud_storage::code_check_cloud_storage)(),
},
+ WorkflowFile {
+ slug: "deploy_preview",
+ file_name: "deploy_preview.yml",
+ render_yaml: || render_gh_workflow(deploy_preview::deploy_preview)(),
+ },
WorkflowFile {
slug: "check_node_modules_nix",
file_name: "check_node_modules_nix.yml",
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/runners.rs b/rust/cloud-storage/tools/xtask/src/workflows/runners.rs
index dee2b1f8d7..aa65b108b7 100644
--- a/rust/cloud-storage/tools/xtask/src/workflows/runners.rs
+++ b/rust/cloud-storage/tools/xtask/src/workflows/runners.rs
@@ -16,6 +16,10 @@ pub enum Runner {
TinyNoCache,
/// Small profile for light jobs (path filtering, status aggregation).
Small,
+ /// Mid-size profile, shared with the deploy workflows. Its *default* cache
+ /// volume is churned by deploys, so always pair it with
+ /// [`Runner::with_cache_tag`] to give a workload its own volume.
+ Mid,
/// Dedicated CI profile for the heavy compile + test jobs. Has its own
/// cache volume, isolated from the deploy profiles so deploy's churn can't
/// evict the CI sccache/cargo caches.
@@ -27,6 +31,7 @@ impl fmt::Display for Runner {
f.write_str(match self {
Runner::TinyNoCache => "namespace-profile-linux-tiny-no-cache",
Runner::Small => "namespace-profile-linux-small",
+ Runner::Mid => "namespace-profile-linux-mid",
Runner::RustCi => "namespace-profile-linux-rust-ci",
})
}
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/steps.rs b/rust/cloud-storage/tools/xtask/src/workflows/steps.rs
index 4dfdc0f70a..58fa3772a6 100644
--- a/rust/cloud-storage/tools/xtask/src/workflows/steps.rs
+++ b/rust/cloud-storage/tools/xtask/src/workflows/steps.rs
@@ -109,6 +109,37 @@ pub fn pin_sccache_dir() -> Step<Run> {
))
}
+/// Mount the web-app cache volume: bun's install cache plus the Nix store
+/// (dev shell closure). `with_rust` additionally persists the cargo
+/// registry/git and the sccache dir for the `gen-api` OpenAPI-binary build.
+/// `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
+ )
+ .add_with(("cache", if with_rust { "bun,rust" } else { "bun" }))
+ .map(|step| {
+ if with_rust {
+ step.add_with(("path", format!("{}\n/nix", vars::SCCACHE_VOLUME_DIR)))
+ } else {
+ step.add_with(("path", "/nix"))
+ }
+ })
+ .continue_on_error(true)
+}
+
+/// The web-app composite: Nix dev shell (bun, biome, just) + `bun install`.
+/// We pass NO `sccache-bucket`, so the gen-api build's sccache stays on the
+/// cache volume. Requires [`setup_nix`] first.
+pub fn setup_reqs_web(name: &str, playwright: bool) -> Step<Use> {
+ uses_local(name, "./.github/actions/setup-reqs-web")
+ .add_with(("cachix-auth-token", vars::CACHIX_AUTH_TOKEN))
+ .when(playwright, |step| step.add_with(("playwright", "true")))
+}
+
/// `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/rust/cloud-storage/tools/xtask/src/workflows/vars.rs b/rust/cloud-storage/tools/xtask/src/workflows/vars.rs
index 3509a5f697..dd34e0c0b3 100644
--- a/rust/cloud-storage/tools/xtask/src/workflows/vars.rs
+++ b/rust/cloud-storage/tools/xtask/src/workflows/vars.rs
@@ -11,10 +11,15 @@ macro_rules! secret {
};
}
+secret!(AWS_ACCESS_KEY);
+secret!(AWS_SECRET_ACCESS_KEY);
secret!(CACHIX_AUTH_TOKEN);
+secret!(DD_WEB_APP_TOKEN);
secret!(DOPPLER_TOKEN);
secret!(MACOS_DEVELOPER_ID_CERTIFICATE_BASE64);
secret!(MACOS_DEVELOPER_ID_CERTIFICATE_PASSWORD);
+secret!(POSTHOG_API_KEY);
+secret!(SEGMENT_WRITE_KEY_PRODUCTION);
/// Nextest thread count for the test job. Tuned for the previous
/// `linux-extra-beefy` runner; revisit if `namespace-profile-linux-mid` is
@@ -26,6 +31,13 @@ pub const NEXTEST_TEST_THREADS: u32 = 32;
/// global across all branches — see [`crate::workflows::runners::Runner::with_cache_tag`].
pub const CI_CACHE_TAG: &str = "sccache-ci";
+/// Namespace cache tag for the web-app jobs (PR checks + preview deploys).
+/// Cache volumes are keyed workspace-wide by tag alone, so a dedicated tag
+/// gives the frontend its own volume — isolated both from the Rust CI volume
+/// ([`CI_CACHE_TAG`]) and from the deploy workflows' heavily-churned default
+/// `linux-mid` volume.
+pub const WEB_CI_CACHE_TAG: &str = "web-ci";
+
/// Directory sccache uses for its local-disk cache. Lives on the Namespace cache
/// volume so it persists across runs — this is what replaces the S3 bucket.
pub const SCCACHE_VOLUME_DIR: &str = "/home/runner/.cache/sccache";
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/web_app_check_main.rs b/rust/cloud-storage/tools/xtask/src/workflows/web_app_check_main.rs
index e26528e86f..0728326c46 100644
--- a/rust/cloud-storage/tools/xtask/src/workflows/web_app_check_main.rs
+++ b/rust/cloud-storage/tools/xtask/src/workflows/web_app_check_main.rs
@@ -2,8 +2,7 @@
//! Generated into `web-app-check-main.yml`.
use gh_workflow::{
- Concurrency, Env, Event, Expression, Job, PullRequest, PullRequestType, Run, Step, Use,
- Workflow,
+ Concurrency, Event, Expression, Job, PullRequest, PullRequestType, Run, Step, Use, Workflow,
};
use crate::workflows::{
@@ -12,11 +11,12 @@ use crate::workflows::{
vars,
};
-const WEB_TYPESCRIPT_RUNNER: &str = "linux-extra-beefy";
-const WEB_DEFAULT_RUNNER: &str = "linux-latest-middy";
-const SCCACHE_BUCKET: &str = "${{ vars.SCCACHE_BUCKET || secrets.SCCACHE_BUCKET }}";
-const AWS_ACCESS_KEY_ID: &str = "${{ secrets.AWS_ACCESS_KEY_ID || secrets.AWS_ACCESS_KEY }}";
-const AWS_SECRET_ACCESS_KEY: &str = "${{ secrets.AWS_SECRET_ACCESS_KEY }}";
+/// All the real web jobs share one mid-size Namespace profile with a dedicated
+/// cache tag, so the frontend caches (Nix store, bun cache, gen-api sccache)
+/// live on their own volume — see [`vars::WEB_CI_CACHE_TAG`].
+fn web_runner() -> String {
+ runners::Runner::Mid.with_cache_tag(vars::WEB_CI_CACHE_TAG)
+}
/// Build the workflow.
pub fn web_app_check_main() -> Workflow {
@@ -61,10 +61,12 @@ fn typescript() -> Job {
"needs.path-check.outputs.should_run == 'true' || needs.path-check.outputs.api_changed == 'true'",
))
.name("Typecheck")
- .runs_on(WEB_TYPESCRIPT_RUNNER)
+ .runs_on(web_runner())
.add_step(checkout("Checkout Repo", false))
- .add_step(setup_reqs_web("Setup Prereqs", false))
- .add_step(rust_cache())
+ .add_step(steps::mount_web_cache_volume(true))
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_reqs_web("Setup Prereqs", false))
+ .add_step(steps::pin_sccache_dir())
.add_step(generate_api_types())
.add_step(show_sccache_stats())
.add_step(check_types())
@@ -73,35 +75,45 @@ fn typescript() -> Job {
fn biome_check() -> Job {
gated_web_job("Biome Check")
.add_step(checkout("Checkout Repo", true))
- .add_step(setup_cachix_dev_shell())
+ .add_step(steps::mount_nix_cache_volume())
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_dev_shell())
.add_step(run_biome())
}
fn tailwind() -> Job {
gated_web_job("Theme Hygiene Inspector")
.add_step(checkout("Checkout Repo", true))
- .add_step(setup_reqs_web("Setup Prereqs", false))
+ .add_step(steps::mount_web_cache_volume(false))
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_reqs_web("Setup Prereqs", false))
.add_step(check_tailwind_classes())
}
fn test() -> Job {
gated_web_job("Test")
.add_step(checkout("Checkout Repo", false))
- .add_step(setup_reqs_web("Setup", true))
+ .add_step(steps::mount_web_cache_volume(false))
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_reqs_web("Setup", true))
.add_step(run_tests())
}
fn cycles() -> Job {
gated_web_job("Cycles Import Check")
.add_step(checkout("Checkout", false))
- .add_step(setup_cachix_dev_shell())
+ .add_step(steps::mount_nix_cache_volume())
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_dev_shell())
.add_step(cycles_import_check())
}
fn build() -> Job {
gated_web_job("Build")
.add_step(checkout("Checkout Repo", false))
- .add_step(setup_reqs_web("Setup", false))
+ .add_step(steps::mount_web_cache_volume(false))
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_reqs_web("Setup", false))
.add_step(run_build())
}
@@ -131,7 +143,7 @@ fn gated_web_job(name: &str) -> Job {
"needs.path-check.outputs.should_run == 'true'",
))
.name(name)
- .runs_on(WEB_DEFAULT_RUNNER)
+ .runs_on(web_runner())
}
fn checkout(name: &str, full_history: bool) -> Step<Use> {
@@ -182,60 +194,21 @@ fn paths_filter() -> Step<Use> {
))
}
-fn setup_reqs_web(name: &str, playwright: bool) -> Step<Use> {
- steps::uses_local(name, "./.github/actions/setup-reqs-web")
- .add_with(("cachix-auth-token", vars::CACHIX_AUTH_TOKEN))
- .add_with(("sccache-bucket", SCCACHE_BUCKET))
- .when(playwright, |step| step.add_with(("playwright", "true")))
-}
-
-fn setup_cachix_dev_shell() -> Step<Use> {
- steps::uses_local("Setup Nix dev shell", "./.github/actions/setup-cachix")
- .add_with(("cachix-auth-token", vars::CACHIX_AUTH_TOKEN))
- .add_with(("dev-shell", "true"))
- .add_with(("sccache-bucket", SCCACHE_BUCKET))
-}
-
-fn rust_cache() -> Step<Use> {
- Step::new("Cache Rust")
- .uses(
- "Swatinem",
- "rust-cache",
- "9d47c6ad4b02e050fd481d890b2ea34778fd09d6",
- )
+fn generate_api_types() -> Step<Run> {
+ Step::new("Generate API Types")
+ .run("bun run gen-api -- --check")
.if_condition(Expression::new(
"needs.path-check.outputs.api_changed == 'true'",
))
- .add_with(("workspaces", "rust/cloud-storage"))
- .add_with(("shared-key", "cloud-storage-gen-api"))
- .add_with(("cache-on-failure", "true"))
- .add_with(("cache-targets", "true"))
-}
-
-fn generate_api_types() -> Step<Run> {
- with_aws_env(
- Step::new("Generate API Types")
- .run("bun run gen-api -- --check")
- .if_condition(Expression::new(
- "needs.path-check.outputs.api_changed == 'true'",
- ))
- .working_directory("js/app"),
- )
+ .working_directory("js/app")
}
fn show_sccache_stats() -> Step<Run> {
- with_aws_env(
- Step::new("show sccache stats")
- .run("sccache --show-stats || true")
- .if_condition(Expression::new(
- "always() && needs.path-check.outputs.api_changed == 'true'",
- )),
- )
-}
-
-fn with_aws_env(step: Step<Run>) -> Step<Run> {
- step.add_env(Env::new("AWS_ACCESS_KEY_ID", AWS_ACCESS_KEY_ID))
- .add_env(Env::new("AWS_SECRET_ACCESS_KEY", AWS_SECRET_ACCESS_KEY))
+ Step::new("show sccache stats")
+ .run("sccache --show-stats || true")
+ .if_condition(Expression::new(
+ "always() && needs.path-check.outputs.api_changed == 'true'",
+ ))
}
fn check_types() -> Step<Run> {