11# Reusable workflow: Lint & Type Check
22# Runs lint and typecheck scripts from package.json if they exist.
3- # Uses bun as the standard package manager for all OrrisTech repos.
3+ # Auto-detects package manager: pnpm-lock.yaml → pnpm, package-lock.json → npm,
4+ # otherwise → bun (default for new projects).
45name : CI - Lint & Type Check
56
67on :
2829 - name : Checkout repository
2930 uses : actions/checkout@v4
3031
32+ # Detect package manager from lock files. Default to bun for new projects.
33+ - name : Detect package manager
34+ id : detect-pm
35+ run : |
36+ if [ -f "pnpm-lock.yaml" ]; then
37+ echo "manager=pnpm" >> "$GITHUB_OUTPUT"
38+ elif [ -f "package-lock.json" ]; then
39+ echo "manager=npm" >> "$GITHUB_OUTPUT"
40+ else
41+ echo "manager=bun" >> "$GITHUB_OUTPUT"
42+ fi
43+
44+ - name : Setup pnpm
45+ if : steps.detect-pm.outputs.manager == 'pnpm'
46+ uses : pnpm/action-setup@v4
47+ with :
48+ version : latest
49+
3150 - name : Setup Bun
51+ if : steps.detect-pm.outputs.manager == 'bun'
3252 uses : oven-sh/setup-bun@v2
3353
3454 - name : Setup Node.js
@@ -37,13 +57,18 @@ jobs:
3757 node-version : ${{ inputs.node_version }}
3858
3959 - name : Install dependencies
40- run : bun install --frozen-lockfile
60+ run : |
61+ case "${{ steps.detect-pm.outputs.manager }}" in
62+ pnpm) pnpm install --frozen-lockfile ;;
63+ npm) npm ci ;;
64+ bun) bun install --frozen-lockfile ;;
65+ esac
4166
4267 # Check if a lint script exists before running it
4368 - name : Check for lint script
4469 id : check-lint
4570 run : |
46- if bun -e "const p=require('./package.json'); process.exit(p.scripts && p.scripts.lint ? 0 : 1)"; then
71+ if node -e "const p=require('./package.json'); process.exit(p.scripts && p.scripts.lint ? 0 : 1)"; then
4772 echo "has_lint=true" >> "$GITHUB_OUTPUT"
4873 else
4974 echo "has_lint=false" >> "$GITHUB_OUTPUT"
@@ -52,13 +77,18 @@ jobs:
5277
5378 - name : Run lint
5479 if : steps.check-lint.outputs.has_lint == 'true'
55- run : bun run lint
80+ run : |
81+ case "${{ steps.detect-pm.outputs.manager }}" in
82+ pnpm) pnpm run lint ;;
83+ npm) npm run lint ;;
84+ bun) bun run lint ;;
85+ esac
5686
5787 # Check if a typecheck script exists (supports both "typecheck" and "type-check")
5888 - name : Check for typecheck script
5989 id : check-typecheck
6090 run : |
61- SCRIPT=$(bun -e "
91+ SCRIPT=$(node -e "
6292 const p = require('./package.json');
6393 const s = p.scripts || {};
6494 if (s['typecheck']) console.log('typecheck');
@@ -75,4 +105,11 @@ jobs:
75105
76106 - name : Run type check
77107 if : steps.check-typecheck.outputs.has_typecheck == 'true'
78- run : bun run ${{ steps.check-typecheck.outputs.script_name }}
108+ env :
109+ SCRIPT : ${{ steps.check-typecheck.outputs.script_name }}
110+ run : |
111+ case "${{ steps.detect-pm.outputs.manager }}" in
112+ pnpm) pnpm run "$SCRIPT" ;;
113+ npm) npm run "$SCRIPT" ;;
114+ bun) bun run "$SCRIPT" ;;
115+ esac
0 commit comments