Skip to content

Commit c65e1c4

Browse files
committed
👷 add CI
1 parent e9cf316 commit c65e1c4

File tree

4 files changed

+250
-36
lines changed

4 files changed

+250
-36
lines changed

‎.github/workflows/ci.yml‎

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

‎.travis.yml‎

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

‎package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"eslint-plugin-node": "4.2.2",
2323
"eslint-plugin-promise": "3.5.0",
2424
"eslint-plugin-standard": "3.0.1",
25-
"istanbul": "0.4.5",
2625
"mocha": "2.5.3",
26+
"nyc": "15.1.0",
2727
"supertest": "1.1.0"
2828
},
2929
"files": [
@@ -36,8 +36,8 @@
3636
},
3737
"scripts": {
3838
"lint": "eslint --plugin markdown --ext js,md .",
39-
"test": "mocha --reporter spec --bail --check-leaks test/",
40-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
41-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot --check-leaks test/"
39+
"test": "mocha --reporter spec --check-leaks test/",
40+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
41+
"test-cov": "nyc --reporter=html --reporter=text npm test"
4242
}
4343
}

‎test/test.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ describe('timeout()', function () {
4343
it('should respond with 503 Request timeout', function (done) {
4444
var server = createServer(null, null, function (req, res) {
4545
assert.ok(req.timedout)
46-
res.end('Hello')
46+
if (!(res.finished || res.writableEnded)) {
47+
// check response is writable for node 14
48+
res.end('Hello')
49+
}
4750
})
4851

4952
request(server)
@@ -54,7 +57,10 @@ describe('timeout()', function () {
5457
it('should pass the error to next()', function (done) {
5558
var server = createServer(null, null, function (req, res) {
5659
assert.ok(req.timedout)
57-
res.end('Hello')
60+
if (!(res.finished || res.writableEnded)) {
61+
// check response is writable for node 14
62+
res.end('Hello')
63+
}
5864
})
5965

6066
request(server)

0 commit comments

Comments
 (0)