Skip to content

Commit 6d674ad

Browse files
committed
build: use GitHub Actions instead of Travis CI
1 parent c1f4388 commit 6d674ad

File tree

3 files changed

+192
-114
lines changed

3 files changed

+192
-114
lines changed

.github/workflows/ci.yml

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

.travis.yml

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

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![NPM Version][npm-version-image]][npm-url]
44
[![NPM Downloads][npm-downloads-image]][npm-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
Infer the content-type of a request.
@@ -159,6 +159,8 @@ app.use(function bodyParser (req, res, next) {
159159

160160
[MIT](LICENSE)
161161

162+
[ci-image]: https://badgen.net/github/checks/jshttp/type-is/master?label=ci
163+
[ci-url]: https://github.com/jshttp/type-is/actions/workflows/ci.yml
162164
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/type-is/master
163165
[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master
164166
[node-version-image]: https://badgen.net/npm/node/type-is

0 commit comments

Comments
 (0)