1fd7a7ecf0
pnpm/action-setup@v4 requires either a version input or a packageManager field in package.json. Repos with pnpm-lock.yaml but no packageManager field were failing with "No pnpm version is specified." Adding version: latest as a fallback allows the action to install the latest stable pnpm when packageManager is not set. Repos that do specify packageManager in package.json continue to use their pinned version. Co-Authored-By: Paperclip <noreply@paperclip.ing>
93 lines
2.2 KiB
YAML
93 lines
2.2 KiB
YAML
name: Plugin CI
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
node-version:
|
|
description: 'Node.js version to use'
|
|
required: false
|
|
type: string
|
|
default: '22'
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: runners-privilegedescalation
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- 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
|
|
version: latest
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
cache: ${{ steps.pkg-manager.outputs.manager }}
|
|
|
|
- name: Install dependencies
|
|
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: |
|
|
if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then
|
|
pnpm run lint
|
|
else
|
|
npm run lint
|
|
fi
|
|
|
|
- name: Type-check
|
|
run: |
|
|
if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then
|
|
pnpm run tsc
|
|
else
|
|
npm run tsc
|
|
fi
|
|
|
|
- name: 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: |
|
|
if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then
|
|
pnpm test
|
|
else
|
|
npm test
|
|
fi
|
|
|
|
- name: Security audit
|
|
run: |
|
|
if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then
|
|
pnpm audit --prod
|
|
else
|
|
npm audit --omit=dev
|
|
fi
|