From 902d50da73e72d1df276b1972b9611387a37b57d Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sat, 24 Oct 2026 20:46:25 -0500 Subject: [PATCH] Require actual cached MSVC type-check for Rust PRs --- .github/workflows/continuum-rust-tests.yml | 39 +++++++++++++++++-- tools/scripts/ci-windows-check.ps1 | 10 +++++ tools/scripts/tests/ci-windows-check.test.cjs | 31 +++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 tools/scripts/ci-windows-check.ps1 create mode 100644 tools/scripts/tests/ci-windows-check.test.cjs diff --git a/.github/workflows/continuum-rust-tests.yml b/.github/workflows/continuum-rust-tests.yml index ce6954021e..538168995b 100644 --- a/.github/workflows/continuum-rust-tests.yml +++ b/.github/workflows/continuum-rust-tests.yml @@ -26,7 +26,7 @@ jobs: cli: ${{ steps.select.outputs.cli }} steps: - uses: actions/checkout@v4 - - run: node --test tools/scripts/tests/ci-change-scope.test.cjs tools/scripts/tests/ci-cargo-freshness.test.cjs + - run: node --test tools/scripts/tests/ci-change-scope.test.cjs tools/scripts/tests/ci-cargo-freshness.test.cjs tools/scripts/tests/ci-windows-check.test.cjs - uses: actions/github-script@v7 id: select with: @@ -535,18 +535,51 @@ jobs: if: needs.changes.outputs.rust != 'false' run: cargo test -p continuum-cli-lifecycle - # Preserve the required Windows context; neither child can silently disappear. + # Real native compilation for Rust changes, including canary PRs. Keep linking and + # custody execution in their existing contracts; this cache stores check artifacts. + windows-type-check: + name: Native MSVC type-check (headless lib + tests) + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target + needs: changes + if: ${{ needs.changes.outputs.rust == 'true' }} + runs-on: windows-latest + # Cold-cache ceiling, not a claim that the warm <10-minute target is proven. + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Resolve pinned toolchain + run: | + rustup show active-toolchain + rustc --version + - uses: Swatinem/rust-cache@v2 + with: + shared-key: continuum-windows-check-v1 + save-if: ${{ github.event_name != 'pull_request' }} + cache-workspace-crates: true + - name: Type-check native Windows libraries and test targets + shell: pwsh + run: ./tools/scripts/ci-windows-check.ps1 + + # Preserve the required Windows context; selected compilation cannot silently disappear. cargo-check-windows: name: cargo check windows-msvc (lib + tests) - needs: [windows-core-contract, windows-lifecycle-contract] + needs: [changes, windows-type-check, windows-core-contract, windows-lifecycle-contract] if: ${{ !cancelled() }} runs-on: ubuntu-latest timeout-minutes: 5 steps: - name: Require both Windows contracts env: + SELECT_RESULT: ${{ needs.changes.result }} + RUST_CHANGED: ${{ needs.changes.outputs.rust }} + CHECK_RESULT: ${{ needs.windows-type-check.result }} CORE_RESULT: ${{ needs.windows-core-contract.result }} LIFECYCLE_RESULT: ${{ needs.windows-lifecycle-contract.result }} run: | ok() { test "$1" = success || test "$1" = skipped; } # skipped = a canary PR, by design + test "$SELECT_RESULT" = success + if [ "$RUST_CHANGED" = true ]; then test "$CHECK_RESULT" = success; else test "$RUST_CHANGED" = false; fi ok "$CORE_RESULT" && ok "$LIFECYCLE_RESULT" diff --git a/tools/scripts/ci-windows-check.ps1 b/tools/scripts/ci-windows-check.ps1 new file mode 100644 index 0000000000..56bccf8471 --- /dev/null +++ b/tools/scripts/ci-windows-check.ps1 @@ -0,0 +1,10 @@ +# Run the native MSVC type-check without linking resident binaries or running custody tests. +# The workflow owns cache restoration; this command is identical on a non-serving dev machine. +$ErrorActionPreference = 'Stop' +if (-not $env:CARGO_TARGET_DIR) { throw 'Set CARGO_TARGET_DIR to the configured shared build cache before checking.' } +$checkTimer = [Diagnostics.Stopwatch]::StartNew() +& cargo check --locked --target x86_64-pc-windows-msvc --profile dev-fast -p continuum-core -p continuum-cli-lifecycle --lib --tests --features continuum-core/test-fixtures +$checkExit = $LASTEXITCODE +$checkTimer.Stop() +Write-Output "Windows type-check elapsed seconds: $($checkTimer.Elapsed.TotalSeconds)" +if ($checkExit -ne 0) { exit $checkExit } diff --git a/tools/scripts/tests/ci-windows-check.test.cjs b/tools/scripts/tests/ci-windows-check.test.cjs new file mode 100644 index 0000000000..e599dea2ca --- /dev/null +++ b/tools/scripts/tests/ci-windows-check.test.cjs @@ -0,0 +1,31 @@ +const { test } = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const { spawnSync } = require('node:child_process'); +const root = path.resolve(__dirname, '../../..'); +const workflow = fs.readFileSync(path.join(root, '.github/workflows/continuum-rust-tests.yml'), 'utf8'); +const gate = workflow.slice(workflow.indexOf(' cargo-check-windows:')); +const run = gate.split(' run: |')[1].split('\n').filter(line => line.startsWith(' ')).map(line => line.slice(10)).join('\n'); +function verdict(overrides) { + const result = spawnSync(process.env.CI_TEST_BASH || 'bash', ['-e', '-c', run], { + env: { ...process.env, SELECT_RESULT: 'success', RUST_CHANGED: 'true', CHECK_RESULT: 'success', CORE_RESULT: 'skipped', LIFECYCLE_RESULT: 'skipped', ...overrides }, encoding: 'utf8' + }); + assert.ifError(result.error); + if (result.status !== 0 && result.stderr) process.stderr.write(result.stderr); + return result.status; +} +test('selected Windows compilation cannot pass through skipped, failed, or cancelled jobs', () => { + // Regression: the required context used to pass when both native jobs skipped. + assert.equal(verdict({}), 0); + for (const CHECK_RESULT of ['skipped', 'failure', 'cancelled', '']) assert.notEqual(verdict({ CHECK_RESULT }), 0); + for (const SELECT_RESULT of ['skipped', 'failure', 'cancelled']) assert.notEqual(verdict({ SELECT_RESULT }), 0); + for (const RUST_CHANGED of ['', 'unknown']) assert.notEqual(verdict({ RUST_CHANGED }), 0); +}); +test('docs may skip compilation but existing custody failures still fail the gate', () => { + // Regression: adding the fast compile must not hide an existing native-contract failure. + assert.equal(verdict({ RUST_CHANGED: 'false', CHECK_RESULT: 'skipped' }), 0); + for (const field of ['CORE_RESULT', 'LIFECYCLE_RESULT']) { + for (const value of ['failure', 'cancelled']) assert.notEqual(verdict({ [field]: value }), 0); + } +});