name: CI
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
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 }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Security audit
run: npm audit --audit-level=high
- name: Run linting
run: npm run lint
- name: Check formatting
run: npm run format:check
- name: Run tests
run: npm run test:coverage
- name: Build project
run: npm run build
- name: Upload coverage reports
if: matrix.node-version == '20.x'
uses: codecov/codecov-action@v3
with:
file: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
validate-package:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Pack package
run: npm pack
- name: Validate package contents
run: |
tar -tzf *.tgz | grep -E "dist/.*\.js$" || (echo "Missing dist files in package" && exit 1)
tar -tzf *.tgz | grep -E "dist/.*\.d\.ts$" || (echo "Missing type definitions in package" && exit 1)