Skip to content

Commit 2f6d5cc

Browse files
committed
build: use GitHub Actions instead of Travis CI
1 parent 804a840 commit 2f6d5cc

File tree

4 files changed

+168
-81
lines changed

4 files changed

+168
-81
lines changed

.github/workflows/ci.yml

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

.travis.yml

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

88
Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
@@ -116,11 +116,11 @@ bytes(1024);
116116

117117
[MIT](LICENSE)
118118

119+
[ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci
120+
[ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci
119121
[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
120122
[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
121123
[downloads-image]: https://badgen.net/npm/dm/bytes
122124
[downloads-url]: https://npmjs.org/package/bytes
123125
[npm-image]: https://badgen.net/npm/v/bytes
124126
[npm-url]: https://npmjs.org/package/bytes
125-
[travis-image]: https://badgen.net/travis/visionmedia/bytes.js/master
126-
[travis-url]: https://travis-ci.org/visionmedia/bytes.js

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"scripts": {
3636
"lint": "eslint .",
3737
"test": "mocha --check-leaks --reporter spec",
38-
"test-ci": "nyc --reporter=text npm test",
38+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
3939
"test-cov": "nyc --reporter=html --reporter=text npm test"
4040
}
4141
}

0 commit comments

Comments
 (0)