license: explicit MIT in package.json + matching README badge #110
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Detect package manager | |
| id: pm | |
| run: | | |
| if [ -f pnpm-lock.yaml ] || node -e "try{const s=Object.values(require('./package.json').scripts||{}).join(' '); process.exit(s.includes('pnpm')?0:1)}catch(e){process.exit(1)}"; then | |
| echo "pm=pnpm" >> $GITHUB_OUTPUT | |
| else | |
| echo "pm=npm" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup pnpm | |
| if: steps.pm.outputs.pm == 'pnpm' | |
| uses: pnpm/action-setup@v4 | |
| - name: Install | |
| run: | | |
| if [ "${{ steps.pm.outputs.pm }}" = "pnpm" ]; then | |
| pnpm install --no-frozen-lockfile | |
| elif [ -f package-lock.json ]; then | |
| npm ci | |
| else | |
| npm install | |
| fi | |
| - name: Lint | |
| run: | | |
| if [ "${{ steps.pm.outputs.pm }}" = "pnpm" ]; then | |
| pnpm run -r --if-present lint || pnpm run --if-present lint | |
| else | |
| npm run lint --if-present | |
| fi | |
| - name: Test | |
| run: | | |
| if [ "${{ steps.pm.outputs.pm }}" = "pnpm" ]; then | |
| pnpm run -r --if-present test || pnpm run --if-present test | |
| else | |
| npm test --if-present | |
| fi | |
| - name: Coverage (Vitest, 60% lines minimum) | |
| run: | | |
| if [ -f vitest.config.ts ] || [ -f vitest.config.js ]; then | |
| if [ "${{ steps.pm.outputs.pm }}" = "pnpm" ]; then | |
| pnpm exec vitest run --coverage | |
| else | |
| npx vitest run --coverage | |
| fi | |
| else | |
| echo "No vitest config found; skipping coverage check." | |
| fi | |