fix: switch CI to pnpm to resolve native binding failure on Linux runners#856
Conversation
…ing bug Co-authored-by: willtheorangeguy <18339050+willtheorangeguy@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub Pages “Astro” workflow to prefer pnpm in CI (to avoid platform-specific optional dependency issues seen with npm ci), while also modernizing the Node runtime and making dependency caching lockfile-aware.
Changes:
- Prefer
pnpm-lock.yamlduring package-manager detection and expose alockfileoutput for downstream steps. - Add
pnpm/action-setup@v4(pnpm v9) and switch Node.js from 18 to 20. - Make
actions/setup-nodecaching use a dynamiccache-dependency-pathbased on the detected lockfile.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then | ||
| echo "manager=pnpm" >> $GITHUB_OUTPUT | ||
| echo "command=install" >> $GITHUB_OUTPUT | ||
| echo "runner=pnpm" >> $GITHUB_OUTPUT | ||
| echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| elif [ -f "${{ github.workspace }}/yarn.lock" ]; then | ||
| echo "manager=yarn" >> $GITHUB_OUTPUT | ||
| echo "command=install" >> $GITHUB_OUTPUT | ||
| echo "runner=yarn" >> $GITHUB_OUTPUT | ||
| echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| elif [ -f "${{ github.workspace }}/package.json" ]; then |
There was a problem hiding this comment.
The lockfile detection is hard-coded to ${{ github.workspace }} and ignores env.BUILD_PATH. If BUILD_PATH is set to a subfolder (as the workflow hints), this step will fail to detect the correct manager/lockfile even though later steps run from working-directory: ${{ env.BUILD_PATH }}. Consider checking for lockfiles under ${{ github.workspace }}/${{ env.BUILD_PATH }} (or cd into BUILD_PATH within this step) so detection stays consistent with the rest of the workflow.
| if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then | |
| echo "manager=pnpm" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=pnpm" >> $GITHUB_OUTPUT | |
| echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=yarn" >> $GITHUB_OUTPUT | |
| echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/package.json" ]; then | |
| if [ -f "${{ github.workspace }}/${{ env.BUILD_PATH }}/pnpm-lock.yaml" ]; then | |
| echo "manager=pnpm" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=pnpm" >> $GITHUB_OUTPUT | |
| echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/${{ env.BUILD_PATH }}/yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=yarn" >> $GITHUB_OUTPUT | |
| echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/${{ env.BUILD_PATH }}/package.json" ]; then |
| echo "command=install" >> $GITHUB_OUTPUT | ||
| echo "runner=pnpm" >> $GITHUB_OUTPUT | ||
| echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| elif [ -f "${{ github.workspace }}/yarn.lock" ]; then | ||
| echo "manager=yarn" >> $GITHUB_OUTPUT | ||
| echo "command=install" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
For CI determinism, pnpm install without a frozen/immutable flag can silently resolve and update the lockfile, which can make builds succeed despite lockfile drift. Consider setting the pnpm command output to use --frozen-lockfile (and similarly for yarn if you want parity with npm ci) so the workflow fails when the lockfile and manifest are out of sync.
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=pnpm" >> $GITHUB_OUTPUT | |
| echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT | |
| echo "runner=pnpm" >> $GITHUB_OUTPUT | |
| echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT |
npm cihas a known bug (npm/cli#4828) where platform-specific optional dependencies aren't installed correctly — causing@tailwindcss/oxideto fail with "Cannot find native binding" on Linux CI runners whenpackage-lock.jsonwas generated on macOS.The repo already ships a
pnpm-lock.yaml, so switching to pnpm is the natural fix; pnpm resolves platform-specific optionals correctly.Changes to
.github/workflows/astro.ymlpnpm-lock.yamlis now checked first; each branch emits alockfileoutput so downstream steps stay genericpnpm/action-setup@v4(pinned to v9, matchinglockfileVersion: '9.0'in the lockfile) beforesetup-nodeso caching workscache-dependency-path— uses${{ steps.detect-package-manager.outputs.lockfile }}instead of the hardcodedpackage-lock.json✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.