Skip to content

Commit 3300c30

Browse files
committed
improve ci workflow
1 parent 544279a commit 3300c30

File tree

4 files changed

+82
-135
lines changed

4 files changed

+82
-135
lines changed

.github/workflows/ci.yml

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
11
name: ci
22

33
on:
4-
- pull_request
5-
- push
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- '*.md'
9+
pull_request:
10+
paths-ignore:
11+
- '*.md'
12+
13+
# Cancel in progress workflows
14+
# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run
15+
concurrency:
16+
group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
17+
cancel-in-progress: true
618

719
jobs:
20+
lint:
21+
name: Lint
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 'lts/*'
29+
30+
- name: Install dependencies
31+
run: npm install --ignore-scripts --only=dev
32+
33+
- name: Run lint
34+
run: npm run lint
35+
836
test:
9-
runs-on: ubuntu-20.04
1037
strategy:
38+
fail-fast: false
1139
matrix:
40+
os: [ubuntu-latest, windows-latest]
1241
name:
1342
- Node.js 0.8
1443
- Node.js 0.10
@@ -35,6 +64,7 @@ jobs:
3564
- Node.js 20.x
3665
- Node.js 21.x
3766
- Node.js 22.x
67+
- Node.js 23.x
3868

3969
include:
4070
- name: Node.js 0.8
@@ -107,51 +137,48 @@ jobs:
107137
npm-i: supertest@6.1.3
108138

109139
- name: Node.js 15.x
110-
node-version: "15.14"
140+
node-version: "15"
111141
npm-i: supertest@6.1.3
112142

113143
- name: Node.js 16.x
114-
node-version: "16.20"
144+
node-version: "16"
115145
npm-i: supertest@6.1.3
116146

117147
- name: Node.js 17.x
118-
node-version: "17.9"
148+
node-version: "17"
119149
npm-i: supertest@6.1.3
120150

121151
- name: Node.js 18.x
122-
node-version: "18.18"
152+
node-version: "18"
123153

124154
- name: Node.js 19.x
125-
node-version: "19.9"
155+
node-version: "19"
126156

127157
- name: Node.js 20.x
128-
node-version: "20.9"
158+
node-version: "20"
129159

130160
- name: Node.js 21.x
131-
node-version: "21.1"
161+
node-version: "21"
132162

133163
- name: Node.js 22.x
134-
node-version: "22.0"
164+
node-version: "22"
135165

166+
- name: Node.js 23.x
167+
node-version: "23"
168+
runs-on: ${{ matrix.os }}
136169
steps:
137170
- uses: actions/checkout@v4
171+
with:
172+
persist-credentials: false
138173

139-
- name: Install Node.js ${{ matrix.node-version }}
140-
shell: bash -eo pipefail -l {0}
141-
run: |
142-
nvm install --default ${{ matrix.node-version }}
143-
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
144-
nvm install --alias=npm 0.10
145-
nvm use ${{ matrix.node-version }}
146-
if [[ "$(npm -v)" == 1.1.* ]]; then
147-
nvm exec npm npm install -g npm@1.1
148-
ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
149-
else
150-
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
151-
fi
152-
npm config set strict-ssl false
153-
fi
154-
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
174+
- name: Setup Node.js ${{ matrix.node-version }}
175+
uses: actions/setup-node@v4
176+
with:
177+
node-version: ${{ matrix.node-version }}
178+
179+
- name: Npm version fixes
180+
if: ${{matrix.npm-version != ''}}
181+
run: npm install -g ${{ matrix.npm-version }}
155182

156183
- name: Configure npm
157184
run: |
@@ -202,24 +229,39 @@ jobs:
202229
npm test
203230
fi
204231
205-
- name: Lint code
206-
if: steps.list_env.outputs.eslint != ''
207-
run: npm run lint
208-
209-
- name: Collect code coverage
210-
uses: coverallsapp/github-action@master
232+
- name: Upload code coverage
211233
if: steps.list_env.outputs.nyc != ''
234+
uses: actions/upload-artifact@v4
212235
with:
213-
github-token: ${{ secrets.GITHUB_TOKEN }}
214-
flag-name: run-${{ matrix.test_number }}
215-
parallel: true
236+
name: coverage-node-${{ matrix.node-version }}
237+
path: ./coverage/lcov.info
238+
retention-days: 1
216239

217240
coverage:
218241
needs: test
219242
runs-on: ubuntu-latest
243+
permissions:
244+
contents: read
245+
checks: write
220246
steps:
221-
- name: Upload code coverage
222-
uses: coverallsapp/github-action@master
247+
- uses: actions/checkout@v4
248+
249+
- name: Install lcov
250+
shell: bash
251+
run: sudo apt-get -y install lcov
252+
253+
- name: Collect coverage reports
254+
uses: actions/download-artifact@v4
255+
with:
256+
path: ./coverage
257+
pattern: coverage-node-*
258+
259+
- name: Merge coverage reports
260+
shell: bash
261+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
262+
263+
- name: Upload coverage report
264+
uses: coverallsapp/github-action@v2
223265
with:
224266
github-token: ${{ secrets.GITHUB_TOKEN }}
225-
parallel-finished: true
267+
file: ./lcov.info

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[![NPM Version][npm-image]][npm-url]
44
[![NPM Downloads][downloads-image]][downloads-url]
55
[![Linux Build Status][ci-image]][ci-url]
6-
[![Windows Build][appveyor-image]][appveyor-url]
76
[![Coverage Status][coveralls-image]][coveralls-url]
87

98
Serves pages that contain directory listings for a given path.
@@ -139,8 +138,6 @@ app.listen(3000)
139138
[MIT](LICENSE). The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons
140139
are created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).
141140

142-
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-index/master.svg?label=windows
143-
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-index
144141
[ci-image]: https://badgen.net/github/checks/expressjs/serve-index/master?label=ci
145142
[ci-url]: https://github.com/expressjs/serve-index/actions/workflows/ci.yml
146143
[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-index/master.svg

appveyor.yml

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"scripts": {
3535
"lint": "eslint .",
36-
"test": "mocha --reporter spec --bail --check-leaks test/",
36+
"test": "mocha --reporter spec --check-leaks test/",
3737
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
3838
"test-cov": "nyc --reporter=html --reporter=text npm test"
3939
}

0 commit comments

Comments
 (0)