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