Skip to content

Commit da11cc8

Browse files
committed
build: use GitHub Actions instead of Travis CI
1 parent 4b5db12 commit da11cc8

File tree

4 files changed

+184
-115
lines changed

4 files changed

+184
-115
lines changed

.github/workflows/ci.yml

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: ci
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
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+
33+
include:
34+
- name: Node.js 0.8
35+
node-version: "0.8"
36+
npm-i: mocha@2.5.3 supertest@1.1.0
37+
npm-rm: nyc
38+
39+
- name: Node.js 0.10
40+
node-version: "0.10"
41+
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0
42+
43+
- name: Node.js 0.12
44+
node-version: "0.12"
45+
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0
46+
47+
- name: io.js 1.x
48+
node-version: "1.8"
49+
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0
50+
51+
- name: io.js 2.x
52+
node-version: "2.5"
53+
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0
54+
55+
- name: io.js 3.x
56+
node-version: "3.3"
57+
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0
58+
59+
- name: Node.js 4.x
60+
node-version: "4.9"
61+
npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2
62+
63+
- name: Node.js 5.x
64+
node-version: "5.12"
65+
npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2
66+
67+
- name: Node.js 6.x
68+
node-version: "6.17"
69+
npm-i: mocha@6.2.2 nyc@14.1.1
70+
71+
- name: Node.js 7.x
72+
node-version: "7.10"
73+
npm-i: mocha@6.2.2 nyc@14.1.1
74+
75+
- name: Node.js 8.x
76+
node-version: "8.17"
77+
npm-i: mocha@7.2.0
78+
79+
- name: Node.js 9.x
80+
node-version: "9.11"
81+
npm-i: mocha@7.2.0
82+
83+
- name: Node.js 10.x
84+
node-version: "10.24"
85+
86+
- name: Node.js 11.x
87+
node-version: "11.15"
88+
89+
- name: Node.js 12.x
90+
node-version: "12.22"
91+
92+
- name: Node.js 13.x
93+
node-version: "13.14"
94+
95+
- name: Node.js 14.x
96+
node-version: "14.17"
97+
98+
- name: Node.js 15.x
99+
node-version: "15.14"
100+
101+
- name: Node.js 16.x
102+
node-version: "16.1"
103+
104+
steps:
105+
- uses: actions/checkout@v2
106+
107+
- name: Install Node.js ${{ matrix.node-version }}
108+
shell: bash -l {0}
109+
run: |
110+
nvm install --default ${{ matrix.node-version }}
111+
if [[ "${{ matrix.node-version }}" == 0.* ]]; then
112+
npm config set strict-ssl false
113+
fi
114+
dirname "$(npm which)" >> "$GITHUB_PATH"
115+
116+
- name: Configure npm
117+
run: npm config set shrinkwrap false
118+
119+
- name: Remove npm module(s) ${{ matrix.npm-rm }}
120+
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
121+
if: matrix.npm-rm != ''
122+
123+
- name: Install npm module(s) ${{ matrix.npm-i }}
124+
run: npm install --save-dev ${{ matrix.npm-i }}
125+
if: matrix.npm-i != ''
126+
127+
- name: Setup Node.js version-specific dependencies
128+
shell: bash
129+
run: |
130+
# eslint for linting
131+
# - remove on Node.js < 10
132+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
133+
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
134+
grep -E '^eslint(-|$)' | \
135+
sort -r | \
136+
xargs -n1 npm rm --silent --save-dev
137+
fi
138+
139+
- name: Install Node.js dependencies
140+
run: npm install
141+
142+
- name: List environment
143+
id: list_env
144+
shell: bash
145+
run: |
146+
echo "node@$(node -v)"
147+
echo "npm@$(npm -v)"
148+
npm -s ls
149+
npm -s ls --depth=0 | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }'
150+
151+
- name: Run tests
152+
shell: bash
153+
run: |
154+
if npm -ps ls nyc | grep -q nyc; then
155+
npm run test-ci
156+
else
157+
npm test
158+
fi
159+
160+
- name: Lint code
161+
if: steps.list_env.outputs.eslint != ''
162+
run: npm run lint
163+
164+
- name: Collect code coverage
165+
uses: coverallsapp/github-action@master
166+
if: steps.list_env.outputs.nyc != ''
167+
with:
168+
github-token: ${{ secrets.GITHUB_TOKEN }}
169+
flag-name: run-${{ matrix.test_number }}
170+
parallel: true
171+
172+
coverage:
173+
needs: test
174+
runs-on: ubuntu-latest
175+
steps:
176+
- name: Upload code coverage
177+
uses: coverallsapp/github-action@master
178+
with:
179+
github-token: ${{ secrets.github_token }}
180+
parallel-finished: true

.travis.yml

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![NPM Version][npm-image]][npm-url]
44
[![NPM Downloads][downloads-image]][downloads-url]
55
[![Node.js Version][node-version-image]][node-version-url]
6-
[![Build Status][travis-image]][travis-url]
6+
[![Build Status][ci-image]][ci-url]
77
[![Test Coverage][coveralls-image]][coveralls-url]
88

99
Simple middleware-style router
@@ -381,12 +381,12 @@ server.listen(8080)
381381

382382
[MIT](LICENSE)
383383

384+
[ci-image]: https://badgen.net/github/checks/pillarjs/router/master?label=ci
385+
[ci-url]: https://github.com/pillarjs/router/actions?query=workflow%3Aci
384386
[npm-image]: https://img.shields.io/npm/v/router.svg
385387
[npm-url]: https://npmjs.org/package/router
386388
[node-version-image]: https://img.shields.io/node/v/router.svg
387389
[node-version-url]: http://nodejs.org/download/
388-
[travis-image]: https://img.shields.io/travis/pillarjs/router/master.svg
389-
[travis-url]: https://travis-ci.org/pillarjs/router
390390
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/router/master.svg
391391
[coveralls-url]: https://coveralls.io/r/pillarjs/router?branch=master
392392
[downloads-image]: https://img.shields.io/npm/dm/router.svg

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"scripts": {
4141
"lint": "eslint .",
4242
"test": "mocha --reporter spec --bail --check-leaks test/",
43-
"test-ci": "nyc --reporter=html --reporter=text npm test",
43+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
4444
"test-cov": "nyc --reporter=text npm test",
4545
"version": "node scripts/version-history.js && git add HISTORY.md"
4646
}

0 commit comments

Comments
 (0)