Skip to content

Commit b6a5e5a

Browse files
committed
build: use GitHub Actions instead of Travis CI
1 parent a42215a commit b6a5e5a

File tree

4 files changed

+204
-117
lines changed

4 files changed

+204
-117
lines changed

.github/workflows/ci.yml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
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+
- Node.js 15.x
32+
- Node.js 16.x
33+
34+
include:
35+
- name: Node.js 0.6
36+
node-version: "0.6"
37+
38+
npm-rm: nyc
39+
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+
- name: Node.js 11.x
93+
node-version: "11.15"
94+
95+
- name: Node.js 12.x
96+
node-version: "12.22"
97+
98+
- name: Node.js 13.x
99+
node-version: "13.14"
100+
101+
- name: Node.js 14.x
102+
node-version: "14.17"
103+
104+
- name: Node.js 15.x
105+
node-version: "15.14"
106+
107+
- name: Node.js 16.x
108+
node-version: "16.3"
109+
110+
steps:
111+
- uses: actions/checkout@v2
112+
113+
- name: Install Node.js ${{ matrix.node-version }}
114+
shell: bash -eo pipefail -l {0}
115+
run: |
116+
if [[ "${{ matrix.node-version }}" == 0.6* ]]; then
117+
sudo apt-get install g++-4.8 gcc-4.8 libssl1.0-dev
118+
export CC=/usr/bin/gcc-4.8
119+
export CXX=/usr/bin/g++-4.8
120+
fi
121+
nvm install --default ${{ matrix.node-version }}
122+
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
123+
nvm install --alias=npm 0.10
124+
nvm use ${{ matrix.node-version }}
125+
if [[ "$(npm -v)" == 1.1.* ]]; then
126+
nvm exec npm npm install -g [email protected]
127+
ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
128+
else
129+
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
130+
fi
131+
npm config set strict-ssl false
132+
fi
133+
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
134+
135+
- name: Configure npm
136+
run: npm config set shrinkwrap false
137+
138+
- name: Remove npm module(s) ${{ matrix.npm-rm }}
139+
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
140+
if: matrix.npm-rm != ''
141+
142+
- name: Install npm module(s) ${{ matrix.npm-i }}
143+
run: npm install --save-dev ${{ matrix.npm-i }}
144+
if: matrix.npm-i != ''
145+
146+
- name: Setup Node.js version-specific dependencies
147+
shell: bash
148+
run: |
149+
# eslint for linting
150+
# - remove on Node.js < 10
151+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
152+
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
153+
grep -E '^eslint(-|$)' | \
154+
sort -r | \
155+
xargs -n1 npm rm --silent --save-dev
156+
fi
157+
158+
- name: Install Node.js dependencies
159+
run: npm install
160+
161+
- name: List environment
162+
id: list_env
163+
shell: bash
164+
run: |
165+
echo "node@$(node -v)"
166+
echo "npm@$(npm -v)"
167+
npm -s ls ||:
168+
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }'
169+
170+
- name: Run tests
171+
shell: bash
172+
run: |
173+
if npm -ps ls nyc | grep -q nyc; then
174+
npm run test-ci
175+
else
176+
npm test
177+
fi
178+
179+
- name: Lint code
180+
if: steps.list_env.outputs.eslint != ''
181+
run: npm run lint
182+
183+
- name: Collect code coverage
184+
uses: coverallsapp/github-action@master
185+
if: steps.list_env.outputs.nyc != ''
186+
with:
187+
github-token: ${{ secrets.GITHUB_TOKEN }}
188+
flag-name: run-${{ matrix.test_number }}
189+
parallel: true
190+
191+
coverage:
192+
needs: test
193+
runs-on: ubuntu-latest
194+
steps:
195+
- name: Upload code coverage
196+
uses: coverallsapp/github-action@master
197+
with:
198+
github-token: ${{ secrets.GITHUB_TOKEN }}
199+
parallel-finished: true

.travis.yml

Lines changed: 0 additions & 112 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][github-actions-ci-image]][github-actions-ci-url]
77
[![Test Coverage][coveralls-image]][coveralls-url]
88

99
An HTTP content negotiator for Node.js
@@ -195,9 +195,9 @@ and more.
195195
[npm-url]: https://npmjs.org/package/negotiator
196196
[node-version-image]: https://img.shields.io/node/v/negotiator.svg
197197
[node-version-url]: https://nodejs.org/en/download/
198-
[travis-image]: https://img.shields.io/travis/jshttp/negotiator/master.svg
199-
[travis-url]: https://travis-ci.org/jshttp/negotiator
200198
[coveralls-image]: https://img.shields.io/coveralls/jshttp/negotiator/master.svg
201199
[coveralls-url]: https://coveralls.io/r/jshttp/negotiator?branch=master
202200
[downloads-image]: https://img.shields.io/npm/dm/negotiator.svg
203201
[downloads-url]: https://npmjs.org/package/negotiator
202+
[github-actions-ci-image]: https://img.shields.io/github/workflow/status/jshttp/negotiator/ci/master?label=ci
203+
[github-actions-ci-url]: https://github.com/jshttp/negotiator/actions/workflows/ci.yml

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"scripts": {
3737
"lint": "eslint .",
3838
"test": "mocha --reporter spec --check-leaks --bail test/",
39-
"test-cov": "nyc --reporter=html --reporter=text npm test",
40-
"test-travis": "nyc --reporter=text npm test"
39+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
40+
"test-cov": "nyc --reporter=html --reporter=text npm test"
4141
}
4242
}

0 commit comments

Comments
 (0)