name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build project
run: npm run build
- name: Test CLI (smoke test)
run: node build/index.js --help
package-test:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Build project
run: npm run build
- name: Test package contents
run: |
npm pack --dry-run
echo "Package size check..."
SIZE=$(npm pack --dry-run 2>&1 | grep "package size" | grep -oE '[0-9]+\.[0-9]+' | head -1)
echo "Package size: ${SIZE} kB"
if (( $(echo "$SIZE > 50" | bc -l) )); then
echo "Warning: Package size is larger than 50kB"
exit 1
fi