diff --git a/.github/scripts/tests/release-runner-cache.test.mjs b/.github/scripts/tests/release-runner-cache.test.mjs index e358cedfde8..fcc8b6ad461 100644 --- a/.github/scripts/tests/release-runner-cache.test.mjs +++ b/.github/scripts/tests/release-runner-cache.test.mjs @@ -36,9 +36,20 @@ test("the shared cache excludes workspace artifacts and only restores or saves t test("parallel lanes cover check:all exactly once and never bypass verification", () => { const scripts = JSON.parse(readFileSync(new URL("../../../packages/paperclip-runner/package.json", import.meta.url))).scripts; - const checks = [...runner.matchAll(/^ checks: (.+)$/gm)].flatMap(([, value]) => value.split(" ")); - assert.deepEqual(checks, scripts["check:all"].split(" && ").map((command) => command.replace(/^pnpm run /, ""))); - assert.deepEqual([...runner.matchAll(/^ - lane: (.+)$/gm)].map(([, value]) => value), ["protocol", "rust", "server-integration"]); + const matrixBlock = runner.split(" matrix:\n include:\n")[1].split("\n steps:")[0]; + const matrixEntries = matrixBlock.split(/^ - /m).slice(1).map((entry) => { + const row = { lane: "", checks: "", vitest_lane: "" }; + for (const line of entry.trim().split("\n")) { + const match = /^\s*(lane|checks|vitest_lane):\s*(.+?)\s*$/.exec(line); + assert.ok(match, `unexpected matrix field line: ${line}`); + row[match[1]] = match[2]; + } + return row; + }); + const checks = matrixEntries.filter((row) => row.checks).flatMap((row) => row.checks.split(" ")); + assert.deepEqual(checks, scripts["check:all-without-vitest"].split(" && ").map((command) => command.replace(/^pnpm run /, ""))); + assert.deepEqual(matrixEntries.map((row) => row.lane), ["protocol-static", "protocol (1/4)", "protocol (2/4)", "protocol (3/4)", "protocol (4/4)", "rust", "server-integration"]); + assert.deepEqual(matrixEntries.filter((row) => row.vitest_lane).map((row) => row.vitest_lane), ["1/4", "2/4", "3/4", "4/4"]); assert.match(runner, /fail-fast: false/); assert.doesNotMatch(runner, /max-parallel: 1|^ needs:|continue-on-error:/m); const verify = runner.split(" - name: Verify Paperclip Runner\n")[1].split(" - name:")[0]; @@ -46,11 +57,24 @@ test("parallel lanes cover check:all exactly once and never bypass verification" assert.match(verify, /set -euo pipefail/); assert.match(verify, /for check in \$RUNNER_CHECKS; do\s+pnpm --filter @paperclipai\/paperclip-runner "\$check"\s+done/); const verifyIf = verify.match(/^\s*if: \$\{\{ (.+) \}\}$/m)?.[1]; - assert.equal(verifyIf, "matrix.lane != 'server-integration'"); - for (const lane of ["protocol", "rust", "server-integration"]) { - assert.equal(runInNewContext(verifyIf, { matrix: { lane } }), lane !== "server-integration"); + assert.equal(verifyIf, "matrix.lane != 'server-integration' && matrix.vitest_lane == ''"); + const vitestStep = runner.split(" - name: Run Paperclip Runner package Vitest lane\n")[1].split(" - name:")[0]; + assert.match(vitestStep, /RUNNER_VITEST_LANE: \$\{\{ matrix.vitest_lane \}\}/); + assert.match(vitestStep, /pnpm --filter @paperclipai\/paperclip-runner test:typescript:vitest "--package-lane=\$RUNNER_VITEST_LANE"/); + const vitestIf = vitestStep.match(/^\s*if: \$\{\{ (.+) \}\}$/m)?.[1]; + assert.equal(vitestIf, "matrix.vitest_lane != ''"); + const serverStep = runner.split(" - name: Run native server integration suites\n")[1].split(" - name:")[0]; + const serverIf = serverStep.match(/^\s*if: \$\{\{ (.+) \}\}$/m)?.[1]; + for (const matrix of matrixEntries) { + const runsVerify = runInNewContext(verifyIf, { matrix }); + const runsVitest = runInNewContext(vitestIf, { matrix }); + const runsServer = runInNewContext(serverIf, { matrix }); + assert.equal([runsVerify, runsVitest, runsServer].filter(Boolean).length, 1, `lane ${matrix.lane} must match exactly one verification step`); + assert.equal(Boolean(matrix.checks), runsVerify, `lane ${matrix.lane} checks field must match Verify Paperclip Runner condition`); + assert.equal(Boolean(matrix.vitest_lane), runsVitest, `lane ${matrix.lane} vitest_lane field must match Vitest lane condition`); } assert.doesNotMatch(verify, /cache-hit/); + assert.doesNotMatch(vitestStep, /cache-hit/); assert.doesNotMatch(runner, /id-token: write|packages: write|secrets: inherit/); }); @@ -62,7 +86,7 @@ test("only the trusted Rust lane writes, and warms both build profiles before sa assert.match(warm, /run: pnpm --filter @paperclipai\/paperclip-runner build:rust/); const sha = "a".repeat(40); const base = { repository: "paperclipai/paperclip", event_name: "push", ref: "refs/heads/master", sha }; - for (const lane of ["protocol", "rust", "server-integration"]) { + for (const lane of ["protocol-static", "protocol (1/4)", "protocol (2/4)", "protocol (3/4)", "protocol (4/4)", "rust", "server-integration"]) { for (const [overrides, ref, trusted] of [ [{}, sha, true], [{ event_name: "pull_request", ref: "refs/pull/1/merge" }, sha, false], diff --git a/.github/workflows/release-verify.yml b/.github/workflows/release-verify.yml index ccd075ad9f3..d4280a98eee 100644 --- a/.github/workflows/release-verify.yml +++ b/.github/workflows/release-verify.yml @@ -329,8 +329,16 @@ jobs: fail-fast: false matrix: include: - - lane: protocol - checks: check:eval-kernel check:protocol + - lane: protocol-static + checks: check:eval-kernel check:protocol-without-vitest + - lane: protocol (1/4) + vitest_lane: 1/4 + - lane: protocol (2/4) + vitest_lane: 2/4 + - lane: protocol (3/4) + vitest_lane: 3/4 + - lane: protocol (4/4) + vitest_lane: 4/4 - lane: rust checks: check:runner check:api-authority - lane: server-integration @@ -431,7 +439,7 @@ jobs: run: pnpm test:run:general -- --group general-server-native-runner - name: Verify Paperclip Runner - if: ${{ matrix.lane != 'server-integration' }} + if: ${{ matrix.lane != 'server-integration' && matrix.vitest_lane == '' }} env: RUNNER_CHECKS: ${{ matrix.checks }} run: | @@ -440,6 +448,13 @@ jobs: pnpm --filter @paperclipai/paperclip-runner "$check" done + - name: Run Paperclip Runner package Vitest lane + if: ${{ matrix.vitest_lane != '' }} + env: + RUNNER_VITEST_LANE: ${{ matrix.vitest_lane }} + # Do not insert `--`: pnpm forwards it literally to run-pr-vitest-lane.mjs. + run: pnpm --filter @paperclipai/paperclip-runner test:typescript:vitest "--package-lane=$RUNNER_VITEST_LANE" + - name: Compute the Runner debug crate cache key id: runner_debug_crate_key if: ${{ matrix.lane == 'rust' && github.repository == 'paperclipai/paperclip' && github.event_name == 'push' && github.ref == 'refs/heads/master' && inputs.ref == github.sha }} diff --git a/scripts/__tests__/release-verify-workflow.test.mjs b/scripts/__tests__/release-verify-workflow.test.mjs index 24830f0d019..6bc90583376 100644 --- a/scripts/__tests__/release-verify-workflow.test.mjs +++ b/scripts/__tests__/release-verify-workflow.test.mjs @@ -521,9 +521,13 @@ test("release verify workflow covers the same split test surface as stable PR ve const runnerScripts = JSON.parse(readFileSync(path.join(repoRoot, "packages/paperclip-runner/package.json"), "utf8")).scripts; const runnerChecks = [...verifyWorkflow.matchAll(/^ checks: (.+)$/gm)] .flatMap(([, checks]) => checks.split(" ")); - assert.deepEqual(runnerChecks, runnerScripts["check:all"].split(" && ") + assert.deepEqual(runnerChecks, runnerScripts["check:all-without-vitest"].split(" && ") .map((command) => command.replace(/^pnpm run /, ""))); + const runnerVitestLanes = [...verifyWorkflow.matchAll(/^ vitest_lane: (.+)$/gm)] + .map(([, lane]) => lane); + assert.deepEqual(runnerVitestLanes, ["1/4", "2/4", "3/4", "4/4"]); assert.match(verifyWorkflow, /pnpm --filter @paperclipai\/paperclip-runner "\$check"/); + assert.match(verifyWorkflow, /pnpm --filter @paperclipai\/paperclip-runner test:typescript:vitest "--package-lane=\$RUNNER_VITEST_LANE"/); assert.match(verifyWorkflow, /runner_workflow_evals:/); assert.match(verifyWorkflow, /runner_chaos_evals:/); assert.match(