|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - master
|
7 |
| - - '2.0' |
8 | 7 | paths-ignore:
|
9 | 8 | - '*.md'
|
10 | 9 | pull_request:
|
11 | 10 | paths-ignore:
|
12 | 11 | - '*.md'
|
13 | 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 | + |
14 | 22 | jobs:
|
15 |
| - test: |
| 23 | + lint: |
| 24 | + name: Lint |
16 | 25 | runs-on: ubuntu-latest
|
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Setup Node.js |
| 30 | + uses: actions/setup-node@v4 |
| 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 }} |
17 | 43 | strategy:
|
| 44 | + fail-fast: false |
18 | 45 | matrix:
|
19 |
| - name: |
20 |
| - - Node.js 18.x |
21 |
| - - Node.js 20.x |
22 |
| - - Node.js 22.x |
| 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] |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
23 | 51 |
|
24 |
| - include: |
25 |
| - - name: Node.js 18.x |
26 |
| - node-version: "18" |
| 52 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 53 | + uses: actions/setup-node@v4 |
| 54 | + with: |
| 55 | + check-latest: true |
| 56 | + node-version: ${{ matrix.node-version }} |
27 | 57 |
|
28 |
| - - name: Node.js 20.x |
29 |
| - node-version: "20" |
| 58 | + - name: Configure npm loglevel |
| 59 | + run: npm config set loglevel error |
30 | 60 |
|
31 |
| - - name: Node.js 22.x |
32 |
| - node-version: "22" |
| 61 | + - name: Install dependencies |
| 62 | + run: npm install |
33 | 63 |
|
34 |
| - steps: |
35 |
| - - uses: actions/checkout@v4 |
36 |
| - |
37 |
| - - name: Install Node.js ${{ matrix.node-version }} |
38 |
| - shell: bash -eo pipefail -l {0} |
39 |
| - run: | |
40 |
| - nvm install --default ${{ matrix.node-version }} |
41 |
| - dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" |
42 |
| -
|
43 |
| - - name: Configure npm |
44 |
| - run: npm config set package-lock false |
45 |
| - |
46 |
| - - name: Install Node.js dependencies |
47 |
| - run: npm install |
48 |
| - |
49 |
| - - name: List environment |
50 |
| - id: list_env |
51 |
| - shell: bash |
52 |
| - run: | |
53 |
| - echo "node@$(node -v)" |
54 |
| - echo "npm@$(npm -v)" |
55 |
| - npm -s ls ||: |
56 |
| - (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' |
57 |
| -
|
58 |
| - - name: Run tests |
59 |
| - shell: bash |
60 |
| - run: npm run test-ci |
61 |
| - |
62 |
| - - name: Lint code |
63 |
| - if: steps.list_env.outputs.eslint != '' |
64 |
| - run: npm run lint |
65 |
| - |
66 |
| - - name: Collect code coverage |
67 |
| - uses: coverallsapp/github-action@master |
68 |
| - with: |
69 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
70 |
| - flag-name: run-${{ matrix.test_number }} |
71 |
| - parallel: true |
| 64 | + - name: Run tests |
| 65 | + run: npm run test-ci |
| 66 | + |
| 67 | + - name: Upload code coverage |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }} |
| 71 | + path: ./coverage/lcov.info |
| 72 | + retention-days: 1 |
72 | 73 |
|
73 | 74 | coverage:
|
74 | 75 | needs: test
|
75 | 76 | runs-on: ubuntu-latest
|
| 77 | + permissions: |
| 78 | + contents: read |
| 79 | + checks: write |
76 | 80 | steps:
|
77 |
| - - name: Upload code coverage |
78 |
| - uses: coverallsapp/github-action@master |
79 |
| - with: |
80 |
| - github-token: ${{ secrets.github_token }} |
81 |
| - parallel-finished: true |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: Install lcov |
| 84 | + run: sudo apt-get -y install lcov |
| 85 | + |
| 86 | + - name: Collect coverage reports |
| 87 | + uses: actions/download-artifact@v4 |
| 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 |
0 commit comments