mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 10:07:24 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Post-merge release verification in `.github/workflows/release-verify.yml` runs `verify_paperclip_runner` matrix lanes in parallel to prove exact-source readiness. > - Today, the `rust` lane runs `check:runner` (236s) and `check:api-authority` (92s) serially on one runner, stretching the lane to ~6m 39s–7m 34s even though `check:api-authority` is independent and reads the same shared `release-runner-v2` Rust dependency cache. > - Meanwhile, PR verification (`pr-trusted.yml`) already separates `check:api-authority` from the Rust test lane. > - This pull request moves `check:api-authority` into its own `api-authority` lane in `.github/workflows/release-verify.yml` and updates `.github/scripts/tests/release-runner-cache.test.mjs` to cover the new lane. > - The benefit is cutting ~1m 30s off the `Verify Paperclip Runner (rust)` critical path on every post-merge `cloud-readiness.yml` and release verification run. ## Linked Issues or Issue Description **What existing behavior does this improve?** Wall-clock duration of `Verify Paperclip Runner (rust)` in `.github/workflows/release-verify.yml`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** The `rust` matrix entry executes `checks: check:runner check:api-authority` serially in one job (~328s in the check step, ~399s–454s total job duration). **Proposed behavior** Run `check:runner` in the `rust` lane (which remains the sole Rust cache writer) and run `check:api-authority` concurrently in a dedicated `api-authority` lane that restores the same `release-runner-v2` Rust cache. **Reason and benefit** Removes ~92s of serial wall-clock time from `Verify Paperclip Runner (rust)` with identical check coverage (`check:all-without-vitest` stays exact and complete). **Breaking changes** None. All checks in `check:all-without-vitest` remain required before verification passes. ## What Changed - Split `checks: check:runner check:api-authority` in `.github/workflows/release-verify.yml` into `lane: rust` (`checks: check:runner`) and `lane: api-authority` (`checks: check:api-authority`). - Updated `.github/scripts/tests/release-runner-cache.test.mjs` to verify `api-authority` restores the shared Rust cache without writing it and preserves complete `check:all-without-vitest` coverage. ## Verification - `node --test .github/scripts/tests/release-runner-cache.test.mjs scripts/__tests__/release-verify-workflow.test.mjs .github/scripts/tests/cloud-readiness.test.mjs` (80/80 passed). ## Risks - Low risk. No production code, schema, or test assertions change; `rust` remains the sole cache writer (`save-if: matrix.lane == 'rust'`), and `release-verify-workflow.test.mjs` enforces exact `check:all-without-vitest` coverage. ## Model Used - Google Gemini 3.1 Pro (thinking mode, tool use and code execution) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge
105 lines
7.2 KiB
JavaScript
105 lines
7.2 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { runInNewContext } from "node:vm";
|
|
|
|
const workflow = readFileSync(new URL("../../workflows/release-verify.yml", import.meta.url), "utf8");
|
|
const runner = workflow.split(" verify_paperclip_runner:")[1].split(" build:")[0];
|
|
|
|
test("Runner dependency caching selects the package's pinned compiler before computing its key", () => {
|
|
const select = runner.indexOf(" - name: Select the pinned Runner Rust toolchain");
|
|
const cache = runner.indexOf(" - name: Cache Runner Rust dependencies");
|
|
assert.ok(select >= 0 && cache > select);
|
|
const setup = runner.slice(select, cache);
|
|
assert.match(setup, /working-directory: packages\/paperclip-runner/);
|
|
assert.match(setup, /rustup show active-toolchain/);
|
|
assert.match(setup, /echo "RUSTUP_TOOLCHAIN=\$toolchain" >> "\$GITHUB_ENV"/);
|
|
assert.match(runner, /uses: Swatinem\/rust-cache@[0-9a-f]{40} # v[0-9.]+/);
|
|
// The target path feeds the entry's version hash, so it must not resolve
|
|
// under the checkout, whose root differs between the fleet and GitHub-hosted
|
|
// runners. The pin step publishes a $HOME-anchored path to the same directory.
|
|
const pin = runner.indexOf(" - name: Pin the Runner Rust workspace path");
|
|
assert.ok(pin >= 0 && cache > pin, "the workspace path must be pinned before the cache step");
|
|
assert.match(runner, /workspaces: \$\{\{ steps\.runner_rust_workspace\.outputs\.path \}\} -> target/);
|
|
assert.match(runner, /shared-key: release-runner-v2/);
|
|
});
|
|
|
|
test("the shared cache excludes workspace artifacts and only restores or saves the exact master-push source", () => {
|
|
assert.match(runner, /cache-workspace-crates: false/);
|
|
assert.match(runner, /cache-bin: false/);
|
|
const saveIf = runner.match(/^\s*save-if: (.+)$/m)?.[1];
|
|
assert.equal(saveIf, "${{ matrix.lane == 'rust' && github.repository == 'paperclipai/paperclip' && github.event_name == 'push' && github.ref == 'refs/heads/master' && inputs.ref == github.sha }}");
|
|
const cacheStep = runner.split(" - name: Cache Runner Rust dependencies")[1].split(" - name: Install dependencies")[0];
|
|
assert.equal(cacheStep.match(/^\s*if: (.+)$/m)?.[1], saveIf.replace("matrix.lane == 'rust' && ", ""));
|
|
assert.doesNotMatch(runner, /cache-on-failure: true|cache-all-crates: true/);
|
|
});
|
|
|
|
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 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", "api-authority", "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];
|
|
assert.match(verify, /RUNNER_CHECKS: \$\{\{ matrix.checks \}\}/);
|
|
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' && 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/);
|
|
});
|
|
|
|
test("only the trusted Rust lane writes, and warms both build profiles before saving", () => {
|
|
const cache = runner.split(" - name: Cache Runner Rust dependencies")[1].split(" - name: Install dependencies")[0];
|
|
const warm = runner.split(" - name: Warm debug dependencies for the shared Runner cache")[1];
|
|
const expr = (body, field) => body.match(new RegExp(`^ +${field}: \\$\\{\\{ (.+) \\}\\}$`, "m"))[1];
|
|
assert.equal(expr(cache, "save-if"), expr(warm, "if"));
|
|
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-static", "protocol (1/4)", "protocol (2/4)", "protocol (3/4)", "protocol (4/4)", "rust", "api-authority", "server-integration"]) {
|
|
for (const [overrides, ref, trusted] of [
|
|
[{}, sha, true],
|
|
[{ event_name: "pull_request", ref: "refs/pull/1/merge" }, sha, false],
|
|
[{ event_name: "pull_request_target" }, sha, false],
|
|
[{ event_name: "workflow_dispatch" }, sha, false],
|
|
[{ repository: "someone/paperclip" }, sha, false],
|
|
[{ ref: "refs/heads/feature" }, sha, false],
|
|
[{}, "b".repeat(40), false],
|
|
]) {
|
|
const context = { matrix: { lane }, github: { ...base, ...overrides }, inputs: { ref } };
|
|
assert.equal(runInNewContext(expr(cache, "if"), context), trusted);
|
|
assert.equal(runInNewContext(expr(cache, "save-if"), context), trusted && lane === "rust");
|
|
}
|
|
}
|
|
});
|