mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-27 03:07:57 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Live 8-core runs on `paperclip-public-ci-fleetd:29` (`ami-09dfb1e62707f576c`, runs `45665466678` & `45668834558`) revealed three zero-hot-instance sources of wasted PR wall-clock time: > 1. `pnpm/action-setup@v6` still spent `4.1–5.0s` on all 68 jobs switching its bundled `v11.19.0` to `v9.15.4` even though the pre-baked AMI already has `pnpm@9.15.4` installed at `$HOME/setup-pnpm/node_modules/.bin/pnpm`. > 2. `ci / verify` and `ci / e2e` rollups booted fresh 8-core AWS EC2 VMs (`18–23s` cold queue after all tests already finished!) just to run a 1-second inline Node `assert` check with zero repo checkout and zero secrets. > 3. `scripts/ci-dependency-cache.mjs` hashed blanket `scripts/**`, `server/scripts/**`, and `packages/paperclip-runner/scripts/**`, causing every merge touching any CI script or shard duration manifest to invalidate the ~944 MB `ci-dependencies-v1` cache for all 70 jobs (`35–40s` cold restore vs `10s` hit) until `release-verify.yml` rebuilt it 15–20 minutes later. > - This pull request eliminates all three bottlenecks with zero hot/standby instances and zero security-boundary changes (`ci-routing.yml`, `pr.yml`, `CODEOWNERS`, and read-only PR caches untouched). ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** PR job startup latency, rollup tail latency, and `ci-dependencies-v1` cache hit rate across `.github/workflows/pr-trusted.yml`, `.github/actions/setup-ci-dependencies/action.yml`, and `scripts/ci-dependency-cache.mjs`. **Subsystem affected** CI — PR workflow bootstrap, rollup jobs, and materialized dependency cache key inputs **Current behavior** All 11 `Setup pnpm` steps run `pnpm/action-setup@v6` unconditionally (`4–5s` each); `ci / verify` and `ci / e2e` boot full AWS EC2 runners (`18–23s` queue) after tests complete; `ci-dependency-cache.mjs` hashes blanket `scripts/**` globs so unrelated CI script edits bust `node_modules` caching across all 70 PR jobs. **Proposed behavior** Dynamically compare `$HOME/setup-pnpm/node_modules/.bin/pnpm --version` against `package.json`'s `packageManager` before all 11 `Setup pnpm` steps (skipping `pnpm/action-setup` on pre-baked runners while preserving identical `PNPM_HOME` and failing closed on version bumps); run `ci / verify` and `ci / e2e` rollups on `ubuntu-slim`; narrow `ci-dependency-cache.mjs` script inputs to the exact 8-file `DEPENDENCY_SCRIPT_INPUTS` closure enforced by a static relative-import test plus `--prefer-offline` on cold-install fallback. ## What Changed - **Skip redundant `pnpm/action-setup` on pre-baked AMIs (`.github/workflows/pr-trusted.yml`):** - Added inline `Check preinstalled pnpm` (`id: pnpm_preinstalled`) before all 11 `Setup pnpm` steps: parses `package.json`'s `packageManager` (`^pnpm@([^+\s]+)(?:\+.*)?$`) dynamically, compares against `$HOME/setup-pnpm/node_modules/.bin/pnpm --version`, exports identical `PNPM_HOME` + `$GITHUB_PATH` on match, and fails closed to `pnpm/action-setup@v6` on version bump or `ubuntu-latest`. - **Move `ci / verify` & `ci / e2e` rollups to `ubuntu-slim` (`.github/workflows/pr-trusted.yml`):** - Switched both zero-checkout rollup jobs from `needs.gate.outputs.runner` to `ubuntu-slim` (~2–4s container start instead of `18–23s` EC2 VM boot). - **Narrow dependency cache script inputs (`scripts/ci-dependency-cache.mjs`, `.github/actions/setup-ci-dependencies/action.yml`):** - Replaced blanket `scripts/**`, `server/scripts/**`, and `packages/paperclip-runner/scripts/**` hashes with exported `DEPENDENCY_SCRIPT_INPUTS` (the exact 8 scripts invoked during dependency materialization/postinstall), kept `scripts/ensure-plugin-build-deps.mjs` on `buildKey` only, and added `--prefer-offline` on cold-install fallback. - **Tests (`.github/scripts/tests/ci-dependency-cache.test.mjs`, `.github/scripts/tests/ci-plan.test.mjs`):** - Added automated static relative-import closure verification for `DEPENDENCY_SCRIPT_INPUTS`, `ubuntu-slim` rollup checks, and execution tests of the extracted `Check preinstalled pnpm` snippet across matching, `+sha512`, bumped, missing `packageManager`, and missing binary cases. ## Verification - `ruby -ryaml -e 'YAML.load_file(".github/workflows/pr-trusted.yml"); YAML.load_file(".github/actions/setup-ci-dependencies/action.yml")'` — **YAML OK** - `node --test .github/scripts/tests/*.test.mjs scripts/ci/test-selection-workflow.test.mjs scripts/__tests__/{ci-typecheck-lane,e2e-shard,run-vitest-stable-shard,run-vitest-stable-pr-mode,merge-queue-checks-workflow,runner-release-crate-cache,runner-debug-crate-cache,public-install-closure}.test.mjs scripts/check-test-budget.test.mjs scripts/docker-image-metadata.test.mjs` — **942/942 PASS** - Live PR CI proves `ubuntu-slim` rollup execution, pre-baked `Check preinstalled pnpm` skip (`hit=true`), and `ci-dependencies-v1` restore parity end-to-end. ## Risks - Low risk: `Check preinstalled pnpm` dynamically reads `package.json`'s `packageManager` and fails closed on mismatch or version bump; `ci-dependency-cache.test.mjs` statically enforces that no relative import from `DEPENDENCY_SCRIPT_INPUTS` can escape the cache key; `ci / verify` and `ci / e2e` check out no code and use no secrets. ## Model Used - Gemini 4 Neon (High) via Antigravity agent swarm (`typecheck-opt`, `verifier`, `ci-pipeline`). ## 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
119 lines
5.0 KiB
YAML
119 lines
5.0 KiB
YAML
name: Restore materialized CI dependencies
|
|
description: Reuse exact installed dependencies and certified shared build outputs; install on a miss.
|
|
inputs:
|
|
working-directory:
|
|
description: Checkout directory relative to the workspace.
|
|
default: '.'
|
|
save-cache:
|
|
description: Allow a canonical master push to populate the caches.
|
|
default: 'false'
|
|
restore-cache:
|
|
description: Disable materialized restores for a controlled cold-path benchmark.
|
|
default: 'true'
|
|
outputs:
|
|
dependencies-restored:
|
|
description: Whether the exact materialized dependency cache was restored.
|
|
value: ${{ steps.installed.outputs.cache-hit }}
|
|
builds-restored:
|
|
description: Whether the exact certified build cache was restored.
|
|
value: ${{ steps.builds.outputs.cache-hit }}
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Compute dependency inputs
|
|
id: inputs
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: node scripts/ci-dependency-cache.mjs
|
|
|
|
- name: Restore installed dependencies (read only)
|
|
if: inputs.restore-cache == 'true' && steps.inputs.outputs.cacheable == 'true'
|
|
id: installed
|
|
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
|
|
with:
|
|
key: ${{ steps.inputs.outputs.dependency-key }}
|
|
path: ${{ steps.inputs.outputs.dependency-paths }}
|
|
|
|
- name: Locate pnpm store
|
|
if: steps.installed.outputs.cache-hit != 'true'
|
|
id: pnpm_store
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
|
|
echo "arch=$(node -p 'process.arch')" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Restore pnpm store (read only)
|
|
if: steps.installed.outputs.cache-hit != 'true'
|
|
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
|
|
with:
|
|
path: ${{ steps.pnpm_store.outputs.path }}
|
|
key: node-cache-${{ runner.os }}-${{ steps.pnpm_store.outputs.arch }}-pnpm-${{ hashFiles(format('{0}/pnpm-lock.yaml', inputs.working-directory)) }}
|
|
restore-keys: node-cache-${{ runner.os }}-${{ steps.pnpm_store.outputs.arch }}-pnpm-
|
|
|
|
- name: Install dependencies
|
|
if: steps.installed.outputs.cache-hit != 'true'
|
|
id: install
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
if pnpm install --frozen-lockfile --prefer-offline; then
|
|
echo 'frozen=true' >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo '::notice title=Lockfile::checked-in lockfile is stale for this merge tree; resolving it inline'
|
|
pnpm install --resolution-only --ignore-scripts --no-frozen-lockfile
|
|
pnpm install --frozen-lockfile --prefer-offline
|
|
fi
|
|
|
|
- name: Replay workspace install hooks after restore
|
|
if: steps.installed.outputs.cache-hit == 'true'
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
if [ -f scripts/replay-workspace-postinstall.mjs ]; then
|
|
node scripts/replay-workspace-postinstall.mjs
|
|
else
|
|
pnpm -r --if-present run postinstall
|
|
pnpm run postinstall
|
|
fi
|
|
|
|
- name: Restore certified shared build outputs (read only)
|
|
if: inputs.restore-cache == 'true' && steps.inputs.outputs.cacheable == 'true'
|
|
id: builds
|
|
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
|
|
with:
|
|
key: ${{ steps.inputs.outputs.build-key }}
|
|
path: ${{ steps.inputs.outputs.build-paths }}
|
|
|
|
- name: Validate workspace links and shared build outputs
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
if [ -f scripts/ensure-workspace-package-links.mjs ]; then
|
|
node scripts/ensure-workspace-package-links.mjs
|
|
else
|
|
pnpm run preflight:workspace-links
|
|
fi
|
|
node scripts/ensure-plugin-build-deps.mjs
|
|
|
|
- name: Save installed dependencies
|
|
if: >-
|
|
inputs.save-cache == 'true' && steps.inputs.outputs.cacheable == 'true' && github.repository == 'paperclipai/paperclip' &&
|
|
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
|
|
steps.installed.outputs.cache-hit != 'true' && steps.install.outputs.frozen == 'true'
|
|
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
|
|
with:
|
|
key: ${{ steps.inputs.outputs.dependency-key }}
|
|
path: ${{ steps.inputs.outputs.dependency-paths }}
|
|
|
|
- name: Save certified shared build outputs
|
|
if: >-
|
|
inputs.save-cache == 'true' && steps.inputs.outputs.cacheable == 'true' && github.repository == 'paperclipai/paperclip' &&
|
|
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
|
|
steps.builds.outputs.cache-hit != 'true' &&
|
|
(steps.installed.outputs.cache-hit == 'true' || steps.install.outputs.frozen == 'true')
|
|
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
|
|
with:
|
|
key: ${{ steps.inputs.outputs.build-key }}
|
|
path: ${{ steps.inputs.outputs.build-paths }}
|