Skip to content

Commit b072a1b

Browse files
authored
ci:update ci pipeline with newer Node.js versions and use nyc for coverage (#17)
PR-URL: #17
1 parent 4780638 commit b072a1b

File tree

2 files changed

+69
-30
lines changed

2 files changed

+69
-30
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,56 +29,62 @@ jobs:
2929
- Node.js 14.x
3030
- Node.js 15.x
3131
- Node.js 16.x
32+
- Node.js 17.x
33+
- Node.js 18.x
34+
- Node.js 19.x
35+
- Node.js 20.x
36+
- Node.js 21.x
37+
- Node.js 22.x
3238

3339
include:
3440
- name: Node.js 0.8
3541
node-version: "0.8"
3642
37-
npm-rm: istanbul
43+
npm-rm: nyc
3844

3945
- name: Node.js 0.10
4046
node-version: "0.10"
41-
47+
4248

4349
- name: Node.js 0.12
4450
node-version: "0.12"
45-
51+
4652

4753
- name: io.js 1.x
4854
node-version: "1.8"
49-
55+
5056

5157
- name: io.js 2.x
5258
node-version: "2.5"
53-
59+
5460

5561
- name: io.js 3.x
5662
node-version: "3.3"
57-
63+
5864

5965
- name: Node.js 4.x
6066
node-version: "4.9"
61-
67+
6268

6369
- name: Node.js 5.x
6470
node-version: "5.12"
65-
71+
6672

6773
- name: Node.js 6.x
6874
node-version: "6.17"
69-
75+
7076

7177
- name: Node.js 7.x
7278
node-version: "7.10"
73-
79+
7480

7581
- name: Node.js 8.x
76-
node-version: "8.16"
77-
npm-i: mocha@7.2.0
82+
node-version: "8.17"
83+
npm-i: mocha@7.1.2 [email protected]
7884

7985
- name: Node.js 9.x
8086
node-version: "9.11"
81-
npm-i: mocha@7.2.0
87+
npm-i: mocha@7.1.2 [email protected]
8288

8389
- name: Node.js 10.x
8490
node-version: "10.24"
@@ -90,33 +96,66 @@ jobs:
9096

9197
- name: Node.js 12.x
9298
node-version: "12.22"
99+
93100

94101
- name: Node.js 13.x
95102
node-version: "13.14"
103+
96104

97105
- name: Node.js 14.x
98-
node-version: "14.17"
106+
node-version: "14.21"
99107

100108
- name: Node.js 15.x
101109
node-version: "15.14"
102110

103111
- name: Node.js 16.x
104-
node-version: "16.7"
112+
node-version: "16.20"
113+
114+
- name: Node.js 17.x
115+
node-version: "17.9"
116+
117+
- name: Node.js 18.x
118+
node-version: "18.20"
119+
120+
- name: Node.js 19.x
121+
node-version: "19.9"
122+
123+
- name: Node.js 20.x
124+
node-version: "20.13"
125+
126+
- name: Node.js 21.x
127+
node-version: "21.7"
128+
129+
- name: Node.js 22.x
130+
node-version: "22.1"
105131

106132
steps:
107-
- uses: actions/checkout@v2
133+
- uses: actions/checkout@v4
108134

109135
- name: Install Node.js ${{ matrix.node-version }}
110136
shell: bash -eo pipefail -l {0}
111137
run: |
112138
nvm install --default ${{ matrix.node-version }}
113-
if [[ "${{ matrix.node-version }}" == 0.* ]]; then
139+
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
140+
nvm install --alias=npm 0.10
141+
nvm use ${{ matrix.node-version }}
142+
if [[ "$(npm -v)" == 1.1.* ]]; then
143+
nvm exec npm npm install -g [email protected]
144+
ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
145+
else
146+
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
147+
fi
114148
npm config set strict-ssl false
115149
fi
116150
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
117151
118152
- name: Configure npm
119-
run: npm config set shrinkwrap false
153+
run: |
154+
if [[ "$(npm config get package-lock)" == "true" ]]; then
155+
npm config set package-lock false
156+
else
157+
npm config set shrinkwrap false
158+
fi
120159
121160
- name: Remove npm module(s) ${{ matrix.npm-rm }}
122161
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
@@ -130,8 +169,8 @@ jobs:
130169
shell: bash
131170
run: |
132171
# eslint for linting
133-
# - remove on Node.js < 10
134-
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
172+
# - remove on Node.js < 12
173+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
135174
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
136175
grep -E '^eslint(-|$)' | \
137176
sort -r | \
@@ -148,12 +187,12 @@ jobs:
148187
echo "node@$(node -v)"
149188
echo "npm@$(npm -v)"
150189
npm -s ls ||:
151-
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }'
190+
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
152191
153192
- name: Run tests
154193
shell: bash
155194
run: |
156-
if npm -ps ls istanbul | grep -q istanbul; then
195+
if npm -ps ls nyc | grep -q nyc; then
157196
npm run test-ci
158197
else
159198
npm test
@@ -165,7 +204,7 @@ jobs:
165204

166205
- name: Collect code coverage
167206
uses: coverallsapp/github-action@master
168-
if: steps.list_env.outputs.istanbul != ''
207+
if: steps.list_env.outputs.nyc != ''
169208
with:
170209
github-token: ${{ secrets.GITHUB_TOKEN }}
171210
flag-name: run-${{ matrix.test_number }}
@@ -175,8 +214,8 @@ jobs:
175214
needs: test
176215
runs-on: ubuntu-latest
177216
steps:
178-
- name: Uploade code coverage
217+
- name: Upload code coverage
179218
uses: coverallsapp/github-action@master
180219
with:
181-
github-token: ${{ secrets.github_token }}
220+
github-token: ${{ secrets.GITHUB_TOKEN }}
182221
parallel-finished: true

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"eslint-plugin-node": "11.1.0",
2121
"eslint-plugin-promise": "4.3.1",
2222
"eslint-plugin-standard": "4.1.0",
23-
"istanbul": "0.4.5",
24-
"mocha": "9.1.0"
23+
"mocha": "10.2.0",
24+
"nyc": "15.1.0"
2525
},
2626
"files": [
2727
"HISTORY.md",
@@ -33,9 +33,9 @@
3333
"node": ">= 0.8"
3434
},
3535
"scripts": {
36-
"lint": "eslint .",
36+
"lint": "eslint --plugin markdown --ext js,md .",
3737
"test": "mocha --reporter spec --bail --check-leaks test/",
38-
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
39-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
38+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
39+
"test-cov": "nyc --reporter=html --reporter=text npm test"
4040
}
4141
}

0 commit comments

Comments
 (0)