From d5403ebf0ad6d5cf1c11ba28a9626aec58d628a3 Mon Sep 17 00:00:00 2001 From: Aron Date: Sat, 7 Nov 2026 09:07:31 +0800 Subject: [PATCH] CI(Validation): Install the pinned Rust toolchain once, then let Turbo build the Wasm artifacts Reapplies the removal of the per-job `cargo xtask build-wasm all` prebuild that afeaebebf reverted. On a fresh macOS runner the three parallel build:artifacts tasks each triggered rustup's auto-install of rust-toolchain.toml and raced on the same download (could not rename the downloaded .partial file, run 42321525228). Each job that runs Turbo now installs the active toolchain once with `rustup toolchain install --no-self-update` (about 8 seconds for all six components on a fresh RUSTUP_HOME locally) before any Turbo task, so Turbo can still skip the Wasm build on a cache hit. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/validation.yml | 33 ++++++++++++++++++++-------- scripts/validation-workflow.test.mjs | 17 ++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 4a74b9e92..047e92a96 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -219,12 +219,15 @@ jobs: } >> "$GITHUB_OUTPUT" - name: Install Chromium headless shell run: bun run playwright install --with-deps --only-shell chromium + # Tests depend on build:artifacts, so Turbo builds the Rust Wasm modules or + # restores them from its cache when crates/ and Cargo inputs are unchanged. + # Install the pinned toolchain first: parallel build:artifacts tasks would + # otherwise race rustup's component downloads on a fresh runner. + - name: Install the pinned Rust toolchain + run: rustup toolchain install --no-self-update - name: Build release packages if: ${{ inputs.release_build }} run: bun run build - - name: Build Rust Wasm artifacts - if: ${{ !inputs.release_build }} - run: bun run build:rust:wasm - name: Validate packages shell: bash env: @@ -453,8 +456,12 @@ jobs: turbo-cache-scope: e2e - name: Install E2E browsers run: bun run playwright install --with-deps chromium firefox webkit - - name: Build Rust Wasm artifacts - run: bun run build:rust:wasm + # Tests depend on build:artifacts, so Turbo builds the Rust Wasm modules or + # restores them from its cache when crates/ and Cargo inputs are unchanged. + # Install the pinned toolchain first: parallel build:artifacts tasks would + # otherwise race rustup's component downloads on a fresh runner. + - name: Install the pinned Rust toolchain + run: rustup toolchain install --no-self-update - name: Run E2E tests shell: bash env: @@ -504,8 +511,12 @@ jobs: turbo-cache-scope: compat - name: Install Chromium headless shell run: bun run playwright install --only-shell chromium - - name: Build Rust Wasm artifacts - run: bun run build:rust:wasm + # Tests depend on build:artifacts, so Turbo builds the Rust Wasm modules or + # restores them from its cache when crates/ and Cargo inputs are unchanged. + # Install the pinned toolchain first: parallel build:artifacts tasks would + # otherwise race rustup's component downloads on a fresh runner. + - name: Install the pinned Rust toolchain + run: rustup toolchain install --no-self-update - name: Test packages shell: bash env: @@ -558,8 +569,12 @@ jobs: turbo-cache-scope: compat - name: Install Chromium headless shell run: bun run playwright install --only-shell chromium - - name: Build Rust Wasm artifacts - run: bun run build:rust:wasm + # Tests depend on build:artifacts, so Turbo builds the Rust Wasm modules or + # restores them from its cache when crates/ and Cargo inputs are unchanged. + # Install the pinned toolchain first: parallel build:artifacts tasks would + # otherwise race rustup's component downloads on a fresh runner. + - name: Install the pinned Rust toolchain + run: rustup toolchain install --no-self-update - name: Test packages shell: bash env: diff --git a/scripts/validation-workflow.test.mjs b/scripts/validation-workflow.test.mjs index 69078bc82..f811bc8e7 100644 --- a/scripts/validation-workflow.test.mjs +++ b/scripts/validation-workflow.test.mjs @@ -126,3 +126,20 @@ test('cache pruning is skipped for pull requests and never fails validation', () const failed = prune({ caches: [[1, 'Linux-X64-bun-1.4.4-turbo-build-main-2'], [2, 'Linux-X64-bun-1.4.4-turbo-build-main-1']], listFailure: true }) assert.deepEqual(failed.deleted, []) }) + +test('jobs that leave Wasm to Turbo install the pinned toolchain once before any Turbo task', () => { + const turbo = JSON.parse(readFileSync(new URL('../turbo.json', import.meta.url), 'utf8')) + // binding-wasm-* bundle their generated ../artifacts modules, so a build that + // could start before its own build:artifacts fails to resolve them. + assert.ok(turbo.tasks.build.dependsOn.includes('build:artifacts')) + for (const job of ['quality_linux', 'e2e_linux', 'compat_windows', 'compat_macos']) { + const steps = workflow.jobs[job].steps + assert.equal(steps.some(step => step.run === 'bun run build:rust:wasm'), false, job) + // Parallel build:artifacts tasks race rustup's first component download on a + // fresh runner ("could not rename 'downloaded' file"), so one install precedes them. + const install = steps.findIndex(step => step.run === 'rustup toolchain install --no-self-update') + const firstTurbo = steps.findIndex(step => /\bbun run (build|test|e2e|turbo)\b(?!:)|\bturbo run\b/.test(step.run ?? '') && !/--dry/.test(step.run ?? '')) + assert.ok(install >= 0, job) + assert.ok(firstTurbo > install, `${job} runs Turbo before installing the toolchain`) + } +})