| 1 |
name: ci |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- master |
| 7 |
paths-ignore: |
| 8 |
- '*.md' |
| 9 |
pull_request: |
| 10 |
paths-ignore: |
| 11 |
- '*.md' |
| 12 |
|
| 13 |
permissions: |
| 14 |
contents: read |
| 15 |
|
| 16 |
# Cancel in progress workflows |
| 17 |
# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run |
| 18 |
concurrency: |
| 19 |
group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" |
| 20 |
cancel-in-progress: true |
| 21 |
|
| 22 |
jobs: |
| 23 |
lint: |
| 24 |
name: Lint |
| 25 |
runs-on: ubuntu-latest |
| 26 |
steps: |
| 27 |
- uses: actions/checkout@v6 |
| 28 |
|
| 29 |
- name: Setup Node.js |
| 30 |
uses: actions/setup-node@v6 |
| 31 |
with: |
| 32 |
node-version: "lts/*" |
| 33 |
|
| 34 |
- name: Install dependencies |
| 35 |
run: npm install --ignore-scripts --include=dev |
| 36 |
|
| 37 |
- name: Run lint |
| 38 |
run: npm run lint |
| 39 |
|
| 40 |
test: |
| 41 |
name: Test - Node.js ${{ matrix.node-version }} - ${{ matrix.os }} |
| 42 |
runs-on: ${{ matrix.os }} |
| 43 |
strategy: |
| 44 |
fail-fast: false |
| 45 |
matrix: |
| 46 |
os: [ubuntu-latest, windows-latest] |
| 47 |
# Node.js release schedule: https://nodejs.org/en/about/releases/ |
| 48 |
node-version: [18, 19, 20, 21, 22, 23, 24, 25] |
| 49 |
steps: |
| 50 |
- uses: actions/checkout@v6 |
| 51 |
|
| 52 |
- name: Setup Node.js ${{ matrix.node-version }} |
| 53 |
uses: actions/setup-node@v6 |
| 54 |
with: |
| 55 |
check-latest: true |
| 56 |
node-version: ${{ matrix.node-version }} |
| 57 |
|
| 58 |
- name: Configure npm loglevel |
| 59 |
run: npm config set loglevel error |
| 60 |
|
| 61 |
- name: Install dependencies |
| 62 |
run: npm install |
| 63 |
|
| 64 |
- name: Run tests |
| 65 |
run: npm run test-ci |
| 66 |
|
| 67 |
- name: Upload code coverage |
| 68 |
uses: actions/upload-artifact@v5 |
| 69 |
with: |
| 70 |
name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }} |
| 71 |
path: ./coverage/lcov.info |
| 72 |
retention-days: 1 |
| 73 |
|
| 74 |
coverage: |
| 75 |
needs: test |
| 76 |
runs-on: ubuntu-latest |
| 77 |
permissions: |
| 78 |
contents: read |
| 79 |
checks: write |
| 80 |
steps: |
| 81 |
- uses: actions/checkout@v6 |
| 82 |
|
| 83 |
- name: Install lcov |
| 84 |
run: sudo apt-get -y install lcov |
| 85 |
|
| 86 |
- name: Collect coverage reports |
| 87 |
uses: actions/download-artifact@v6 |
| 88 |
with: |
| 89 |
path: ./coverage |
| 90 |
pattern: coverage-node-* |
| 91 |
|
| 92 |
- name: Merge coverage reports |
| 93 |
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info |
| 94 |
|
| 95 |
- name: Upload coverage report |
| 96 |
uses: coverallsapp/github-action@v2 |
| 97 |
with: |
| 98 |
file: ./lcov.info |