Skip to content

Commit eab99c9

Browse files
committed
migrate ci pipeline to github actions
1 parent 6842d4a commit eab99c9

File tree

4 files changed

+222
-86
lines changed

4 files changed

+222
-86
lines changed

.github/workflows/ci.yml

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

.travis.yml

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

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# resolve-path
22

3-
[![NPM Version][npm-image]][npm-url]
4-
[![NPM Downloads][downloads-image]][downloads-url]
5-
[![Node.js Version][node-image]][node-url]
6-
[![Linux Build][travis-image]][travis-url]
3+
[![NPM Version][npm-version-image]][npm-url]
4+
[![NPM Downloads][npm-downloads-image]][npm-url]
5+
[![Node.js Version][node-version-image]][node-version-url]
6+
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
77
[![Windows Build][appveyor-image]][appveyor-url]
88
[![Test Coverage][coveralls-image]][coveralls-url]
99

@@ -97,15 +97,14 @@ server.listen(3000)
9797

9898
[MIT](LICENSE)
9999

100-
[npm-image]: https://img.shields.io/npm/v/resolve-path.svg
101-
[npm-url]: https://npmjs.org/package/resolve-path
102-
[node-image]: https://img.shields.io/node/v/resolve-path.svg
103-
[node-url]: http://nodejs.org/download/
104-
[travis-image]: https://img.shields.io/travis/pillarjs/resolve-path/master.svg?label=linux
105-
[travis-url]: https://travis-ci.org/pillarjs/resolve-path
100+
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
101+
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
102+
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
103+
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
104+
[node-version-image]: https://badgen.net/npm/node/accepts
105+
[node-version-url]: https://nodejs.org/en/download
106+
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
107+
[npm-url]: https://npmjs.org/package/accepts
108+
[npm-version-image]: https://badgen.net/npm/v/accepts
106109
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/resolve-path/master.svg?label=windows
107110
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/resolve-path
108-
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/resolve-path/master.svg
109-
[coveralls-url]: https://coveralls.io/r/pillarjs/resolve-path?branch=master
110-
[downloads-image]: https://img.shields.io/npm/dm/resolve-path.svg
111-
[downloads-url]: https://npmjs.org/package/resolve-path

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"eslint-plugin-node": "8.0.1",
2121
"eslint-plugin-promise": "4.0.1",
2222
"eslint-plugin-standard": "4.0.0",
23-
"istanbul": "0.4.5",
24-
"mocha": "2.5.3"
23+
"mocha": "9.2.0",
24+
"nyc": "15.1.0"
2525
},
2626
"files": [
2727
"HISTORY.md",
@@ -34,9 +34,9 @@
3434
},
3535
"scripts": {
3636
"lint": "eslint --plugin markdown --ext js,md .",
37-
"test": "mocha --reporter spec --bail --check-leaks test/",
38-
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
39-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
37+
"test": "mocha --reporter spec --check-leaks --bail test/",
38+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
39+
"test-cov": "nyc --reporter=html --reporter=text npm test"
4040
},
4141
"keywords": [
4242
"resolve",

0 commit comments

Comments
 (0)