fix(ci): use python3 for pnpm detection instead of node

node is not on PATH before the Setup Node step runs on ARC runners
(minimal Docker-based containers). The node -e command exits 127,
is silently swallowed by 2>/dev/null, and the || echo 'false' fallback
sets has_package_manager=false. This causes the Corepack branch to be
skipped and pnpm/action-setup@v4 to run with version:latest, which
conflicts with packageManager in package.json.

python3 is pre-installed on Ubuntu ARC runners (no setup required)
and reliably parses JSON via the stdlib json module.

Fixes pnpm version conflict on headlamp-polaris-plugin PR #103.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Hugh Hackman
2026-03-22 05:59:48 +00:00
parent 17ce365262
commit 13bf0639c6
+3 -1
View File
@@ -26,7 +26,9 @@ jobs:
# Check for packageManager field in package.json (Corepack pinning).
# pnpm/action-setup@v4 errors when `packageManager` is set (even without
# a `version` input), so we use Corepack directly for those repos.
PM=$(node -e "try{const p=require('./package.json');const v=p.packageManager||'';console.log(v.startsWith('pnpm@')?'true':'false')}catch(e){console.log('false')}" 2>/dev/null || echo "false")
# Use python3 (pre-installed on Ubuntu ARC runners) instead of node,
# because node is not on PATH before the Setup Node step runs.
PM=$(python3 -c "import json,sys; d=json.load(open('package.json')); print('true' if d.get('packageManager','').startswith('pnpm@') else 'false')" 2>/dev/null || echo "false")
echo "has_package_manager=$PM" >> $GITHUB_OUTPUT
else
echo "manager=npm" >> $GITHUB_OUTPUT