Skip to content

Commit 30c948b

Browse files
nanotowerCopilot
andauthored
ci: migrate CI from Travis to GitHub Actions (#53)
Co-authored-by: nanotower <50929081+nanotower@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent dbee8da commit 30c948b

3 files changed

Lines changed: 256 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- '*.md'
9+
pull_request:
10+
paths-ignore:
11+
- '*.md'
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
name:
20+
- Node.js 0.8
21+
- Node.js 0.10
22+
- Node.js 0.12
23+
- io.js 1.x
24+
- io.js 2.x
25+
- io.js 3.x
26+
- Node.js 4.x
27+
- Node.js 5.x
28+
- Node.js 6.x
29+
- Node.js 7.x
30+
- Node.js 8.x
31+
- Node.js 9.x
32+
- Node.js 10.x
33+
- Node.js 11.x
34+
- Node.js 12.x
35+
- Node.js 13.x
36+
- Node.js 14.x
37+
- Node.js 15.x
38+
- Node.js 16.x
39+
- Node.js 17.x
40+
- Node.js 18.x
41+
- Node.js 19.x
42+
- Node.js 20.x
43+
- Node.js 21.x
44+
- Node.js 22.x
45+
- Node.js 23.x
46+
- Node.js 24.x
47+
- Node.js 25.x
48+
49+
include:
50+
- name: Node.js 0.8
51+
node-version: "0.8"
52+
npm-i: mocha@2.5.3 supertest@1.1.0
53+
npm-rm: istanbul
54+
55+
- name: Node.js 0.10
56+
node-version: "0.10"
57+
npm-i: mocha@3.5.3 supertest@2.0.0
58+
npm-rm: istanbul
59+
60+
- name: Node.js 0.12
61+
node-version: "0.12"
62+
npm-i: mocha@3.5.3 supertest@2.0.0
63+
npm-rm: istanbul
64+
65+
- name: io.js 1.x
66+
node-version: "1"
67+
npm-i: mocha@3.5.3 supertest@2.0.0
68+
npm-rm: istanbul
69+
70+
- name: io.js 2.x
71+
node-version: "2"
72+
npm-i: mocha@3.5.3 supertest@2.0.0
73+
npm-rm: istanbul
74+
75+
- name: io.js 3.x
76+
node-version: "3"
77+
npm-i: mocha@3.5.3 supertest@2.0.0
78+
npm-rm: istanbul
79+
80+
- name: Node.js 4.x
81+
node-version: "4"
82+
npm-i: mocha@5.2.0 supertest@3.4.2
83+
84+
- name: Node.js 5.x
85+
node-version: "5"
86+
npm-i: mocha@5.2.0 supertest@3.4.2
87+
88+
- name: Node.js 6.x
89+
node-version: "6"
90+
npm-i: mocha@6.2.2
91+
92+
- name: Node.js 7.x
93+
node-version: "7"
94+
npm-i: mocha@6.2.2
95+
96+
- name: Node.js 8.x
97+
node-version: "8"
98+
99+
- name: Node.js 9.x
100+
node-version: "9"
101+
102+
- name: Node.js 10.x
103+
node-version: "10"
104+
105+
- name: Node.js 11.x
106+
node-version: "11"
107+
108+
- name: Node.js 12.x
109+
node-version: "12"
110+
111+
- name: Node.js 13.x
112+
node-version: "13"
113+
114+
- name: Node.js 14.x
115+
node-version: "14"
116+
117+
- name: Node.js 15.x
118+
node-version: "15"
119+
120+
- name: Node.js 16.x
121+
node-version: "16"
122+
123+
- name: Node.js 17.x
124+
node-version: "17"
125+
126+
- name: Node.js 18.x
127+
node-version: "18"
128+
129+
- name: Node.js 19.x
130+
node-version: "19"
131+
132+
- name: Node.js 20.x
133+
node-version: "20"
134+
135+
- name: Node.js 21.x
136+
node-version: "21"
137+
138+
- name: Node.js 22.x
139+
node-version: "22"
140+
141+
- name: Node.js 23.x
142+
node-version: "23"
143+
144+
- name: Node.js 24.x
145+
node-version: "24"
146+
147+
- name: Node.js 25.x
148+
node-version: "25"
149+
150+
steps:
151+
- uses: actions/checkout@v6
152+
153+
- name: Install Node.js ${{ matrix.node-version }}
154+
shell: bash -eo pipefail -l {0}
155+
run: |
156+
nvm install --default ${{ matrix.node-version }}
157+
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
158+
nvm install --alias=npm 0.10
159+
nvm use ${{ matrix.node-version }}
160+
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
161+
npm config set strict-ssl false
162+
npm install -g --prefix "$(which node)/../.." npm@1.2.8000
163+
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
164+
fi
165+
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
166+
167+
- name: Configure npm
168+
run: |
169+
if [[ "$(npm config get package-lock)" == "true" ]]; then
170+
npm config set package-lock false
171+
else
172+
npm config set shrinkwrap false
173+
fi
174+
175+
- name: Remove npm module(s) ${{ matrix.npm-rm }}
176+
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
177+
if: matrix.npm-rm != ''
178+
179+
- name: Install npm module(s) ${{ matrix.npm-i }}
180+
run: npm install --save-dev ${{ matrix.npm-i }}
181+
if: matrix.npm-i != ''
182+
183+
- name: Setup Node.js version-specific dependencies
184+
shell: bash
185+
run: |
186+
# eslint for linting
187+
# - remove on Node.js < 12
188+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
189+
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
190+
grep -E '^eslint(-|$)' | \
191+
sort -r | \
192+
xargs -n1 npm rm --silent --save-dev
193+
fi
194+
195+
- name: Install Node.js dependencies
196+
run: npm install
197+
198+
- name: List environment
199+
id: list_env
200+
shell: bash
201+
run: |
202+
echo "node@$(node -v)"
203+
echo "npm@$(npm -v)"
204+
npm -s ls ||:
205+
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
206+
207+
- name: Run tests
208+
shell: bash
209+
run: |
210+
if npm -ps ls istanbul | grep -q istanbul; then
211+
npm run test-ci
212+
cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov"
213+
else
214+
npm test
215+
fi
216+
217+
- name: Lint code
218+
if: steps.list_env.outputs.eslint != ''
219+
run: npm run lint
220+
221+
- name: Upload code coverage
222+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
223+
with:
224+
name: coverage-node-${{ matrix.node-version }}
225+
path: ./coverage/lcov.info
226+
retention-days: 1
227+
228+
coverage:
229+
needs: test
230+
runs-on: ubuntu-latest
231+
permissions:
232+
contents: read
233+
checks: write
234+
steps:
235+
- uses: actions/checkout@v6
236+
237+
- name: Install lcov
238+
shell: bash
239+
run: sudo apt-get -y install lcov
240+
241+
- name: Collect coverage reports
242+
uses: actions/download-artifact@v6
243+
with:
244+
path: ./coverage
245+
pattern: coverage-node-*
246+
247+
- name: Merge coverage reports
248+
shell: bash
249+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
250+
251+
- name: Upload coverage report
252+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
253+
with:
254+
file: ./lcov.info

README.md

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

33
[![NPM Version][npm-version-image]][npm-url]
44
[![NPM Downloads][npm-downloads-image]][npm-url]
5-
[![Build Status][travis-image]][travis-url]
5+
<a href="https://github.com/nanotower/errorhandler/actions/workflows/ci.yml"><img src="https://github.com/nanotower/errorhandler/actions/workflows/ci.yml/badge.svg"></a>
66
[![Test Coverage][coveralls-image]][coveralls-url]
77

88
Development-only error handler middleware.
@@ -126,5 +126,3 @@ function errorNotification (err, str, req) {
126126
[npm-downloads-image]: https://badgen.net/npm/dm/errorhandler
127127
[npm-url]: https://npmjs.org/package/errorhandler
128128
[npm-version-image]: https://badgen.net/npm/v/errorhandler
129-
[travis-image]: https://badgen.net/travis/expressjs/errorhandler/master
130-
[travis-url]: https://travis-ci.org/expressjs/errorhandler

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
"lint": "eslint --plugin markdown --ext js,md .",
4343
"test": "mocha --reporter spec --bail --check-leaks test/",
4444
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
45-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
45+
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
4646
}
4747
}

0 commit comments

Comments
 (0)