Skip to content

Commit 5242fff

Browse files
committed
update ci
1 parent ba984a1 commit 5242fff

File tree

2 files changed

+86
-55
lines changed

2 files changed

+86
-55
lines changed

.github/workflows/ci.yml

+85-54
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,47 @@
11
name: ci
22

33
on:
4-
- pull_request
5-
- push
4+
pull_request:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- '*.md'
9+
push:
10+
paths-ignore:
11+
- '*.md'
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
621

722
jobs:
23+
lint:
24+
name: Lint
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 'lts/*'
32+
33+
- name: Install dependencies
34+
run: npm install --ignore-scripts --only=dev
35+
36+
- name: Run lint
37+
run: npm run lint
38+
839
test:
940
runs-on: ubuntu-20.04
1041
strategy:
42+
fail-fast: false
1143
matrix:
1244
name:
13-
- Node.js 0.6
1445
- Node.js 0.8
1546
- Node.js 0.10
1647
- Node.js 0.12
@@ -33,13 +64,12 @@ jobs:
3364
- Node.js 17.x
3465
- Node.js 18.x
3566
- Node.js 19.x
67+
- Node.js 20.x
68+
- Node.js 21.x
69+
- Node.js 22.x
70+
- Node.js 23.x
3671

3772
include:
38-
- name: Node.js 0.6
39-
node-version: "0.6"
40-
41-
npm-rm: nyc
42-
4373
- name: Node.js 0.8
4474
node-version: "0.8"
4575
@@ -66,65 +96,75 @@ jobs:
6696
6797

6898
- name: Node.js 4.x
69-
node-version: "4.9"
99+
node-version: "4"
70100
71101

72102
- name: Node.js 5.x
73-
node-version: "5.12"
103+
node-version: "5"
74104
75105

76106
- name: Node.js 6.x
77-
node-version: "6.17"
78-
107+
node-version: "6"
108+
79109

80110
- name: Node.js 7.x
81-
node-version: "7.10"
82-
111+
node-version: "7"
112+
83113

84114
- name: Node.js 8.x
85-
node-version: "8.17"
115+
node-version: "8"
86116
87117

88118
- name: Node.js 9.x
89-
node-version: "9.11"
119+
node-version: "9"
90120
91121

92122
- name: Node.js 10.x
93-
node-version: "10.24"
123+
node-version: "10"
94124
95125

96126
- name: Node.js 11.x
97-
node-version: "11.15"
127+
node-version: "11"
98128
99129

100130
- name: Node.js 12.x
101-
node-version: "12.22"
102-
131+
node-version: "12"
103132

104133
- name: Node.js 13.x
105-
node-version: "13.14"
106-
134+
node-version: "13"
107135

108136
- name: Node.js 14.x
109-
node-version: "14.21"
137+
node-version: "14"
110138

111139
- name: Node.js 15.x
112-
node-version: "15.14"
140+
node-version: "15"
113141

114142
- name: Node.js 16.x
115-
node-version: "16.19"
143+
node-version: "16"
116144

117145
- name: Node.js 17.x
118-
node-version: "17.9"
146+
node-version: "17"
119147

120148
- name: Node.js 18.x
121-
node-version: "18.14"
149+
node-version: "18"
122150

123151
- name: Node.js 19.x
124-
node-version: "19.6"
152+
node-version: "19"
153+
154+
- name: Node.js 20.x
155+
node-version: "20"
156+
157+
- name: Node.js 21.x
158+
node-version: "21"
159+
160+
- name: Node.js 22.x
161+
node-version: "22"
162+
163+
- name: Node.js 23.x
164+
node-version: "23"
125165

126166
steps:
127-
- uses: actions/checkout@v3
167+
- uses: actions/checkout@v4
128168

129169
- name: Install Node.js ${{ matrix.node-version }}
130170
shell: bash -eo pipefail -l {0}
@@ -141,6 +181,7 @@ jobs:
141181
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
142182
nvm install --alias=npm 0.10
143183
nvm use ${{ matrix.node-version }}
184+
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
144185
if [[ "$(npm -v)" == 1.1.* ]]; then
145186
nvm exec npm npm install -g [email protected]
146187
ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
@@ -176,8 +217,8 @@ jobs:
176217
shell: bash
177218
run: |
178219
# eslint for linting
179-
# - remove on Node.js < 12
180-
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
220+
# - remove on Node.js < 10
221+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
181222
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
182223
grep -E '^eslint(-|$)' | \
183224
sort -r | \
@@ -194,60 +235,50 @@ jobs:
194235
echo "node@$(node -v)"
195236
echo "npm@$(npm -v)"
196237
npm -s ls ||:
197-
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
238+
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }'
198239
199240
- name: Run tests
200241
shell: bash
201242
run: |
202243
if npm -ps ls nyc | grep -q nyc; then
203244
npm run test-ci
204-
cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov"
205245
else
206246
npm test
207247
fi
208248
209-
- name: Lint code
210-
if: steps.list_env.outputs.eslint != ''
211-
run: npm run lint
212-
213-
- name: Collect code coverage
214-
if: steps.list_env.outputs.nyc != ''
215-
run: |
216-
if [[ -d ./coverage ]]; then
217-
mv ./coverage "./${{ matrix.name }}"
218-
mkdir ./coverage
219-
mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}"
220-
fi
221-
222249
- name: Upload code coverage
223-
uses: actions/upload-artifact@v3
224250
if: steps.list_env.outputs.nyc != ''
251+
uses: actions/upload-artifact@v4
225252
with:
226-
name: coverage
227-
path: ./coverage
253+
name: coverage-node-${{ matrix.node-version }}
254+
path: ./coverage/lcov.info
228255
retention-days: 1
229256

230257
coverage:
231258
needs: test
232259
runs-on: ubuntu-latest
260+
permissions:
261+
contents: read
262+
checks: write
233263
steps:
234-
- uses: actions/checkout@v3
264+
- uses: actions/checkout@v4
235265

236266
- name: Install lcov
237267
shell: bash
238268
run: sudo apt-get -y install lcov
239269

240270
- name: Collect coverage reports
241-
uses: actions/download-artifact@v3
271+
uses: actions/download-artifact@v4
242272
with:
243-
name: coverage
244273
path: ./coverage
274+
pattern: coverage-node-*
245275

246276
- name: Merge coverage reports
247277
shell: bash
248-
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
278+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
249279

250280
- name: Upload coverage report
251-
uses: coverallsapp/github-action@master
281+
uses: coverallsapp/github-action@v2
252282
with:
253283
github-token: ${{ secrets.GITHUB_TOKEN }}
284+
file: ./lcov.info

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"build": "node scripts/build",
4848
"fetch": "node scripts/fetch-apache && node scripts/fetch-iana && node scripts/fetch-nginx",
4949
"lint": "eslint .",
50-
"test": "mocha --reporter spec --bail --check-leaks test/",
50+
"test": "mocha --reporter spec --check-leaks test/",
5151
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
5252
"test-cov": "nyc --reporter=html --reporter=text npm test",
5353
"update": "npm run fetch && npm run build",

0 commit comments

Comments
 (0)