Skip to content

Commit cd9d9bf

Browse files
authored
ci: migrate to GitHub Actions CI (#20)
1 parent dae06ff commit cd9d9bf

File tree

4 files changed

+270
-41
lines changed

4 files changed

+270
-41
lines changed

.github/workflows/ci.yml

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
name: ci
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
lint:
13+
name: Lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- name: Setup Node.js
18+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
19+
with:
20+
node-version: "lts/*"
21+
22+
- name: Install dependencies
23+
run: npm install --ignore-scripts --only=dev
24+
25+
- name: Run lint
26+
run: npm run lint
27+
28+
test:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
name:
34+
- Node.js 0.8
35+
- Node.js 0.10
36+
- Node.js 0.12
37+
- io.js 1.x
38+
- io.js 2.x
39+
- io.js 3.x
40+
- Node.js 4.x
41+
- Node.js 5.x
42+
- Node.js 6.x
43+
- Node.js 7.x
44+
- Node.js 8.x
45+
- Node.js 9.x
46+
- Node.js 10.x
47+
- Node.js 11.x
48+
- Node.js 12.x
49+
- Node.js 13.x
50+
- Node.js 14.x
51+
- Node.js 15.x
52+
- Node.js 16.x
53+
- Node.js 17.x
54+
- Node.js 18.x
55+
- Node.js 19.x
56+
- Node.js 20.x
57+
- Node.js 21.x
58+
- Node.js 22.x
59+
- Node.js 23.x
60+
- Node.js 24.x
61+
62+
include:
63+
- name: Node.js 0.8
64+
node-version: "0.8"
65+
npm-i: mocha@2.5.3
66+
npm-rm: nyc
67+
68+
- name: Node.js 0.10
69+
node-version: "0.10"
70+
npm-i: mocha@3.5.3 nyc@10.3.2
71+
72+
- name: Node.js 0.12
73+
node-version: "0.12"
74+
npm-i: mocha@3.5.3 nyc@10.3.2
75+
76+
- name: io.js 1.x
77+
node-version: "1.8"
78+
npm-i: mocha@3.5.3 nyc@10.3.2
79+
80+
- name: io.js 2.x
81+
node-version: "2.5"
82+
npm-i: mocha@3.5.3 nyc@10.3.2
83+
84+
- name: io.js 3.x
85+
node-version: "3.3"
86+
npm-i: mocha@3.5.3 nyc@10.3.2
87+
88+
- name: Node.js 4.x
89+
node-version: "4"
90+
npm-i: mocha@5.2.0 nyc@11.9.0
91+
92+
- name: Node.js 5.x
93+
node-version: "5"
94+
npm-i: mocha@5.2.0 nyc@11.9.0
95+
96+
- name: Node.js 6.x
97+
node-version: "6"
98+
npm-i: mocha@6.2.3 nyc@14.1.1
99+
100+
- name: Node.js 7.x
101+
node-version: "7"
102+
npm-i: mocha@6.2.3 nyc@14.1.1
103+
104+
- name: Node.js 8.x
105+
node-version: "8"
106+
npm-i: mocha@7.2.0 nyc@14.1.1
107+
108+
- name: Node.js 9.x
109+
node-version: "9"
110+
npm-i: mocha@7.2.0 nyc@14.1.1
111+
112+
- name: Node.js 10.x
113+
node-version: "10"
114+
npm-i: mocha@8.4.0 nyc@15.1.0
115+
116+
- name: Node.js 11.x
117+
node-version: "11"
118+
npm-i: mocha@8.4.0 nyc@15.1.0
119+
120+
- name: Node.js 12.x
121+
node-version: "12"
122+
npm-i: mocha@9.2.2 nyc@15.1.0
123+
124+
- name: Node.js 13.x
125+
node-version: "13"
126+
npm-i: mocha@9.2.2 nyc@15.1.0
127+
128+
- name: Node.js 14.x
129+
node-version: "14"
130+
npm-i: mocha@10.8.2 nyc@15.1.0
131+
132+
- name: Node.js 15.x
133+
node-version: "15"
134+
npm-i: mocha@9.2.2 nyc@15.1.0
135+
136+
- name: Node.js 16.x
137+
node-version: "16"
138+
npm-i: mocha@9.2.2 nyc@15.1.0
139+
140+
- name: Node.js 17.x
141+
node-version: "17"
142+
npm-i: mocha@9.2.2 nyc@15.1.0
143+
144+
- name: Node.js 18.x
145+
node-version: "18"
146+
147+
- name: Node.js 19.x
148+
node-version: "19"
149+
150+
- name: Node.js 20.x
151+
node-version: "20"
152+
153+
- name: Node.js 21.x
154+
node-version: "21"
155+
156+
- name: Node.js 22.x
157+
node-version: "22"
158+
159+
- name: Node.js 23.x
160+
node-version: "23"
161+
162+
- name: Node.js 24.x
163+
node-version: "24"
164+
165+
steps:
166+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
167+
168+
- name: Install Node.js ${{ matrix.node-version }}
169+
shell: bash -eo pipefail -l {0}
170+
run: |
171+
nvm install --default ${{ matrix.node-version }}
172+
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
173+
nvm install --alias=npm 0.10
174+
nvm use ${{ matrix.node-version }}
175+
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
176+
npm config set strict-ssl false
177+
fi
178+
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
179+
180+
- name: Configure npm
181+
run: |
182+
if [[ "$(npm config get package-lock)" == "true" ]]; then
183+
npm config set package-lock false
184+
else
185+
npm config set shrinkwrap false
186+
fi
187+
188+
- name: Remove npm module(s) ${{ matrix.npm-rm }}
189+
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
190+
if: matrix.npm-rm != ''
191+
192+
- name: Install npm module(s) ${{ matrix.npm-i }}
193+
run: npm install --save-dev ${{ matrix.npm-i }}
194+
if: matrix.npm-i != ''
195+
196+
- name: Setup Node.js version-specific dependencies
197+
shell: bash
198+
run: |
199+
# eslint for linting
200+
# - remove on Node.js < 10
201+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
202+
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
203+
grep -E '^eslint(-|$)' | \
204+
sort -r | \
205+
xargs -n1 npm rm --silent --save-dev
206+
fi
207+
208+
- name: Install Node.js dependencies
209+
run: npm install
210+
211+
- name: List environment
212+
id: list_env
213+
shell: bash
214+
run: |
215+
echo "node@$(node -v)"
216+
echo "npm@$(npm -v)"
217+
npm -s ls ||:
218+
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
219+
220+
- name: Run tests
221+
shell: bash
222+
run: |
223+
if npm -ps ls nyc | grep -q nyc; then
224+
npm run test-ci
225+
else
226+
npm test
227+
fi
228+
229+
- name: Upload code coverage
230+
if: steps.list_env.outputs.nyc != ''
231+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
232+
with:
233+
name: coverage-node-${{ matrix.node-version }}
234+
path: ./coverage/lcov.info
235+
retention-days: 1
236+
237+
coverage:
238+
needs: test
239+
runs-on: ubuntu-latest
240+
permissions:
241+
contents: read
242+
checks: write
243+
steps:
244+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
245+
246+
- name: Install lcov
247+
shell: bash
248+
run: sudo apt-get -y install lcov
249+
250+
- name: Collect coverage reports
251+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
252+
with:
253+
path: ./coverage
254+
pattern: coverage-node-*
255+
256+
- name: Merge coverage reports
257+
shell: bash
258+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
259+
260+
- name: Upload coverage report
261+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
262+
with:
263+
github-token: ${{ secrets.GITHUB_TOKEN }}
264+
file: ./lcov.info

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ coverage/
22
node_modules/
33
npm-debug.log
44
package-lock.json
5+
.nyc_output/

.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"eslint-plugin-node": "7.0.1",
2424
"eslint-plugin-promise": "4.0.1",
2525
"eslint-plugin-standard": "4.0.0",
26-
"istanbul": "0.4.5",
27-
"mocha": "2.5.3"
26+
"mocha": "~11.7.0",
27+
"nyc": "~17.1.0"
2828
},
2929
"files": [
3030
"LICENSE",
@@ -37,8 +37,8 @@
3737
},
3838
"scripts": {
3939
"lint": "eslint .",
40-
"test": "mocha --reporter spec --bail --check-leaks test/",
41-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
42-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
40+
"test": "mocha --check-leaks --reporter spec",
41+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
42+
"test-cov": "nyc --reporter=html --reporter=text npm test"
4343
}
4444
}

0 commit comments

Comments
 (0)