Skip to content

Commit 9712f0c

Browse files
committed
build: use GitHub Actions instead of Travis CI
1 parent 3fea81d commit 9712f0c

File tree

4 files changed

+168
-112
lines changed

4 files changed

+168
-112
lines changed

.github/workflows/ci.yml

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

.travis.yml

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

README.md

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

33
[![NPM Version][npm-image]][npm-url]
44
[![NPM Downloads][downloads-image]][downloads-url]
5-
[![Build Status][travis-image]][travis-url]
5+
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
66
[![Test Coverage][coveralls-image]][coveralls-url]
77

88
Node.js compression middleware.
@@ -232,9 +232,9 @@ app.get('/events', function (req, res) {
232232

233233
[npm-image]: https://img.shields.io/npm/v/compression.svg
234234
[npm-url]: https://npmjs.org/package/compression
235-
[travis-image]: https://img.shields.io/travis/expressjs/compression/master.svg
236-
[travis-url]: https://travis-ci.org/expressjs/compression
237235
[coveralls-image]: https://img.shields.io/coveralls/expressjs/compression/master.svg
238236
[coveralls-url]: https://coveralls.io/r/expressjs/compression?branch=master
239237
[downloads-image]: https://img.shields.io/npm/dm/compression.svg
240238
[downloads-url]: https://npmjs.org/package/compression
239+
[github-actions-ci-image]: https://badgen.net/github/checks/expressjs/compression/master?label=ci
240+
[github-actions-ci-url]: https://github.com/expressjs/compression/actions?query=workflow%3Aci

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"scripts": {
4242
"lint": "eslint --plugin markdown --ext js,md .",
4343
"test": "mocha --check-leaks --reporter spec --bail",
44-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot",
45-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec"
44+
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec",
45+
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot"
4646
}
4747
}

0 commit comments

Comments
 (0)