|
1 | 1 | name: ci |
2 | 2 |
|
3 | 3 | on: |
4 | | -- pull_request |
5 | | -- push |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - v2.x |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - v2.x |
| 10 | + workflow_dispatch: |
6 | 11 |
|
7 | 12 | permissions: |
8 | 13 | contents: read |
9 | 14 |
|
| 15 | +# Cancel in progress workflows |
| 16 | +# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run |
| 17 | +concurrency: |
| 18 | + group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" |
| 19 | + cancel-in-progress: true |
| 20 | + |
10 | 21 | jobs: |
11 | | - test: |
12 | | - permissions: |
13 | | - checks: write # for coverallsapp/github-action to create new checks |
14 | | - contents: read # for actions/checkout to fetch code |
| 22 | + lint: |
| 23 | + name: Lint |
15 | 24 | runs-on: ubuntu-latest |
16 | | - strategy: |
17 | | - matrix: |
18 | | - name: |
19 | | - - Node.js 0.8 |
20 | | - - Node.js 0.10 |
21 | | - - Node.js 0.12 |
22 | | - - io.js 1.x |
23 | | - - io.js 2.x |
24 | | - - io.js 3.x |
25 | | - - Node.js 4.x |
26 | | - - Node.js 5.x |
27 | | - - Node.js 6.x |
28 | | - - Node.js 7.x |
29 | | - - Node.js 8.x |
30 | | - - Node.js 9.x |
31 | | - - Node.js 10.x |
32 | | - - Node.js 11.x |
33 | | - - Node.js 12.x |
34 | | - - Node.js 13.x |
35 | | - - Node.js 14.x |
36 | | - - Node.js 15.x |
37 | | - - Node.js 16.x |
38 | | - - Node.js 17.x |
39 | | - - Node.js 18.x |
40 | | - - Node.js 19.x |
41 | | - - Node.js 20.x |
42 | | - - Node.js 21.x |
43 | | - - Node.js 22.x |
44 | | - - Node.js 23.x |
45 | | - - Node.js 24.x |
46 | | - |
47 | | - include: |
48 | | - - name: Node.js 0.8 |
49 | | - node-version: "0.8" |
50 | | - |
51 | | - npm-rm: nyc |
52 | | - |
53 | | - - name: Node.js 0.10 |
54 | | - node-version: "0.10" |
55 | | - |
56 | | - |
57 | | - - name: Node.js 0.12 |
58 | | - node-version: "0.12" |
59 | | - |
60 | | - |
61 | | - - name: io.js 1.x |
62 | | - node-version: "1" |
63 | | - |
64 | | - |
65 | | - - name: io.js 2.x |
66 | | - node-version: "2" |
67 | | - |
68 | | - |
69 | | - - name: io.js 3.x |
70 | | - node-version: "3" |
71 | | - |
72 | | - |
73 | | - - name: Node.js 4.x |
74 | | - node-version: "4" |
75 | | - |
76 | | - |
77 | | - - name: Node.js 5.x |
78 | | - node-version: "5" |
79 | | - |
80 | | - |
81 | | - - name: Node.js 6.x |
82 | | - node-version: "6" |
83 | | - |
84 | | - |
85 | | - - name: Node.js 7.x |
86 | | - node-version: "7" |
87 | | - |
88 | | - |
89 | | - - name: Node.js 8.x |
90 | | - node-version: "8" |
91 | | - |
92 | | - |
93 | | - - name: Node.js 9.x |
94 | | - node-version: "9" |
95 | | - |
96 | | - |
97 | | - - name: Node.js 10.x |
98 | | - node-version: "10" |
99 | | - |
100 | | - |
101 | | - - name: Node.js 11.x |
102 | | - node-version: "11" |
103 | | - |
104 | | - |
105 | | - - name: Node.js 12.x |
106 | | - node-version: "12" |
107 | | - |
108 | | - |
109 | | - - name: Node.js 13.x |
110 | | - node-version: "13" |
111 | | - |
112 | | - |
113 | | - - name: Node.js 14.x |
114 | | - node-version: "14" |
115 | | - |
116 | | - |
117 | | - - name: Node.js 15.x |
118 | | - node-version: "15" |
119 | | - |
120 | | - |
121 | | - - name: Node.js 16.x |
122 | | - node-version: "16" |
123 | | - |
124 | | - |
125 | | - - name: Node.js 17.x |
126 | | - node-version: "17" |
127 | | - |
128 | | - |
129 | | - - name: Node.js 18.x |
130 | | - node-version: "18" |
131 | | - |
132 | | - - name: Node.js 19.x |
133 | | - node-version: "19" |
134 | | - |
135 | | - - name: Node.js 20.x |
136 | | - node-version: "20" |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 27 | + with: |
| 28 | + persist-credentials: false |
| 29 | + - name: Setup Node.js |
| 30 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
| 31 | + with: |
| 32 | + node-version: 'lts/*' |
137 | 33 |
|
138 | | - - name: Node.js 21.x |
139 | | - node-version: "21" |
| 34 | + - name: Install dependencies |
| 35 | + run: npm install --ignore-scripts --include=dev |
140 | 36 |
|
141 | | - - name: Node.js 22.x |
142 | | - node-version: "22" |
| 37 | + - name: Run lint |
| 38 | + run: npm run lint |
143 | 39 |
|
144 | | - - name: Node.js 23.x |
145 | | - node-version: "23" |
| 40 | + test: |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + os: [ubuntu-latest, windows-latest] |
| 45 | + node-version: [18, 19, 20, 21, 22, 23, 24, 25] |
| 46 | + # Node.js release schedule: https://nodejs.org/en/about/releases/ |
146 | 47 |
|
147 | | - - name: Node.js 24.x |
148 | | - node-version: "24" |
| 48 | + name: Node.js ${{ matrix.node-version }} - ${{matrix.os}} |
149 | 49 |
|
| 50 | + runs-on: ${{ matrix.os }} |
150 | 51 | steps: |
151 | | - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
152 | | - |
153 | | - - name: Install Node.js ${{ matrix.node-version }} |
154 | | - shell: bash -eo pipefail -l {0} |
155 | | - run: | |
156 | | - nvm install --default ${{ matrix.node-version }} |
157 | | - if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then |
158 | | - nvm install --alias=npm 0.10 |
159 | | - nvm use ${{ matrix.node-version }} |
160 | | - if [[ "$(npm -v)" == 1.1.* ]]; then |
161 | | - nvm exec npm npm install -g [email protected] |
162 | | - ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" |
163 | | - else |
164 | | - sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" |
165 | | - fi |
166 | | - npm config set strict-ssl false |
167 | | - fi |
168 | | - dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" |
169 | | -
|
170 | | - - name: Configure npm |
171 | | - run: | |
172 | | - if [[ "$(npm config get package-lock)" == "true" ]]; then |
173 | | - npm config set package-lock false |
174 | | - else |
175 | | - npm config set shrinkwrap false |
176 | | - fi |
177 | | -
|
178 | | - - name: Remove npm module(s) ${{ matrix.npm-rm }} |
179 | | - if: matrix.npm-rm != '' |
180 | | - run: npm rm --silent --save-dev ${{ matrix.npm-rm }} |
181 | | - |
182 | | - - name: Install npm module(s) ${{ matrix.npm-i }} |
183 | | - if: matrix.npm-i != '' |
184 | | - run: npm install --save-dev ${{ matrix.npm-i }} |
185 | | - |
186 | | - - name: Setup Node.js version-specific dependencies |
187 | | - shell: bash |
188 | | - run: | |
189 | | - # eslint for linting |
190 | | - # - remove on Node.js < 12 |
191 | | - if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then |
192 | | - node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ |
193 | | - grep -E '^eslint(-|$)' | \ |
194 | | - sort -r | \ |
195 | | - xargs -n1 npm rm --silent --save-dev |
196 | | - fi |
197 | | -
|
198 | | - - name: Install Node.js dependencies |
199 | | - run: npm install |
200 | | - |
201 | | - - name: List environment |
202 | | - id: list_env |
203 | | - shell: bash |
204 | | - run: | |
205 | | - echo "node@$(node -v)" |
206 | | - echo "npm@$(npm -v)" |
207 | | - npm -s ls ||: |
208 | | - (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" |
209 | | -
|
210 | | - - name: Run tests |
211 | | - shell: bash |
212 | | - run: | |
213 | | - if npm -ps ls nyc | grep -q nyc; then |
214 | | - npm run test-ci |
215 | | - else |
216 | | - npm test |
217 | | - fi |
218 | | -
|
219 | | - - name: Lint code |
220 | | - if: steps.list_env.outputs.eslint != '' |
221 | | - run: npm run lint |
222 | | - |
223 | | - - name: Collect code coverage |
224 | | - uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # master |
225 | | - if: steps.list_env.outputs.nyc != '' |
226 | | - with: |
227 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
228 | | - flag-name: run-${{ matrix.test_number }} |
229 | | - parallel: true |
| 52 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 53 | + with: |
| 54 | + persist-credentials: false |
| 55 | + |
| 56 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 57 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
| 58 | + with: |
| 59 | + node-version: ${{ matrix.node-version }} |
| 60 | + |
| 61 | + - name: Configure npm loglevel |
| 62 | + run: | |
| 63 | + npm config set loglevel error |
| 64 | + shell: bash |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: npm install |
| 68 | + |
| 69 | + - name: Output Node and NPM versions |
| 70 | + run: | |
| 71 | + echo "Node.js version: $(node -v)" |
| 72 | + echo "NPM version: $(npm -v)" |
| 73 | +
|
| 74 | + - name: Run tests |
| 75 | + shell: bash |
| 76 | + run: npm run test-ci |
| 77 | + |
| 78 | + - name: Upload code coverage |
| 79 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 80 | + with: |
| 81 | + name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }} |
| 82 | + path: ./coverage/lcov.info |
| 83 | + retention-days: 1 |
230 | 84 |
|
231 | 85 | coverage: |
232 | | - permissions: |
233 | | - checks: write # for coverallsapp/github-action to create new checks |
234 | 86 | needs: test |
235 | 87 | runs-on: ubuntu-latest |
| 88 | + permissions: |
| 89 | + contents: read |
| 90 | + checks: write |
236 | 91 | steps: |
237 | | - - name: Upload code coverage |
238 | | - uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # master |
239 | | - with: |
240 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
241 | | - parallel-finished: true |
| 92 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 93 | + with: |
| 94 | + persist-credentials: false |
| 95 | + |
| 96 | + - name: Install lcov |
| 97 | + shell: bash |
| 98 | + run: sudo apt-get -y install lcov |
| 99 | + |
| 100 | + - name: Collect coverage reports |
| 101 | + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 102 | + with: |
| 103 | + path: ./coverage |
| 104 | + pattern: coverage-node-* |
| 105 | + |
| 106 | + - name: Merge coverage reports |
| 107 | + shell: bash |
| 108 | + run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info |
| 109 | + |
| 110 | + - name: Upload coverage report |
| 111 | + uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 |
| 112 | + with: |
| 113 | + file: ./lcov.info |
0 commit comments