From 23c86bf2d9dd51929e319dd0986ed0d852d1bfa0 Mon Sep 17 00:00:00 2001 From: Hugh Hackman Date: Sat, 21 Mar 2026 23:07:19 +0000 Subject: [PATCH] ci: add pnpm auto-detection to shared plugin CI workflow When pnpm-lock.yaml is present, use pnpm for install, lint, type-check, format check, tests, and security audit instead of npm. Repos using npm are unaffected (falls back to existing npm behavior). This fixes the npm/pnpm inconsistency in headlamp-polaris-plugin where local development uses pnpm but CI used npm, causing: - Different transitive dependency resolution (TypeScript not hoisted) - Different audit results (pnpm audit vs npm audit) Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/plugin-ci.yaml | 59 ++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/.github/workflows/plugin-ci.yaml b/.github/workflows/plugin-ci.yaml index 2898d32..06d786b 100644 --- a/.github/workflows/plugin-ci.yaml +++ b/.github/workflows/plugin-ci.yaml @@ -18,29 +18,74 @@ jobs: - name: Checkout uses: actions/checkout@v6 + - name: Detect package manager + id: pkg-manager + run: | + if [ -f "pnpm-lock.yaml" ]; then + echo "manager=pnpm" >> $GITHUB_OUTPUT + else + echo "manager=npm" >> $GITHUB_OUTPUT + fi + + - name: Setup pnpm + if: steps.pkg-manager.outputs.manager == 'pnpm' + uses: pnpm/action-setup@v4 + with: + run_install: false + - name: Setup Node uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} - cache: 'npm' + cache: ${{ steps.pkg-manager.outputs.manager }} - name: Install dependencies - run: npm ci + run: | + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm install --frozen-lockfile + else + npm ci + fi - name: Build plugin run: npx @kinvolk/headlamp-plugin build - name: Lint - run: npm run lint + run: | + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm run lint + else + npm run lint + fi - name: Type-check - run: npm run tsc + run: | + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm run tsc + else + npm run tsc + fi - name: Format check - run: npm run format:check + run: | + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm run format:check + else + npm run format:check + fi - name: Run tests - run: npm test + run: | + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm test + else + npm test + fi - name: Security audit - run: npm audit --omit=dev + run: | + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm audit --prod + else + npm audit --omit=dev + fi