mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-06 19:35:04 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The pull request workflow is the main merge gate for changes to that app. > - The Playwright e2e lane is expensive because every spec shares one isolated server and runs serially. > - Splitting that lane across runners shortens the critical path, but the public required-check contract still needs a check named exactly `e2e`. > - This pull request shards the real e2e work while preserving a fast aggregate `e2e` job for branch protection. > - The benefit is a faster PR workflow without making otherwise-good PRs unmergeable because a legacy required check disappeared. ## Linked Issues or Issue Description No public GitHub issue exists for this CI follow-up. Related prior CI work: - Refs #8360 - Refs #9168 - Refs #9516 Bug report: ### What happened? Sharding the PR e2e lane directly at the workflow job level changes the emitted check names to shard-specific names, while existing branch protection expects a check named exactly `e2e`. ### Expected behavior The PR workflow should be able to run e2e specs across multiple runners while still emitting a stable aggregate check named `e2e`. ### Steps to reproduce 1. Open a PR against `master`. 2. Run the PR workflow with the e2e lane split only as a matrix job. 3. Observe that the shard checks complete, but a required check named exactly `e2e` never appears. ### Paperclip version or commit Current `master`. ### Deployment mode GitHub Actions pull request workflow. ## What Changed - Added `scripts/e2e-shard.mjs`, which partitions default Playwright e2e specs by recorded per-spec duration. - Added `scripts/e2e-shard-durations.json` with measured e2e spec durations so the slow smoke-lab spec does not dominate one runner. - Split the PR workflow e2e lane into two `e2e_shards` matrix jobs and added a fast aggregate job named exactly `e2e`. - Added `scripts/__tests__/e2e-shard.test.mjs` to lock the shard partition, ignored-spec sync, manifest coverage, and aggregate required-check contract. ## Verification - `node --test scripts/__tests__/e2e-shard.test.mjs` - `node --test scripts/__tests__/run-vitest-stable-shard.test.mjs` - `git diff --check upstream/master..HEAD` - Searched GitHub for duplicate or related e2e-shard / required-check PRs and issues before opening this PR; no direct duplicate was found. ## Risks Low risk. The main risk is that the duration manifest can drift as specs are added or runtimes change; missing specs fall back to the median known duration, and the focused shard test catches empty, overlapping, or badly imbalanced partitions. ## Model Used OpenAI GPT-5 via Codex CLI coding agent, with shell/tool execution and repository inspection. ## 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 - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge Co-authored-by: Paperclip <noreply@paperclip.ing>
60 lines
2.7 KiB
JavaScript
60 lines
2.7 KiB
JavaScript
import { readdirSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { loadShardDurations, partitionGeneralServerSuites } from "./general-server-shard.mjs";
|
|
|
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
const REPO_ROOT = path.resolve(HERE, "..");
|
|
const E2E_DIR = path.join(REPO_ROOT, "tests", "e2e");
|
|
const DURATIONS_MANIFEST = path.join(HERE, "e2e-shard-durations.json");
|
|
|
|
// Specs the default local_trusted Playwright project deliberately skips. Keep
|
|
// this in sync with `testIgnore` in tests/e2e/playwright.config.ts — the unit
|
|
// test in scripts/__tests__/e2e-shard.test.mjs fails if the two ever drift.
|
|
export const IGNORED_SPECS = ["multi-user.spec.ts", "multi-user-authenticated.spec.ts"];
|
|
|
|
// Enumerates the specs the default e2e lane actually runs, as repo-relative
|
|
// paths so the output can be handed straight to `playwright test`.
|
|
export function listE2eSpecs(e2eDir = E2E_DIR, repoRoot = REPO_ROOT) {
|
|
return readdirSync(e2eDir)
|
|
.filter((entry) => entry.endsWith(".spec.ts") && !IGNORED_SPECS.includes(entry))
|
|
.map((entry) => path.relative(repoRoot, path.join(e2eDir, entry)).split(path.sep).join("/"))
|
|
.sort((a, b) => a.localeCompare(b));
|
|
}
|
|
|
|
// Playwright's own --shard balances by test count, which is useless here: one
|
|
// spec (smoke-lab) is ~40% of the lane's wall clock. Reuse the deterministic
|
|
// longest-processing-time partition already proven on the general-server lane
|
|
// so every runner computes the identical, non-overlapping split.
|
|
export function selectE2eShard(files, shardIndex, shardCount, durations = {}) {
|
|
return partitionGeneralServerSuites(files, shardCount, durations)[shardIndex].files;
|
|
}
|
|
|
|
function parseArgs(argv) {
|
|
const args = { shardIndex: 0, shardCount: 1 };
|
|
for (let index = 0; index < argv.length; index += 1) {
|
|
if (argv[index] === "--shard-index") args.shardIndex = Number(argv[index + 1]);
|
|
if (argv[index] === "--shard-count") args.shardCount = Number(argv[index + 1]);
|
|
}
|
|
return args;
|
|
}
|
|
|
|
function main(argv) {
|
|
const { shardIndex, shardCount } = parseArgs(argv);
|
|
if (!Number.isInteger(shardCount) || shardCount < 1) {
|
|
throw new Error(`--shard-count must be a positive integer, got ${shardCount}`);
|
|
}
|
|
if (!Number.isInteger(shardIndex) || shardIndex < 0 || shardIndex >= shardCount) {
|
|
throw new Error(`--shard-index must be in [0, ${shardCount}), got ${shardIndex}`);
|
|
}
|
|
|
|
const specs = listE2eSpecs();
|
|
const durations = loadShardDurations(DURATIONS_MANIFEST);
|
|
process.stdout.write(`${selectE2eShard(specs, shardIndex, shardCount, durations).join(" ")}\n`);
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
main(process.argv.slice(2));
|
|
}
|