Convert the hand-rolled corepack + store-path + actions/cache pnpm setups to pnpm/action-setup@v4 + setup-node cache: pnpm (the landlock-run.yml pattern) in e2e.yml, docs-pages.yml, pi-ai-provider-e2e.yml, build-exe-for-python-sdk.yml, and ci.yml's node-compat and benchmark jobs. The enterprise restore-only PR jobs and the Windows job keep their documented asymmetries; serial-linux keeps its hand-rolled store cache because it produces the exact key those restore-only jobs consume, and only swaps corepack for the action. Implements and moves the CI-caching Agent Note from PR #667 to implemented/, recording the serial-linux producer exception and the exact-key (no restore-keys prefix) behavior of setup-node's cache.
3.6 KiB
Agent Note: Use pnpm/action-setup for symmetric CI pnpm caching
Status: implemented
English | 中文
Problem
Five workflows repeated a hand-rolled three-step pnpm setup — corepack enable, pnpm store path --silent >> $GITHUB_OUTPUT, then actions/cache@v4 keyed on pnpm-lock.yaml: e2e.yml, docs-pages.yml, pi-ai-provider-e2e.yml, build-exe-for-python-sdk.yml, and the node-compat, serial-linux, and benchmark jobs of ci.yml (~40–60 YAML lines total). The maintained equivalent — pnpm/action-setup@v4 (reads packageManager from package.json) plus actions/setup-node with cache: pnpm — was already proven in-repo in landlock-run.yml, and also insulates against corepack's removal from newer Node distributions.
Decision
The symmetric-cache setups use pnpm/action-setup@v4 followed by actions/setup-node with cache: pnpm, the landlock-run.yml pattern: e2e.yml, docs-pages.yml, pi-ai-provider-e2e.yml, build-exe-for-python-sdk.yml, and the node-compat and two benchmark jobs of ci.yml. The larger-runner benchmark keeps its store cache Linux-only through a conditional cache: input, mirroring the required Windows job's deliberate skip; the consolidated benchmark caches on both platforms as before.
Explicitly NOT converted:
- the three enterprise-runner PR jobs in
ci.yml— they deliberately useactions/cache/restoreonly, keeping cache compression/upload off the paid latency-critical path, an asymmetrysetup-node's cache cannot express; - the Windows job, which deliberately skips the store cache;
- the store-cache step of
ci.yml's serial-linux job — the job swapscorepack enableforpnpm/action-setup@v4, but itspnpm store path+actions/cache@v4steps stay hand-rolled because the master-push serial-linux run is the save side that populates the exact key and path the enterprise restore-only jobs consume; converting the producer tosetup-node's own key format would silently starve their restores.
Alternatives considered
- Keep the hand-rolled steps. They work, but they are five drifting copies of setup boilerplate, and the corepack dependency is a known future break.
- Convert everything including the enterprise jobs. Rejected: the restore-only asymmetry is a documented latency decision in
ci.yml's comments; erasing it to unify tooling inverts the priority. - Convert serial-linux's store cache too. Rejected during implementation: the proposal counted serial-linux among the symmetric setups, but its cache step is the producer half of the enterprise jobs' restore-only pairing — moving it to
setup-node's key format is the enterprise conversion by another route.
Consequences
- The corepack dependency is gone from every converted workflow; pnpm arrives via the pnpm team's official action, already trusted in-repo (
landlock-run.yml). - The cache-key format changed once; one cold run per converted lane repopulates it, after which hit rates match the old steps. The built-in key spans platform, arch, and the lockfile hash but not the Node version, so the node-compat matrix legs share one store entry — safe, because the pnpm store is Node-version-independent.
setup-node's built-in pnpm cache restores by exact key only, with norestore-keysprefix fallback: apnpm-lock.yamlchange starts a converted lane from a cold store instead of seeding from the previous entry.- About 75 net lines of workflow YAML removed; the enterprise-runner PR jobs and the Windows job are byte-identical, and serial-linux keeps producing the key they restore.