fix(ci): use Corepack for pnpm setup when packageManager field is set#57
Conversation
pnpm/action-setup@v4 errors with "Multiple versions of pnpm specified" even when no explicit version input is provided, if the repo has a packageManager field in package.json. Switch to Corepack for repos that pin their pnpm version via the packageManager field. Corepack reads the version from package.json directly and installs it without conflicting with pnpm/action-setup. Repos without a packageManager field continue using pnpm/action-setup@v4 with version: latest (unchanged behavior). Unblocks headlamp-polaris-plugin PR #103 (ci/pin-pnpm-version). Co-Authored-By: Paperclip <noreply@paperclip.ing>
There was a problem hiding this comment.
CTO Review: Approved.
Clean, correct fix. When packageManager is set, use Corepack instead of pnpm/action-setup@v4 — avoids the "Multiple versions" error entirely. Detection logic unchanged, repos without packageManager unaffected. CI green.
This unblocks polaris PR #103. Merge after QA approval.
There was a problem hiding this comment.
QA Review: Approved ✅
Tested: Reviewed diff and verified CI passing ( check run on commit ).
Fix correctness:
- Bug:
pnpm/action-setup@v4errors whenpackageManageris set inpackage.json - Fix: Use Corepack (
corepack enable pnpm && corepack install) which reads version frompackageManagerfield directly
Edge cases covered:
- Invalid
packageManagerformat →startsWith('pnpm@')returns false → safe fallback topnpm/action-setup@v4with latest ✅ - Corepack availability → bundled with Node.js 16+ on all Actions runners ✅
Regression: Repos without packageManager field are unaffected (unchanged pnpm/action-setup@v4 path) ✅
No test gap: Workflow YAML change — no unit tests applicable.
CI: Passing ✅
cc @cpfarhood
There was a problem hiding this comment.
QA Review: Approved. CI passing. Fix is correct and minimal. No regression risk. cc @cpfarhood
Problem
pnpm/action-setup@v4throwsError: Multiple versions of pnpm specifiedeven when no explicitversioninput is given, if the repo'spackage.jsonhas apackageManagerfield (e.g.pnpm@10.32.1).This blocked headlamp-polaris-plugin PR #103 which adds
packageManager: pnpm@10.32.1for Corepack compatibility.Fix
When the
packageManagerfield is set (detected by the existinghas_package_manageroutput), use Corepack instead ofpnpm/action-setup@v4:Corepack reads the version directly from
packageManagerinpackage.jsonand installs it without any conflict.Repos without
packageManagercontinue usingpnpm/action-setup@v4withversion: latest— unchanged behavior.Impact
packageManager(kube-vip, sealed-secrets, rook, tns-csi, intel-gpu): unchanged behaviorpackageManagerset (polaris): pnpm version read frompackage.jsonvia Corepackcc @cpfarhood