Skip to content

Commit 7dc8621

Browse files
authored
ci: migrate ci pipeline to github actions (#59)
PR-URL: #59
1 parent 270611d commit 7dc8621

File tree

4 files changed

+237
-93
lines changed

4 files changed

+237
-93
lines changed

.github/workflows/ci.yml

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

.travis.yml

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

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# basic-auth
22

3-
[![NPM Version][npm-image]][npm-url]
4-
[![NPM Downloads][downloads-image]][downloads-url]
5-
[![Node.js Version][node-version-image]][node-version-url]
6-
[![Build Status][travis-image]][travis-url]
7-
[![Test Coverage][coveralls-image]][coveralls-url]
3+
[![NPM Version][npm-version-image]][npm-url]
4+
[![NPM Downloads][npm-downloads-image]][npm-url]
5+
[![Node.js Version][node-image]][node-url]
6+
[![Build Status][ci-image]][ci-url]
7+
[![Coverage Status][coveralls-image]][coveralls-url]
88

99
Generic basic auth Authorization header field parser for whatever.
1010

@@ -101,13 +101,12 @@ server.listen(3000)
101101

102102
[MIT](LICENSE)
103103

104+
[ci-image]: https://badgen.net/github/checks/jshttp/basic-auth/master?label=ci
105+
[ci-url]: https://github.com/jshttp/basic-auth/actions/workflows/ci.yml
104106
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/basic-auth/master
105107
[coveralls-url]: https://coveralls.io/r/jshttp/basic-auth?branch=master
106-
[downloads-image]: https://badgen.net/npm/dm/basic-auth
107-
[downloads-url]: https://npmjs.org/package/basic-auth
108-
[node-version-image]: https://badgen.net/npm/node/basic-auth
109-
[node-version-url]: https://nodejs.org/en/download
110-
[npm-image]: https://badgen.net/npm/v/basic-auth
108+
[node-image]: https://badgen.net/npm/node/basic-auth
109+
[node-url]: https://nodejs.org/en/download
110+
[npm-downloads-image]: https://badgen.net/npm/dm/basic-auth
111111
[npm-url]: https://npmjs.org/package/basic-auth
112-
[travis-image]: https://badgen.net/travis/jshttp/basic-auth/master
113-
[travis-url]: https://travis-ci.org/jshttp/basic-auth
112+
[npm-version-image]: https://badgen.net/npm/v/basic-auth

package.json

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

0 commit comments

Comments
 (0)