Skip to content

Commit b764cbd

Browse files
committed
Updated CI Workflow from #53
1 parent 3d328f9 commit b764cbd

File tree

1 file changed

+92
-47
lines changed

1 file changed

+92
-47
lines changed

.github/workflows/ci.yml

+92-47
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
11
name: ci
22

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

722
jobs:
23+
lint:
24+
name: Lint
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 'lts/*'
32+
33+
- name: Install dependencies
34+
run: npm install --ignore-scripts --only=dev
35+
36+
- name: Run lint
37+
run: npm run lint
38+
839
test:
940
runs-on: ubuntu-latest
1041
strategy:
42+
fail-fast: false
1143
matrix:
1244
name:
1345
- Node.js 0.8
@@ -34,6 +66,11 @@ jobs:
3466
- Node.js 16.x
3567
- Node.js 17.x
3668
- Node.js 18.x
69+
- Node.js 19.x
70+
- Node.js 20.x
71+
- Node.js 21.x
72+
- Node.js 22.x
73+
- Node.js 23.x
3774

3875
include:
3976
- name: Node.js 0.8
@@ -62,27 +99,27 @@ jobs:
6299
63100

64101
- name: Node.js 4.x
65-
node-version: "4.9"
102+
node-version: "4"
66103
67104

68105
- name: Node.js 5.x
69-
node-version: "5.12"
106+
node-version: "5"
70107
71108

72109
- name: Node.js 6.x
73-
node-version: "6.17"
74-
110+
node-version: "6"
111+
75112

76113
- name: Node.js 7.x
77-
node-version: "7.10"
78-
114+
node-version: "7"
115+
79116

80117
- name: Node.js 8.0
81118
node-version: "8.0"
82119
83120

84121
- name: Node.js 8.x
85-
node-version: "8.17"
122+
node-version: "8"
86123
87124

88125
# test fail on Node.js 9.x for unknown reasons
@@ -91,38 +128,51 @@ jobs:
91128
# node-version: "9.11"
92129
93130
- name: Node.js 10.x
94-
node-version: "10.24"
131+
node-version: "10"
95132
96133

97134
- name: Node.js 11.x
98-
node-version: "11.15"
99-
npm-i: mocha@9.2.2
135+
node-version: "11"
136+
npm-i: mocha@8.4.0
100137

101138
- name: Node.js 12.x
102-
node-version: "12.22"
103-
139+
node-version: "12"
104140

105141
- name: Node.js 13.x
106-
node-version: "13.14"
142+
node-version: "13"
107143

108144
- name: Node.js 14.x
109-
node-version: "14.19"
145+
node-version: "14"
110146

111147
- name: Node.js 15.x
112-
node-version: "15.14"
148+
node-version: "15"
113149

114150
- name: Node.js 16.x
115-
node-version: "16.15"
151+
node-version: "16"
116152

117153
- name: Node.js 17.x
118-
node-version: "17.9"
154+
node-version: "17"
119155

120156
- name: Node.js 18.x
121-
node-version: "18.1"
157+
node-version: "18"
122158

123-
steps:
124-
- uses: actions/checkout@v2
159+
- name: Node.js 19.x
160+
node-version: "19"
161+
162+
- name: Node.js 20.x
163+
node-version: "20"
164+
165+
- name: Node.js 21.x
166+
node-version: "21"
167+
168+
- name: Node.js 22.x
169+
node-version: "22"
125170

171+
- name: Node.js 23.x
172+
node-version: "23"
173+
174+
steps:
175+
- uses: actions/checkout@v4
126176
- name: Install Node.js ${{ matrix.node-version }}
127177
shell: bash -eo pipefail -l {0}
128178
run: |
@@ -136,7 +186,12 @@ jobs:
136186
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
137187
138188
- name: Configure npm
139-
run: npm config set shrinkwrap false
189+
run: |
190+
if [[ "$(npm config get package-lock)" == "true" ]]; then
191+
npm config set package-lock false
192+
else
193+
npm config set shrinkwrap false
194+
fi
140195
141196
- name: Remove npm module(s) ${{ matrix.npm-rm }}
142197
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
@@ -150,8 +205,8 @@ jobs:
150205
shell: bash
151206
run: |
152207
# eslint for linting
153-
# - remove on Node.js < 12
154-
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
208+
# - remove on Node.js < 10
209+
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
155210
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
156211
grep -E '^eslint(-|$)' | \
157212
sort -r | \
@@ -175,53 +230,43 @@ jobs:
175230
run: |
176231
if npm -ps ls nyc | grep -q nyc; then
177232
npm run test-ci
178-
cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov"
179233
else
180234
npm test
181235
fi
182236
183-
- name: Lint code
184-
if: steps.list_env.outputs.eslint != ''
185-
run: npm run lint
186-
187-
- name: Collect code coverage
188-
if: steps.list_env.outputs.nyc != ''
189-
run: |
190-
if [[ -d ./coverage ]]; then
191-
mv ./coverage "./${{ matrix.name }}"
192-
mkdir ./coverage
193-
mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}"
194-
fi
195-
196237
- name: Upload code coverage
197-
uses: actions/upload-artifact@v2
198238
if: steps.list_env.outputs.nyc != ''
239+
uses: actions/upload-artifact@v4
199240
with:
200-
name: coverage
201-
path: ./coverage
241+
name: coverage-node-${{ matrix.node-version }}
242+
path: ./coverage/lcov.info
202243
retention-days: 1
203244

204245
coverage:
205246
needs: test
206247
runs-on: ubuntu-latest
248+
permissions:
249+
contents: read
250+
checks: write
207251
steps:
208-
- uses: actions/checkout@v2
252+
- uses: actions/checkout@v4
209253

210254
- name: Install lcov
211255
shell: bash
212256
run: sudo apt-get -y install lcov
213257

214258
- name: Collect coverage reports
215-
uses: actions/download-artifact@v2
259+
uses: actions/download-artifact@v4
216260
with:
217-
name: coverage
218261
path: ./coverage
262+
pattern: coverage-node-*
219263

220264
- name: Merge coverage reports
221265
shell: bash
222-
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
266+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
223267

224268
- name: Upload coverage report
225-
uses: coverallsapp/github-action@master
269+
uses: coverallsapp/github-action@v2
226270
with:
227271
github-token: ${{ secrets.GITHUB_TOKEN }}
272+
file: ./lcov.info

0 commit comments

Comments
 (0)