|
3 | 3 | push: |
4 | 4 | branches: |
5 | 5 | - master |
6 | | - - '2.x' |
7 | 6 | paths-ignore: |
8 | 7 | - '*.md' |
9 | 8 | pull_request: |
10 | 9 | paths-ignore: |
11 | 10 | - '*.md' |
| 11 | +permissions: |
| 12 | + contents: read |
12 | 13 |
|
13 | 14 | jobs: |
14 | 15 | test: |
| 16 | + name: Test - Node.js ${{ matrix.node-version }} |
15 | 17 | runs-on: ubuntu-latest |
16 | 18 | strategy: |
17 | 19 | matrix: |
18 | | - name: |
19 | | - - Node.js 18.x |
20 | | - - Node.js 20.x |
21 | | - - Node.js 22.x |
22 | | - |
23 | | - include: |
24 | | - - name: Node.js 18.x |
25 | | - node-version: "18" |
26 | | - |
27 | | - - name: Node.js 20.x |
28 | | - node-version: "20" |
29 | | - |
30 | | - - name: Node.js 22.x |
31 | | - node-version: "22" |
| 20 | + node-version: [18, 19, 20, 21, 22, 23] |
32 | 21 |
|
33 | 22 | steps: |
34 | | - - uses: actions/checkout@v4 |
35 | | - |
36 | | - - name: Install Node.js ${{ matrix.node-version }} |
37 | | - shell: bash -eo pipefail -l {0} |
38 | | - run: | |
39 | | - nvm install --default ${{ matrix.node-version }} |
40 | | - dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" |
41 | | -
|
42 | | - - name: Configure npm |
43 | | - run: | |
44 | | - if [[ "$(npm config get package-lock)" == "true" ]]; then |
45 | | - npm config set package-lock false |
46 | | - else |
47 | | - npm config set shrinkwrap false |
48 | | - fi |
| 23 | + - uses: actions/checkout@v4 |
49 | 24 |
|
50 | | - - name: Install Node.js dependencies |
51 | | - run: npm install |
| 25 | + - uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: ${{ matrix.node-version }} |
| 28 | + check-latest: true |
52 | 29 |
|
53 | | - - name: List environment |
54 | | - id: list_env |
55 | | - shell: bash |
56 | | - run: | |
57 | | - echo "node@$(node -v)" |
58 | | - echo "npm@$(npm -v)" |
59 | | - npm -s ls ||: |
60 | | - (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" |
| 30 | + - name: Install Node.js dependencies |
| 31 | + run: npm install |
61 | 32 |
|
62 | | - - name: Run tests |
63 | | - shell: bash |
64 | | - run: | |
65 | | - npm run test-ci |
66 | | - cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov" |
| 33 | + - name: Run tests |
| 34 | + run: npm run test-ci |
67 | 35 |
|
68 | | - - name: Lint code |
69 | | - if: steps.list_env.outputs.eslint != '' |
70 | | - run: npm run lint |
| 36 | + - name: Lint code |
| 37 | + run: npm run lint |
71 | 38 |
|
72 | | - - name: Collect code coverage |
73 | | - run: | |
74 | | - if [[ -d ./coverage ]]; then |
75 | | - mv ./coverage "./${{ matrix.name }}" |
76 | | - mkdir ./coverage |
77 | | - mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}" |
78 | | - fi |
79 | | -
|
80 | | - - name: Upload code coverage |
81 | | - uses: actions/upload-artifact@v3 |
82 | | - with: |
83 | | - name: coverage |
84 | | - path: ./coverage |
85 | | - retention-days: 1 |
| 39 | + - name: Upload code coverage |
| 40 | + uses: actions/upload-artifact@v4 |
| 41 | + with: |
| 42 | + name: coverage-node-${{ matrix.node-version }} |
| 43 | + path: ./coverage/lcov.info |
| 44 | + retention-days: 1 |
86 | 45 |
|
87 | 46 | coverage: |
88 | 47 | needs: test |
89 | 48 | runs-on: ubuntu-latest |
| 49 | + permissions: |
| 50 | + contents: read |
| 51 | + checks: write |
90 | 52 | steps: |
91 | | - - uses: actions/checkout@v4 |
92 | | - |
93 | | - - name: Install lcov |
94 | | - shell: bash |
95 | | - run: sudo apt-get -y install lcov |
96 | | - |
97 | | - - name: Collect coverage reports |
98 | | - uses: actions/download-artifact@v3 |
99 | | - with: |
100 | | - name: coverage |
101 | | - path: ./coverage |
102 | | - |
103 | | - - name: Merge coverage reports |
104 | | - shell: bash |
105 | | - run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info |
106 | | - |
107 | | - - name: Upload coverage report |
108 | | - uses: coverallsapp/github-action@master |
109 | | - with: |
110 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Install lcov |
| 56 | + shell: bash |
| 57 | + run: sudo apt-get -y install lcov |
| 58 | + |
| 59 | + - name: Collect coverage reports |
| 60 | + uses: actions/download-artifact@v4 |
| 61 | + with: |
| 62 | + path: ./coverage |
| 63 | + pattern: coverage-node-* |
| 64 | + |
| 65 | + - name: Merge coverage reports |
| 66 | + shell: bash |
| 67 | + run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info |
| 68 | + |
| 69 | + - name: Upload coverage report |
| 70 | + uses: coverallsapp/github-action@v2 |
| 71 | + with: |
| 72 | + file: ./lcov.info |
0 commit comments