Building and Testing with GitHub Actions
Test matrix
Run tests across multiple Node.js versions:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
Caching dependencies
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm' # Automatically caches node_modules
Uploading artifacts
- uses: actions/upload-artifact@v4
with:
name: test-results
path: coverage/
retention-days: 7
Coverage reports
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}