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