Skip to content

Commit aa0d24b

Browse files
committed
migrate ci pipeline to github actions
1 parent 9894c00 commit aa0d24b

File tree

4 files changed

+232
-86
lines changed

4 files changed

+232
-86
lines changed

.github/workflows/ci.yml

+214
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
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+
npm-i: mocha@2.5.3
40+
npm-rm: nyc
41+
42+
- name: Node.js 0.10
43+
node-version: "0.10"
44+
npm-i: mocha@3.5.3 nyc@10.3.2
45+
npm-rm: nyc
46+
47+
- name: Node.js 0.12
48+
node-version: "0.12"
49+
npm-i: mocha@3.5.3 nyc@10.3.2
50+
npm-rm: nyc
51+
52+
- name: Node.js 4.x
53+
node-version: "4"
54+
npm-i: mocha@5.2.0 nyc@11.9.0
55+
npm-rm: nyc
56+
57+
- name: Node.js 5.x
58+
node-version: "5"
59+
npm-i: mocha@5.2.0 nyc@11.9.0
60+
npm-rm: nyc
61+
62+
- name: Node.js 6.x
63+
node-version: "6"
64+
npm-i: mocha@6.2.3 nyc@14.1.1
65+
npm-rm: nyc
66+
67+
- name: Node.js 7.x
68+
node-version: "7"
69+
npm-i: mocha@6.2.3 nyc@14.1.1
70+
npm-rm: nyc
71+
72+
- name: Node.js 8.x
73+
node-version: "8"
74+
npm-i: mocha@7.2.0 nyc@14.1.1
75+
npm-rm: nyc
76+
77+
- name: Node.js 9.x
78+
node-version: "9"
79+
npm-i: mocha@7.2.0 nyc@14.1.1
80+
npm-rm: nyc
81+
82+
- name: Node.js 10.x
83+
node-version: "10"
84+
npm-i: mocha@8.4.0
85+
npm-rm: nyc
86+
87+
- name: Node.js 11.x
88+
node-version: "11"
89+
npm-i: mocha@8.4.0
90+
npm-rm: nyc
91+
92+
- name: Node.js 12.x
93+
node-version: "12"
94+
95+
- name: Node.js 13.x
96+
node-version: "13"
97+
98+
- name: Node.js 14.x
99+
node-version: "14"
100+
101+
- name: Node.js 15.x
102+
node-version: "15"
103+
104+
- name: Node.js 16.x
105+
node-version: "16"
106+
107+
- name: Node.js 17.x
108+
node-version: "17"
109+
110+
- name: Node.js 18.x
111+
node-version: "18"
112+
113+
- name: Node.js 19.x
114+
node-version: "19"
115+
116+
- name: Node.js 20.x
117+
node-version: "20"
118+
119+
- name: Node.js 21.x
120+
node-version: "21"
121+
122+
- name: Node.js 22.x
123+
node-version: "22"
124+
125+
steps:
126+
- uses: actions/checkout@v4
127+
128+
- name: Configure npm
129+
run: |
130+
if [[ "$(npm config get package-lock)" == "true" ]]; then
131+
npm config set package-lock false
132+
else
133+
npm config set shrinkwrap false
134+
fi
135+
136+
- name: Setup Node.js version-specific dependencies
137+
shell: bash
138+
run: |
139+
# eslint for linting
140+
# - remove on Node.js < 12
141+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; 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: Remove npm module(s) ${{ matrix.npm-rm }}
149+
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
150+
if: matrix.npm-rm != ''
151+
152+
- name: Install npm module(s) ${{ matrix.npm-i }}
153+
run: npm install --save-dev ${{ matrix.npm-i }}
154+
if: matrix.npm-i != ''
155+
156+
- name: Install Node.js dependencies
157+
run: npm install
158+
159+
- name: List environment
160+
id: list_env
161+
shell: bash
162+
run: |
163+
echo "node@$(node -v)"
164+
echo "npm@$(npm -v)"
165+
npm -s ls ||:
166+
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
167+
168+
- name: Run tests
169+
shell: bash
170+
run: |
171+
if npm -ps ls nyc | grep -q nyc; then
172+
npm run test-ci
173+
else
174+
npm test
175+
fi
176+
177+
- name: Lint code
178+
if: steps.list_env.outputs.eslint != ''
179+
run: npm run lint
180+
181+
- name: Collect code coverage
182+
if: steps.list_env.outputs.nyc != ''
183+
run: |
184+
mv ./coverage "./${{ matrix.node-version }}"
185+
mkdir ./coverage
186+
mv "./${{ matrix.node-version }}" "./coverage/${{ matrix.node-version }}"
187+
188+
- name: Upload code coverage
189+
uses: actions/upload-artifact@v3
190+
with:
191+
name: coverage
192+
path: ./coverage
193+
retention-days: 1
194+
195+
coverage:
196+
needs: test
197+
runs-on: ubuntu-latest
198+
steps:
199+
- uses: actions/checkout@v4
200+
- name: Install lcov
201+
shell: bash
202+
run: sudo apt-get -y install lcov
203+
- name: Collect coverage reports
204+
uses: actions/download-artifact@v3
205+
with:
206+
name: coverage
207+
path: ./coverage
208+
- name: Merge coverage reports
209+
shell: bash
210+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
211+
- name: Upload coverage report
212+
uses: coverallsapp/github-action@master
213+
with:
214+
github-token: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

-67
This file was deleted.

README.md

+13-14
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

+5-5
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)