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(web): get the web PR checks under five minutes (#9718)
teo709ada68b349
diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.ymlindex e7c9a09002..e622e88f27 100644--- a/.github/workflows/code_check_cloud_storage.yml+++ b/.github/workflows/code_check_cloud_storage.yml@@ -910,9 +910,9 @@ jobs:# 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.+ # Nothing in this build carries debug info: the job sets CARGO_PROFILE_*_DEBUG=0 for+ # workspace crates, and this flag covers dependencies. Panic messages keep their+ # file and line; backtrace frames keep function names only.common=(--config 'profile.dev.package."*".debug=false'--all-features --no-tests=passdiff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.ymldeleted file mode 100644index 9e302925c0..0000000000--- a/.github/workflows/deploy_preview.yml+++ /dev/null@@ -1,140 +0,0 @@-# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).-# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs-name: Deploy Preview-env:- PREVIEW_BUCKET: macro-preview-assets-dev-'on':- pull_request:- types:- - opened- - synchronize- paths:- - package.json- - bun.lock- - apps/web/**- - packages/**- - crates/folds/agent_fold/**- - crates/agent_runtime_protocol/**- - crates/client/cache-core/**- - crates/client/cache-turso/**- - crates/client/cache-wasm/**- - crates/client/turso-opfs/**- - crates/database_sql/**- - crates/filter_ast/**- - crates/item_filters/**- - static_assets/schema.graphql- - Cargo.toml- - Cargo.lock- - rust-toolchain.toml-jobs:- deploy:- if: '!contains(github.event.pull_request.title, ''[no preview]'')'- 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: nix- 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"- # 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- 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:- 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: apps/web- - 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: apps/web- - 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: apps/web- - name: Teardown Nix- if: always()- uses: './.github/actions/teardown-nix'-concurrency:- group: preview-${{ github.event.pull_request.number }}- cancel-in-progress: truediff --git a/.github/workflows/export-ci-telemetry.yml b/.github/workflows/export-ci-telemetry.ymlindex c717571810..66da19d4c9 100644--- a/.github/workflows/export-ci-telemetry.yml+++ b/.github/workflows/export-ci-telemetry.yml@@ -21,7 +21,6 @@ name: Export CI telemetry- Deploy CLA Worker- Deploy FusionAuth Instance- Deploy Lexical Service- - Deploy Preview- Deploy Production Release- Deploy Service (Generic)- Deploy Sync Servicediff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.ymlindex f9ec4fa6e7..2880196886 100644--- a/.github/workflows/web-app-check-main.yml+++ b/.github/workflows/web-app-check-main.yml@@ -16,6 +16,7 @@ jobs:outputs:should_run: ${{ steps.filter.outputs.should_run }}codegen_changed: ${{ steps.filter.outputs.codegen_changed }}+ web_artifact_changed: ${{ steps.filter.outputs.web_artifact_changed }}i18n_changed: ${{ steps.filter.outputs.i18n_changed }}database_grid_changed: ${{ steps.filter.outputs.database_grid_changed }}calendar_details_changed: ${{ steps.filter.outputs.calendar_details_changed }}@@ -52,6 +53,24 @@ jobs:- 'packages/code-mode-sdk/**'- 'crates/agent_code_mode/SKILL.md'- '.github/actions/setup-reqs-web/**'+ web_artifact_changed:+ - 'package.json'+ - 'bun.lock'+ - 'apps/web/**'+ - 'packages/**'+ - 'crates/folds/agent_fold/**'+ - 'crates/agent_runtime_protocol/**'+ - 'crates/client/cache-core/**'+ - 'crates/client/cache-turso/**'+ - 'crates/client/cache-wasm/**'+ - 'crates/client/turso-opfs/**'+ - 'crates/database_sql/**'+ - 'crates/filter_ast/**'+ - 'crates/item_filters/**'+ - 'static_assets/schema.graphql'+ - 'Cargo.toml'+ - 'Cargo.lock'+ - 'rust-toolchain.toml'codegen_changed:- 'crates/**/*.rs'- 'services/**/*.rs'@@ -301,7 +320,7 @@ jobs:- name: Check Floating Promisesrun: bun run lint:oxlint --quiet- name: Check Functional Test Types- run: bun run --bun --silent tsc --project tests/functional/tsconfig.json+ run: bun ../../node_modules/typescript-native/bin/tsc --noEmit --skipLibCheck --project tests/functional/tsconfig.jsonworking-directory: apps/web- name: Check Collaboration Package Typesrun: bun run type-check@@ -514,8 +533,15 @@ jobs:needs:- path-checkif: needs.path-check.outputs.should_run == 'true'- name: Test+ name: Test (${{ matrix.shard }}/3)runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci+ strategy:+ matrix:+ shard:+ - 1+ - 2+ - 3+ fail-fast: falsesteps:- name: Checkout Repouses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10@@ -525,23 +551,212 @@ jobs:cache: nixpath: |-/home/runner/.bun/install/cache+ /home/runner/.cargo/registry+ /home/runner/.cargo/git+ /home/runner/.cache/.wasm-pack/home/runner/.cache/vitest-modules+ /home/runner/.cache/wasm-pkgscontinue-on-error: true- name: Setup Nixuses: './.github/actions/setup-nix'- name: Setupuses: './.github/actions/setup-reqs-web'- with:- playwright: 'true'+ - 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"+ # 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+ else+ echo "::warning::Namespace remote sccache setup failed; using local cache fallback"+ fi- name: Build agent-fold WASM for testsrun: just build-agent-fold-wasm+ env:+ WASM_PKG_CACHE_DIR: /home/runner/.cache/wasm-pkgstimeout-minutes: 15working-directory: apps/web- name: Test- run: bun run test+ run: bun run test --shard=${{ matrix.shard }}/3env:VITEST_MODULE_CACHE_DIR: /home/runner/.cache/vitest-modulesworking-directory: apps/web+ - name: Teardown Nix+ if: always()+ uses: './.github/actions/teardown-nix'+ functional:+ needs:+ - path-check+ if: needs.path-check.outputs.should_run == 'true'+ name: Functional Tests+ 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: nix+ path: |-+ /home/runner/.bun/install/cache+ /home/runner/.cargo/registry+ /home/runner/.cargo/git+ /home/runner/.cache/.wasm-pack+ /home/runner/.cache/wasm-pkgs+ continue-on-error: true+ - name: Setup Nix+ uses: './.github/actions/setup-nix'+ - name: Setup+ uses: './.github/actions/setup-reqs-web'+ with:+ playwright: 'true'+ - 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"+ # 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+ else+ echo "::warning::Namespace remote sccache setup failed; using local cache fallback"+ fi+ - name: Start sccache server+ run: sccache --start-server+ - name: Build wasm packages+ run: just build-wasm+ env:+ CARGO_PROFILE_FIG_ENGINE_WASM_LTO: 'off'+ CARGO_PROFILE_FIG_ENGINE_WASM_CODEGEN_UNITS: '16'+ CARGO_PROFILE_PSD_ENGINE_WASM_LTO: 'off'+ CARGO_PROFILE_PSD_ENGINE_WASM_CODEGEN_UNITS: '16'+ CARGO_PROFILE_AI_ENGINE_WASM_LTO: 'off'+ CARGO_PROFILE_AI_ENGINE_WASM_CODEGEN_UNITS: '16'+ WASM_PKG_CACHE_DIR: /home/runner/.cache/wasm-pkgs+ working-directory: apps/web+ - name: Functional Browser Tests+ run: bun run test:functional+ env:+ FUNCTIONAL_TEST_WORKERS: '8'+ 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'+ browser:+ needs:+ - path-check+ if: needs.path-check.outputs.should_run == 'true'+ name: Browser Tests+ 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: nix+ path: |-+ /home/runner/.bun/install/cache+ /home/runner/.cargo/registry+ /home/runner/.cargo/git+ /home/runner/.cache/.wasm-pack+ /home/runner/.cache/vitest-modules+ /home/runner/.cache/wasm-pkgs+ continue-on-error: true+ - name: Setup Nix+ uses: './.github/actions/setup-nix'+ - name: Setup+ uses: './.github/actions/setup-reqs-web'+ with:+ playwright: 'true'+ - 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"+ # 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+ else+ echo "::warning::Namespace remote sccache setup failed; using local cache fallback"+ fi+ - name: Build agent-fold WASM for tests+ run: just build-agent-fold-wasm+ env:+ WASM_PKG_CACHE_DIR: /home/runner/.cache/wasm-pkgs+ timeout-minutes: 15+ working-directory: apps/web- name: Sign-up Browser Testsrun: just test-signup-browserworking-directory: apps/web@@ -599,6 +814,9 @@ jobs:if: needs.path-check.outputs.should_run == 'true'name: Buildruns-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci+ permissions:+ contents: read+ pull-requests: writesteps:- name: Checkout Repouses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10@@ -617,8 +835,6 @@ jobs:uses: './.github/actions/setup-nix'- name: Setupuses: './.github/actions/setup-reqs-web'- with:- playwright: 'true'- name: Configure Namespace remote sccacheif: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.event.pull_request.head.repo.full_name == github.repositoryrun: |-@@ -657,14 +873,78 @@ jobs:- name: Buildrun: just build-devenv:+ CARGO_PROFILE_FIG_ENGINE_WASM_LTO: 'off'+ CARGO_PROFILE_FIG_ENGINE_WASM_CODEGEN_UNITS: '16'+ CARGO_PROFILE_PSD_ENGINE_WASM_LTO: 'off'+ CARGO_PROFILE_PSD_ENGINE_WASM_CODEGEN_UNITS: '16'+ CARGO_PROFILE_AI_ENGINE_WASM_LTO: 'off'+ CARGO_PROFILE_AI_ENGINE_WASM_CODEGEN_UNITS: '16'WASM_PKG_CACHE_DIR: /home/runner/.cache/wasm-pkgs- working-directory: apps/web- - name: Test Optimistic Mutations in Chromium- run: bun run test:functional+ VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}+ VITE_POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}working-directory: apps/web- name: show sccache statsif: always()run: sccache --show-stats || true+ - id: preview-credentials+ name: Configure AWS Credentials+ if: needs.path-check.outputs.web_artifact_changed == 'true' && !contains(github.event.pull_request.title, '[no preview]') && github.event.pull_request.head.repo.full_name == github.repository+ 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+ continue-on-error: true+ - id: preview-id+ name: Get or create preview ID+ if: needs.path-check.outputs.web_artifact_changed == 'true' && !contains(github.event.pull_request.title, '[no preview]') && github.event.pull_request.head.repo.full_name == github.repository && steps.preview-credentials.outcome == 'success'+ 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"+ env:+ PREVIEW_BUCKET: macro-preview-assets-dev+ continue-on-error: true+ working-directory: apps/web+ - id: preview-bucket+ name: Validate bucket name+ if: needs.path-check.outputs.web_artifact_changed == 'true' && !contains(github.event.pull_request.title, '[no preview]') && github.event.pull_request.head.repo.full_name == github.repository && steps.preview-id.outcome == 'success'+ run: |+ if [[ "${{ env.PREVIEW_BUCKET }}" != "macro-preview-assets-dev" ]]; then+ echo "ERROR: PREVIEW_BUCKET must be 'macro-preview-assets-dev'"+ exit 1+ fi+ env:+ PREVIEW_BUCKET: macro-preview-assets-dev+ continue-on-error: true+ - id: preview-deploy+ name: Deploy to S3+ if: needs.path-check.outputs.web_artifact_changed == 'true' && !contains(github.event.pull_request.title, '[no preview]') && github.event.pull_request.head.repo.full_name == github.repository && steps.preview-bucket.outcome == 'success'+ run: |+ bun scripts/preview/deploy.ts \+ --preview-id ${{ steps.preview-id.outputs.id }} \+ --skip-build+ env:+ PREVIEW_BUCKET: macro-preview-assets-dev+ continue-on-error: true+ working-directory: apps/web+ - name: Comment on PR+ if: needs.path-check.outputs.web_artifact_changed == 'true' && !contains(github.event.pull_request.title, '[no preview]') && github.event.pull_request.head.repo.full_name == github.repository && steps.preview-deploy.outcome == 'success'+ 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 }}+ env:+ PREVIEW_BUCKET: macro-preview-assets-dev+ continue-on-error: true+ working-directory: apps/web- name: Teardown Nixif: always()uses: './.github/actions/teardown-nix'@@ -1042,6 +1322,8 @@ jobs:- generated-code- biome-check- test+ - functional+ - browser- cycles- build- ios-native-check@@ -1057,6 +1339,8 @@ jobs:echo "generated-code: ${{ needs.generated-code.result }}"echo "biome-check: ${{ needs.biome-check.result }}"echo "test: ${{ needs.test.result }}"+ echo "functional: ${{ needs.functional.result }}"+ echo "browser: ${{ needs.browser.result }}"echo "cycles: ${{ needs.cycles.result }}"echo "build: ${{ needs.build.result }}"echo "ios-native-check: ${{ needs.ios-native-check.result }}"@@ -1071,6 +1355,8 @@ jobs:[[ "${{ needs.generated-code.result }}" == "cancelled" ]] || \[[ "${{ needs.biome-check.result }}" == "failure" ]] || \[[ "${{ needs.test.result }}" == "failure" ]] || \+ [[ "${{ needs.functional.result }}" == "failure" ]] || \+ [[ "${{ needs.browser.result }}" == "failure" ]] || \[[ "${{ needs.cycles.result }}" == "failure" ]] || \[[ "${{ needs.build.result }}" == "failure" ]] || \[[ "${{ needs.ios-native-check.result }}" == "failure" ]] || \diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 9d85fd30b9..7616ceed9c 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -25,6 +25,13 @@## Verifying a change in a real browser+`just test-functional` builds a production-like bundle of its fixtures and runs+Playwright against it, not a dev server: each page otherwise fetches thousands of+modules through the test's own routes, which limits how many tests can run at+once. A fixture that depends on dev-only behavior won't work there. CI sets+`FUNCTIONAL_TEST_WORKERS` and retries a failed test once; locally it defaults to+one worker and no retries.+ID-only user mention rendering, name lookup failure, and composer save/reopenare covered on desktop/tablet/phone by `user-mentions.browser.e2e.ts` in theLexicalMarkdown core browser suite (see its README).diff --git a/apps/web/tests/functional/playwright.config.ts b/apps/web/tests/functional/playwright.config.tsindex 00ce1a111f..9586afad0d 100644--- a/apps/web/tests/functional/playwright.config.ts+++ b/apps/web/tests/functional/playwright.config.ts@@ -8,7 +8,12 @@ export default defineConfig({testMatch: '*.spec.ts',timeout: 60_000,expect: { timeout: 10_000 },- workers: 1,+ fullyParallel: true,+ // Under CPU pressure about 0.3% of these tests miss a deadline (seen at both 4+ // and 8 workers on 8 CPUs), which fails about one full run in five. A retried+ // test still shows as flaky in the output.+ retries: process.env.CI ? 1 : 0,+ workers: Number(process.env.FUNCTIONAL_TEST_WORKERS ?? 1),forbidOnly: !!process.env.CI,reporter: 'list',use: {@@ -22,11 +27,13 @@ export default defineConfig({webServer: {cwd: fileURLToPath(new URL('../../', import.meta.url)),command:- 'just ensure-cache-wasm && bunx --bun vite --config tests/functional/vite.config.ts',+ 'just ensure-cache-wasm && bunx --bun vite build --config tests/functional/vite.config.ts && bunx --bun vite preview --config tests/functional/vite.config.ts',url: `http://127.0.0.1:${port}/tests/functional/optimistic-mutations/index.html`,reuseExistingServer: false,- timeout: 180_000,+ timeout: 240_000,env: {+ MODE: 'development',+ NODE_ENV: 'production',FUNCTIONAL_TEST_PORT: String(port),MACRO_DEV_HTTPS: 'false',VITE_LOCAL_SERVERS: 'ALL',diff --git a/apps/web/tests/functional/vite.config.ts b/apps/web/tests/functional/vite.config.tsindex 9f8069d851..f38eeaff2e 100644--- a/apps/web/tests/functional/vite.config.ts+++ b/apps/web/tests/functional/vite.config.ts@@ -1,13 +1,66 @@-import { defineConfig } from 'vite';+import { resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { defineConfig, type PluginOption } from 'vite';import { createAppViteConfig } from '../../vite.base';-export default defineConfig((environment) => ({- ...createAppViteConfig()(environment),- cacheDir: 'node_modules/.vite-functional',- server: {- host: '127.0.0.1',- port: Number(process.env.FUNCTIONAL_TEST_PORT ?? 4191),- strictPort: true,- hmr: false,- },-}));+const directory = fileURLToPath(new URL('.', import.meta.url));+const port = Number(process.env.FUNCTIONAL_TEST_PORT ?? 4191);++/** This bundle ships nowhere, so the production size limits don't apply. */+const SHIPPING_CHECKS = [+ 'posthog-source-map-limit',+ 'cloudfront-compression-limit',+];+const withoutShippingChecks = (plugins: PluginOption[] = []) =>+ plugins+ .flat()+ .filter(+ (plugin) =>+ !(+ plugin &&+ typeof plugin === 'object' &&+ 'name' in plugin &&+ SHIPPING_CHECKS.includes(plugin.name)+ )+ );++export default defineConfig(async (environment) => {+ const app = await createAppViteConfig()(environment);+ return {+ ...app,+ base: '/',+ plugins: withoutShippingChecks(app.plugins),+ worker: {+ ...app.worker,+ plugins: () => withoutShippingChecks(app.worker?.plugins?.()),+ },+ cacheDir: 'node_modules/.vite-functional',+ build: {+ ...app.build,+ // node_modules keeps the bundle out of git, tsc and Biome.+ outDir: resolve(directory, '../../node_modules/.functional-dist'),+ minify: false,+ sourcemap: false,+ rollupOptions: {+ input: {+ optimisticMutations: resolve(+ directory,+ 'optimistic-mutations/index.html'+ ),+ whatsappLinked: resolve(directory, 'whatsapp-linked/index.html'),+ },+ },+ },+ server: {+ host: '127.0.0.1',+ port,+ strictPort: true,+ hmr: false,+ },+ preview: {+ host: '127.0.0.1',+ port,+ strictPort: true,+ },+ };+});diff --git a/packages/email-renderer/src/browser/colors.adversarial.test.ts b/packages/email-renderer/src/browser/colors.adversarial.test.tsindex 495d6b8421..19212d04cc 100644--- a/packages/email-renderer/src/browser/colors.adversarial.test.ts+++ b/packages/email-renderer/src/browser/colors.adversarial.test.ts@@ -435,5 +435,6 @@ describe('computeTextNodeColor caching is equivalent to main', () => {spy.mockRestore();attr.mockRestore();}- });+ // Usually under 2 s, but over 5 s on a busy CI runner.+ }, 20_000);});diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows.rs b/tooling/xtask/crates/xtask_workflows/src/workflows.rsindex 67e775536f..0053fc0d5f 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows.rs@@ -37,7 +37,6 @@ mod deploy_all_services;mod deploy_cla_worker;mod deploy_fusionauth_instance;mod deploy_on_push;-mod deploy_preview;mod deploy_sdk_docs;mod deploy_sync_service;mod deploy_web_app;@@ -261,11 +260,6 @@ const WORKFLOWS: &[WorkflowFile] = &[)},},- WorkflowFile {- slug: "deploy_preview",- 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",diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/cleanup_preview.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/cleanup_preview.rsindex 5ab7046cfe..28e4651c42 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/cleanup_preview.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/cleanup_preview.rs@@ -1,5 +1,5 @@//! `Cleanup Preview` — removes a PR's preview files from S3 when the PR-//! closes (companion to `deploy_preview`). Generated into+//! closes (companion to the web `Build` job's preview steps). Generated into//! `cleanup_preview.yml` (replaces the hand-written `cleanup-preview.yml`).use gh_workflow::{diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rsdeleted file mode 100644index 803ab7dfb2..0000000000--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs+++ /dev/null@@ -1,152 +0,0 @@-//! `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.-//! A `[no preview]` marker in the PR title opts out without skipping CI.--use gh_workflow::{- Concurrency, Env, Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType,- Run, Step, Use, 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.-pub fn deploy_preview() -> Workflow {- Workflow::new("Deploy Preview")- .on(Event::default().pull_request(pull_request_event()))- .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 pull_request_event() -> PullRequest {- WEB_ARTIFACT_PATHS.iter().copied().fold(- PullRequest::default()- .add_type(PullRequestType::Opened)- .add_type(PullRequestType::Synchronize),- PullRequest::add_path,- )-}--fn deploy() -> Job {- Job::default()- .cond(Expression::new(- "!contains(github.event.pull_request.title, '[no preview]')",- ))- .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_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())- .add_step(deploy_to_s3())- .add_step(comment_on_pr())- .add_step(steps::teardown_nix())-}--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(xtask_paths::repo_dir!("apps/web"))- .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(xtask_paths::repo_dir!("apps/web"))-}--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(xtask_paths::repo_dir!("apps/web"))-}--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(xtask_paths::repo_dir!("apps/web"))-}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.rsdeleted file mode 100644index 1991b87b38..0000000000--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_preview/test.rs+++ /dev/null@@ -1,36 +0,0 @@-use super::*;--#[test]-fn preview_can_be_disabled_in_the_pull_request_title() {- let workflow = serde_json::to_value(deploy_preview()).expect("workflow JSON");- assert_eq!(- workflow["jobs"]["deploy"]["if"],- "!contains(github.event.pull_request.title, '[no preview]')"- );-}--#[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/export_ci_telemetry.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/export_ci_telemetry.rsindex 253d4073ae..ccbd4f884e 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/export_ci_telemetry.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/export_ci_telemetry.rs@@ -21,7 +21,6 @@ const OBSERVED_WORKFLOWS: &[&str] = &["Deploy CLA Worker","Deploy FusionAuth Instance","Deploy Lexical Service",- "Deploy Preview","Deploy Production Release","Deploy Service (Generic)","Deploy Sync Service",diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rsindex 687323c1fb..80448ebfc0 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rs@@ -11,7 +11,7 @@//! as an artifact; the iOS build has never run in CI, so that is the cheap way//! to iterate on it without a PR or an API token.//!-//! NOTE: like `deploy_preview`, this must NOT be a required status check — a+//! NOTE: like the web preview steps, this must NOT be a required status check — a//! PR should stay mergeable regardless of whether its preview built.use gh_workflow::{diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/runners.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/runners.rsindex ff34259957..e418af4453 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/runners.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/runners.rs@@ -55,15 +55,15 @@ impl fmt::Display for Runner {}impl Runner {- /// Render the `runs-on` label with an explicit, branch-independent cache- /// *tag* (`<profile>;overrides.cache-tag=<tag>`).+ /// Render the `runs-on` label with an explicit cache *tag*+ /// (`<profile>;overrides.cache-tag=<tag>`), for a volume apart from the+ /// profile's default one.///- /// By default Namespace scopes a profile's cache volume per branch: a fresh- /// branch can only inherit the *default* branch's cache, so any branch whose- /// workflow never runs on `main` starts cold every time. Pinning a fixed tag- /// makes every branch read/write the *same* volume — one global cache, like- /// the old globally shared cache behavior. Cache-volume writes are managed- /// by Namespace; compiled objects use the separately named remote sccache.+ /// Every job on a tag forks the newest generation its node holds, and the+ /// last job to finish cleanly on that node replaces it, with no merge. Keep+ /// jobs that read back what they wrote apart from jobs that would overwrite+ /// it. A new tag starts empty, so its first jobs fetch the whole Nix store.+ /// Compiled objects use the separately named remote sccache.pub fn with_cache_tag(self, tag: &str) -> String {format!("{self};overrides.cache-tag={tag}")}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rsindex 37925719bd..95655ca699 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs@@ -382,9 +382,11 @@ pub fn mount_web_test_cache_volume() -> Step<Use> {.add_with(("path",format!(- "{}\n{}",+ "{}\n/home/runner/.cargo/registry\n/home/runner/.cargo/git\n{}\n{}\n{}",vars::BUN_CACHE_VOLUME_DIR,+ xtask_paths::runtime_path!("/home/runner/.cache/.wasm-pack").as_str(),vars::VITEST_MODULE_CACHE_VOLUME_DIR,+ vars::WASM_PKG_CACHE_DIR,),))}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rsindex 5177257957..7861be5867 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs@@ -58,8 +58,7 @@ pub const DEV_SHELL_TIMEOUT_MINUTES: u32 = 15;pub const NEXTEST_TEST_THREADS: u32 = 32;/// Explicit Namespace cache-volume tag for the heavy compile jobs (check +-/// test). A fixed tag (instead of the default per-branch scoping) makes the-/// Cargo/Nix volume global across all branches — see+/// test), apart from the profile's default volume — see/// [`crate::workflows::runners::Runner::with_cache_tag`]. The legacy tag name is/// retained so the existing warm volume is not invalidated.pub const CI_CACHE_TAG: &str = "sccache-ci";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.rsindex 9422c80f5e..4fcd9fcac9 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@@ -2,7 +2,8 @@//! Generated into `web-app-check-main.yml`.use gh_workflow::{- Concurrency, Event, Expression, Job, PullRequest, PullRequestType, Run, Step, Use, Workflow,+ Concurrency, Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType, Run,+ Step, Strategy, Use, Workflow,};use crate::workflows::{@@ -13,6 +14,7 @@ use crate::workflows::{mod android_native_check;mod ios_native_check;+mod preview;#[cfg(test)]mod test;@@ -54,6 +56,8 @@ pub fn web_app_check_main() -> Workflow {.add_job("generated-code", generated_code()).add_job("biome-check", biome_check()).add_job("test", test())+ .add_job("functional", functional())+ .add_job("browser", browser()).add_job("cycles", cycles()).add_job("build", build()).add_job(ios_native_check::JOB_ID, ios_native_check::job())@@ -74,6 +78,10 @@ fn path_check() -> Job {"codegen_changed","${{ steps.filter.outputs.codegen_changed }}",)+ .add_output(+ "web_artifact_changed",+ "${{ steps.filter.outputs.web_artifact_changed }}",+ ).add_output("i18n_changed", "${{ steps.filter.outputs.i18n_changed }}").add_output("database_grid_changed",@@ -199,14 +207,52 @@ fn biome_check() -> Job {}fn test() -> Job {- gated_web_job("Test")+ gated_web_job("Test (${{ matrix.shard }}/3)").runs_on(mid_web_runner())+ .strategy(+ Strategy::default()+ .fail_fast(false)+ .matrix(serde_json::json!({ "shard": [1, 2, 3] })),+ ).add_step(checkout("Checkout Repo", false)).add_step(steps::mount_web_test_cache_volume()).add_step(steps::setup_nix())- .add_step(steps::setup_reqs_web("Setup", true))+ .add_step(steps::setup_reqs_web("Setup", false))+ .add_step(steps::configure_namespace_sccache(vars::WEB_SCCACHE_NAME)).add_step(build_agent_fold_for_tests()).add_step(run_tests())+ .add_step(steps::teardown_nix())+}++/// The functional suite bundles fixtures that import every wasm package, so this+/// job restores or builds them; unchanged packages come from the shared cache.+fn functional() -> Job {+ gated_web_job("Functional Tests")+ .runs_on(mid_web_runner())+ .add_step(checkout("Checkout Repo", false))+ .add_step(steps::mount_web_build_check_cache_volume())+ .add_step(steps::setup_nix())+ .add_step(steps::setup_reqs_web("Setup", true))+ .add_step(steps::configure_namespace_sccache(vars::WEB_SCCACHE_NAME))+ .add_step(steps::start_sccache_server())+ .add_step(build_wasm_for_functional_tests())+ .add_step(run_functional_tests())+ .add_step(steps::show_sccache_stats())+ .add_step(steps::teardown_nix())+}++/// Browser suites that only need the agent-fold package, including the ones that+/// run only when their paths change. Apart from vitest and the app build so+/// neither waits for them.+fn browser() -> Job {+ gated_web_job("Browser Tests")+ .runs_on(mid_web_runner())+ .add_step(checkout("Checkout Repo", false))+ .add_step(steps::mount_web_test_cache_volume())+ .add_step(steps::setup_nix())+ .add_step(steps::setup_reqs_web("Setup", true))+ .add_step(steps::configure_namespace_sccache(vars::WEB_SCCACHE_NAME))+ .add_step(build_agent_fold_for_tests()).add_step(run_signup_browser_tests()).add_step(run_i18n_browser_tests()).add_step(run_database_browser_tests())@@ -226,19 +272,27 @@ fn cycles() -> Job {}fn build() -> Job {- gated_web_job("Build")+ let (preview_credentials, preview_steps) = preview::steps();+ let job = gated_web_job("Build")// Match preview/deploy capacity for Vite's chunk-rendering memory peak.- .runs_on(runners::Runner::Mid.with_cache_tag(vars::WEB_CI_CACHE_TAG))+ .runs_on(mid_web_runner())+ .permissions(+ Permissions::default()+ .contents(Level::Read)+ .pull_requests(Level::Write),+ ).add_step(checkout("Checkout Repo", false)).add_step(steps::mount_web_build_check_cache_volume()).add_step(steps::setup_nix())- .add_step(steps::setup_reqs_web("Setup", true))+ .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())- // Exercise this revision's cache engine, already compiled by build-dev.- .add_step(run_functional_tests()).add_step(steps::show_sccache_stats())+ .add_step(preview_credentials);+ preview_steps+ .into_iter()+ .fold(job, Job::add_step).add_step(steps::teardown_nix())}@@ -257,6 +311,8 @@ fn status_check() -> Job {"generated-code".to_string(),"biome-check".to_string(),"test".to_string(),+ "functional".to_string(),+ "browser".to_string(),"cycles".to_string(),"build".to_string(),ios_native_check::JOB_ID.to_string(),@@ -311,7 +367,7 @@ fn paths_filter() -> Step<Use> {.add_with(("filters",format!(- "should_run:\n{artifact_paths} - 'services/lexical-service/**'\n - 'packages/sdk/**'\n - 'packages/sdk-docs/**'\n - 'services/ai-editing-worker/**'\n - 'packages/code-mode-sdk/**'\n - 'crates/agent_code_mode/SKILL.md'\n - '.github/actions/setup-reqs-web/**'\ncodegen_changed:\n - 'crates/**/*.rs'\n - 'services/**/*.rs'\n - 'Cargo.toml'\n - 'Cargo.lock'\n - 'apps/web/scripts/generate-api-schema.ts'\n - 'apps/web/scripts/services.ts'\n - 'packages/sdk/**'\n - 'apps/docs/**'\n - '.github/actions/setup-reqs-web/**'\ni18n_changed:\n - 'apps/web/src/lib/i18n/**'\n - 'apps/web/src/lib/core/component/ContextMenu.tsx'\n - 'apps/web/src/lib/core/constant/settingsTabsConfig.tsx'\n - 'apps/web/src/components/ui/components/Dropdown.tsx'\n - 'apps/web/src/features/settings/**'\ndatabase_grid_changed:\n - 'apps/web/src/features/database/**'\ncalendar_details_changed:\n - 'apps/web/src/features/calendar-view/**'\n - 'apps/web/src/features/calendar/**'\n - 'apps/web/src/lib/queries/calendar/**'\n"+ "should_run:\n{artifact_paths} - 'services/lexical-service/**'\n - 'packages/sdk/**'\n - 'packages/sdk-docs/**'\n - 'services/ai-editing-worker/**'\n - 'packages/code-mode-sdk/**'\n - 'crates/agent_code_mode/SKILL.md'\n - '.github/actions/setup-reqs-web/**'\nweb_artifact_changed:\n{artifact_paths}codegen_changed:\n - 'crates/**/*.rs'\n - 'services/**/*.rs'\n - 'Cargo.toml'\n - 'Cargo.lock'\n - 'apps/web/scripts/generate-api-schema.ts'\n - 'apps/web/scripts/services.ts'\n - 'packages/sdk/**'\n - 'apps/docs/**'\n - '.github/actions/setup-reqs-web/**'\ni18n_changed:\n - 'apps/web/src/lib/i18n/**'\n - 'apps/web/src/lib/core/component/ContextMenu.tsx'\n - 'apps/web/src/lib/core/constant/settingsTabsConfig.tsx'\n - 'apps/web/src/components/ui/components/Dropdown.tsx'\n - 'apps/web/src/features/settings/**'\ndatabase_grid_changed:\n - 'apps/web/src/features/database/**'\ncalendar_details_changed:\n - 'apps/web/src/features/calendar-view/**'\n - 'apps/web/src/features/calendar/**'\n - 'apps/web/src/lib/queries/calendar/**'\n"),))}@@ -402,7 +458,7 @@ fn check_floating_promises() -> Step<Run> {fn check_functional_test_types() -> Step<Run> {Step::new("Check Functional Test Types")- .run("bun run --bun --silent tsc --project tests/functional/tsconfig.json")+ .run("bun ../../node_modules/typescript-native/bin/tsc --noEmit --skipLibCheck --project tests/functional/tsconfig.json").working_directory(xtask_paths::repo_dir!("apps/web"))}@@ -448,6 +504,7 @@ fn run_collaboration_biome() -> Step<Run> {fn build_agent_fold_for_tests() -> Step<Run> {Step::new("Build agent-fold WASM for tests").run("just build-agent-fold-wasm")+ .add_env(("WASM_PKG_CACHE_DIR", vars::WASM_PKG_CACHE_DIR)).working_directory(xtask_paths::repo_dir!("apps/web")).timeout_minutes(15u32)}@@ -456,7 +513,7 @@ fn build_agent_fold_for_tests() -> Step<Run> {/// keeps it warm across jobs.fn run_tests() -> Step<Run> {Step::new("Test")- .run("bun run test")+ .run("bun run test --shard=${{ matrix.shard }}/3").add_env(("VITEST_MODULE_CACHE_DIR",vars::VITEST_MODULE_CACHE_VOLUME_DIR,@@ -464,9 +521,18 @@ fn run_tests() -> Step<Run> {.working_directory(xtask_paths::repo_dir!("apps/web"))}+fn build_wasm_for_functional_tests() -> Step<Run> {+ with_pr_wasm_env(+ Step::new("Build wasm packages")+ .run("just build-wasm")+ .working_directory(xtask_paths::repo_dir!("apps/web")),+ )+}+fn run_functional_tests() -> Step<Run> {- Step::new("Test Optimistic Mutations in Chromium")+ Step::new("Functional Browser Tests").run("bun run test:functional")+ .add_env(("FUNCTIONAL_TEST_WORKERS", "8")).working_directory(xtask_paths::repo_dir!("apps/web"))}@@ -526,11 +592,35 @@ fn collaboration_cycles_import_check() -> Step<Run> {.working_directory(xtask_paths::repo_dir!("packages/collaboration"))}-fn run_build() -> Step<Run> {- Step::new("Build")- .run("just build-dev")+/// Whole-program LTO costs the fig, psd and ai engines about 40 s each and only+/// makes them faster to run, which a PR's tests and preview don't need. Deploys+/// keep it. The wasm package cache doesn't key on these, so only PR jobs, which+/// all set them, may read it.+const PR_WASM_ENV: [(&str, &str); 6] = [+ ("CARGO_PROFILE_FIG_ENGINE_WASM_LTO", "off"),+ ("CARGO_PROFILE_FIG_ENGINE_WASM_CODEGEN_UNITS", "16"),+ ("CARGO_PROFILE_PSD_ENGINE_WASM_LTO", "off"),+ ("CARGO_PROFILE_PSD_ENGINE_WASM_CODEGEN_UNITS", "16"),+ ("CARGO_PROFILE_AI_ENGINE_WASM_LTO", "off"),+ ("CARGO_PROFILE_AI_ENGINE_WASM_CODEGEN_UNITS", "16"),+];++fn with_pr_wasm_env(step: Step<Run>) -> Step<Run> {+ PR_WASM_ENV+ .into_iter()+ .fold(step, Step::add_env).add_env(("WASM_PKG_CACHE_DIR", vars::WASM_PKG_CACHE_DIR))- .working_directory(xtask_paths::repo_dir!("apps/web"))+}++fn run_build() -> Step<Run> {+ preview::build_env().into_iter().fold(+ with_pr_wasm_env(+ Step::new("Build")+ .run("just build-dev")+ .working_directory(xtask_paths::repo_dir!("apps/web")),+ ),+ Step::add_env,+ )}fn check_job_results() -> Step<Run> {@@ -541,6 +631,8 @@ fn check_job_results() -> Step<Run> {echo "generated-code: ${{ needs.generated-code.result }}"echo "biome-check: ${{ needs.biome-check.result }}"echo "test: ${{ needs.test.result }}"+ echo "functional: ${{ needs.functional.result }}"+ echo "browser: ${{ needs.browser.result }}"echo "cycles: ${{ needs.cycles.result }}"echo "build: ${{ needs.build.result }}"echo "ios-native-check: ${{ needs.ios-native-check.result }}"@@ -555,6 +647,8 @@ fn check_job_results() -> Step<Run> {[[ "${{ needs.generated-code.result }}" == "cancelled" ]] || \[[ "${{ needs.biome-check.result }}" == "failure" ]] || \[[ "${{ needs.test.result }}" == "failure" ]] || \+ [[ "${{ needs.functional.result }}" == "failure" ]] || \+ [[ "${{ needs.browser.result }}" == "failure" ]] || \[[ "${{ needs.cycles.result }}" == "failure" ]] || \[[ "${{ needs.build.result }}" == "failure" ]] || \[[ "${{ needs.ios-native-check.result }}" == "failure" ]] || \diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/preview.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/preview.rsnew file mode 100644index 0000000000..ca7022ffb3--- /dev/null+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/preview.rs@@ -0,0 +1,115 @@+//! Preview deployment, as the last steps of the web `Build` job: the bundle that+//! job already built is the preview. Deploys to+//! `<branch>-<nanoid>-preview.macro.com`, built identically to dev.macro.com+//! (MODE=development, points at dev services).+//!+//! These steps must NOT block a merge, so each continues on error and the+//! status check doesn't read them. A `[no preview]` marker in the PR title opts+//! out without skipping CI.++use gh_workflow::{Env, Expression, Run, Step, Use};++use crate::workflows::vars;++const PREVIEW_BUCKET: &str = "macro-preview-assets-dev";++/// A fork has no credentials to deploy with, and a change that can't alter the+/// bundle has nothing new to show.+const WANTED: &str = "needs.path-check.outputs.web_artifact_changed == 'true' \+ && !contains(github.event.pull_request.title, '[no preview]') \+ && github.event.pull_request.head.repo.full_name == github.repository";++/// Env for the build step, so the bundle can serve as the preview.+pub fn build_env() -> [Env; 2] {+ [+ Env::new("VITE_SEGMENT_WRITE_KEY", vars::SEGMENT_WRITE_KEY_PRODUCTION),+ Env::new("VITE_POSTHOG_API_KEY", vars::POSTHOG_API_KEY),+ ]+}++/// Every deploy step with its gate, in order. A step that continues on error+/// still leaves `success()` true, so later steps check the steps they need.+pub fn steps() -> (Step<Use>, Vec<Step<Run>>) {+ let gate = |needs: &str| Expression::new(format!("{WANTED}{needs}"));+ let credentials = configure_aws_credentials()+ .id("preview-credentials")+ .if_condition(Expression::new(WANTED))+ .continue_on_error(true);+ let credentials_ok = " && steps.preview-credentials.outcome == 'success'";+ let id_ok = " && steps.preview-id.outcome == 'success'";+ let bucket_ok = " && steps.preview-bucket.outcome == 'success'";+ let deployed = " && steps.preview-deploy.outcome == 'success'";+ let rest = vec![+ (get_or_create_preview_id(), gate(credentials_ok)),+ (validate_bucket_name().id("preview-bucket"), gate(id_ok)),+ (deploy_to_s3().id("preview-deploy"), gate(bucket_ok)),+ (comment_on_pr(), gate(deployed)),+ ]+ .into_iter()+ .map(|(step, condition)| {+ step.add_env(("PREVIEW_BUCKET", PREVIEW_BUCKET))+ .if_condition(condition)+ .continue_on_error(true)+ })+ .collect();+ (credentials, rest)+}++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(xtask_paths::repo_dir!("apps/web"))+}++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(xtask_paths::repo_dir!("apps/web"))+}++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(xtask_paths::repo_dir!("apps/web"))+}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.rsindex ff544270e4..73e4a964d1 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@@ -360,33 +360,104 @@ fn build_job_uses_remote_sccache_and_wasm_cache() {);}-#[test]-fn test_job_runs_signup_browser_tests_after_vitest() {- let yaml = web_app_check_main().to_string().expect("workflow yaml");- // The job and its vitest step are both named "Test"; slice from the job.- let start = yaml.find("name: Test\n").expect("Test job");+/// The Test legs, up to the next job.+fn test_job(yaml: &str) -> &str {+ let start = yaml+ .find("name: Test (${{ matrix.shard }}/3)")+ .expect("Test job");+ let end = yaml[start..]+ .find("name: Functional Tests\n")+ .map_or(yaml.len(), |offset| start + offset);+ &yaml[start..end]+}++fn browser_job(yaml: &str) -> &str {+ let start = yaml+ .find("name: Browser Tests\n")+ .expect("Browser Tests job");let end = yaml[start..].find("name: Cycles Import Check").map_or(yaml.len(), |offset| start + offset);- let test_job = &yaml[start..end];+ &yaml[start..end]+}++fn functional_job(yaml: &str) -> &str {+ let start = yaml+ .find("name: Functional Tests\n")+ .expect("Functional Tests job");+ let end = yaml[start..]+ .find("name: Browser Tests\n")+ .map_or(yaml.len(), |offset| start + offset);+ &yaml[start..end]+}++#[test]+fn test_job_shards_vitest_after_building_its_wasm() {+ let yaml = web_app_check_main().to_string().expect("workflow yaml");+ let test_job = test_job(&yaml);let wasm = test_job.find("just build-agent-fold-wasm").expect("build WASM before the test setup hook");- let vitest = test_job.find("bun run test").expect("vitest step");+ let vitest = test_job+ .find("bun run test --shard=${{ matrix.shard }}/3")+ .expect("vitest step runs one shard");assert!(wasm < vitest, "cold WASM compilation precedes Vitest");- let browser = test_job- .find("just test-signup-browser")- .expect("sign-up browser step");assert!(- vitest < browser,- "browser tests run after vitest: {test_job}"+ test_job.contains("fail-fast: false"),+ "a failing shard must not hide the others' failures: {test_job}");assert!(- test_job.contains("playwright: 'true'"),- "the Test job installs Playwright's Chromium: {test_job}"+ test_job.contains(&format!("WASM_PKG_CACHE_DIR: {}", vars::WASM_PKG_CACHE_DIR)),+ "unchanged wasm packages are reused: {test_job}");}+#[test]+fn browser_suites_build_the_wasm_they_load_first() {+ let yaml = web_app_check_main().to_string().expect("workflow yaml");+ let functional = functional_job(&yaml);+ let wasm = functional.find("just build-wasm").expect("wasm packages");+ let suite = functional+ .find("bun run test:functional")+ .expect("functional suite");+ assert!(+ wasm < suite,+ "the bundle imports every package: {functional}"+ );+ assert!(+ functional.contains("playwright: 'true'"),+ "the job installs Playwright's Chromium: {functional}"+ );++ let browser = browser_job(&yaml);+ let wasm = browser+ .find("just build-agent-fold-wasm")+ .expect("agent-fold package");+ for suite in [+ "just test-signup-browser",+ "just test-i18n-browser",+ "just test-database-browser",+ "just test-calendar-details-browser",+ ] {+ let at = browser+ .find(suite)+ .unwrap_or_else(|| panic!("{suite} runs: {browser}"));+ assert!(wasm < at, "{suite} needs the package: {browser}");+ }+ assert!(+ browser.contains("playwright: 'true'"),+ "the job installs Playwright's Chromium: {browser}"+ );+}++/// A browser suite that isn't required could fail without blocking a merge.+#[test]+fn status_check_requires_the_browser_jobs() {+ let yaml = web_app_check_main().to_string().expect("workflow yaml");+ assert!(yaml.contains(r#"[[ "${{ needs.functional.result }}" == "failure" ]]"#));+ assert!(yaml.contains(r#"[[ "${{ needs.browser.result }}" == "failure" ]]"#));+}+/// The event details fixture replaces the calendar query modules with preview/// adapters, so a change to those modules runs the suite that would show a/// blank page when an adapter export goes missing.@@ -408,11 +479,7 @@ fn calendar_details_browser_tests_run_when_the_replaced_queries_change() {] {assert!(calendar.contains(path), "{path} runs the suite: {calendar}");}- let start = yaml.find("name: Test\n").expect("Test job");- let end = yaml[start..]- .find("name: Cycles Import Check")- .map_or(yaml.len(), |offset| start + offset);- let step = yaml[start..end]+ let step = browser_job(&yaml).split("- name: Calendar Event Details Browser Tests").nth(1).and_then(|rest| rest.split("- name:").next())@@ -427,11 +494,7 @@ fn calendar_details_browser_tests_run_when_the_replaced_queries_change() {#[test]fn test_job_keeps_vitest_module_cache_on_the_cache_volume() {let yaml = web_app_check_main().to_string().expect("workflow yaml");- let start = yaml.find("name: Test\n").expect("Test job");- let end = yaml[start..]- .find("name: Cycles Import Check")- .map_or(yaml.len(), |offset| start + offset);- let test_job = &yaml[start..end];+ let test_job = test_job(&yaml);let mounted = format!(" {}\n", vars::VITEST_MODULE_CACHE_VOLUME_DIR);assert!(test_job.contains(&mounted),@@ -659,6 +722,48 @@ fn ios_gate_status_and_comment_scenarios() {);}+fn build_job(yaml: &str) -> &str {+ yaml.split("\n build:\n")+ .nth(1)+ .and_then(|rest| rest.split("\n ios-native-check:").next())+ .expect("build job")+}++/// A failed preview must not read as a failed build or block a merge, and a+/// `[no preview]` title or a fork skips it.+#[test]+fn preview_steps_follow_the_build_and_cannot_fail_it() {+ let yaml = web_app_check_main().to_string().expect("workflow yaml");+ let build = build_job(&yaml);+ let build_at = build.find("just build-dev").expect("bundle");+ let deploy_at = build.find("scripts/preview/deploy.ts").expect("deploy");+ assert!(+ build_at < deploy_at,+ "the deploy reuses the bundle: {build}"+ );+ assert!(+ build.contains("--skip-build"),+ "the deploy must not rebuild: {build}"+ );+ for name in [+ "Configure AWS Credentials",+ "Get or create preview ID",+ "Validate bucket name",+ "Deploy to S3",+ "Comment on PR",+ ] {+ let step = build+ .split(&format!("name: {name}"))+ .nth(1)+ .and_then(|rest| rest.split("\n - ").next())+ .unwrap_or_else(|| panic!("{name} step: {build}"));+ assert!(step.contains("continue-on-error: true"), "{name}: {step}");+ assert!(step.contains("[no preview]"), "{name}: {step}");+ assert!(step.contains("web_artifact_changed"), "{name}: {step}");+ assert!(step.contains("head.repo.full_name"), "{name}: {step}");+ }+}+/// A job that hits its timeout reports `cancelled`, so the required check must/// not pass on a generated code job that never finished.#[test]