Skip to content

Commit cc9e20a

Browse files
committed
migrate CI pipeline to GitHub actions
1 parent 34ef1ba commit cc9e20a

File tree

4 files changed

+243
-127
lines changed

4 files changed

+243
-127
lines changed

.github/workflows/ci.yml

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

.travis.yml

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

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
[![NPM Version][npm-version-image]][npm-url]
44
[![NPM Downloads][npm-downloads-image]][npm-url]
5-
[![Node.js Version][node-version-image]][node-version-url]
6-
[![Build Status][travis-image]][travis-url]
7-
[![Test Coverage][coveralls-image]][coveralls-url]
5+
[![Node.js Version][node-image]][node-url]
6+
[![Build Status][ci-image]][ci-url]
7+
[![Coverage Status][coveralls-image]][coveralls-url]
88

99
Execute a listener when a response is about to write headers.
1010

@@ -70,12 +70,12 @@ $ npm test
7070

7171
[MIT](LICENSE)
7272

73-
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/on-headers/master
74-
[coveralls-url]: https://coveralls.io/r/jshttp/on-headers?branch=master
75-
[node-version-image]: https://badgen.net/npm/node/on-headers
76-
[node-version-url]: https://nodejs.org/en/download
77-
[npm-downloads-image]: https://badgen.net/npm/dm/on-headers
78-
[npm-url]: https://npmjs.org/package/on-headers
79-
[npm-version-image]: https://badgen.net/npm/v/on-headers
80-
[travis-image]: https://badgen.net/travis/jshttp/on-headers/master
81-
[travis-url]: https://travis-ci.org/jshttp/on-headers
73+
[ci-image]: https://badgen.net/github/checks/jshttp/methods/master?label=ci
74+
[ci-url]: https://github.com/jshttp/methods/actions/workflows/ci.yml
75+
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/methods/master
76+
[coveralls-url]: https://coveralls.io/r/jshttp/methods?branch=master
77+
[node-image]: https://badgen.net/npm/node/methods
78+
[node-url]: https://nodejs.org/en/download
79+
[npm-downloads-image]: https://badgen.net/npm/dm/methods
80+
[npm-url]: https://npmjs.org/package/methods
81+
[npm-version-image]: https://badgen.net/npm/v/methods

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"eslint-plugin-node": "11.1.0",
2020
"eslint-plugin-promise": "4.2.1",
2121
"eslint-plugin-standard": "4.0.1",
22-
"istanbul": "0.4.5",
23-
"mocha": "8.0.1",
22+
"mocha": "10.2.0",
23+
"nyc": "15.1.0",
2424
"supertest": "4.0.2"
2525
},
2626
"files": [
@@ -35,8 +35,8 @@
3535
"scripts": {
3636
"lint": "eslint --plugin markdown --ext js,md .",
3737
"test": "mocha --reporter spec --bail --check-leaks test/",
38-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
39-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
38+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
39+
"test-cov": "nyc --reporter=html --reporter=text npm test",
4040
"version": "node scripts/version-history.js && git add HISTORY.md"
4141
}
4242
}

0 commit comments

Comments
 (0)