Skip to content

Commit 96df7c5

Browse files
authored
improve ci workflow (#206)
1 parent f4e596c commit 96df7c5

File tree

2 files changed

+62
-16
lines changed

2 files changed

+62
-16
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
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:
@@ -195,24 +226,39 @@ jobs:
195226
npm test
196227
fi
197228
198-
- name: Lint code
199-
if: steps.list_env.outputs.eslint != ''
200-
run: npm run lint
201-
202-
- name: Collect code coverage
203-
uses: coverallsapp/github-action@master
229+
- name: Upload code coverage
204230
if: steps.list_env.outputs.nyc != ''
231+
uses: actions/upload-artifact@v4
205232
with:
206-
github-token: ${{ secrets.GITHUB_TOKEN }}
207-
flag-name: run-${{ matrix.test_number }}
208-
parallel: true
233+
name: coverage-node-${{ matrix.node-version }}
234+
path: ./coverage/lcov.info
235+
retention-days: 1
209236

210237
coverage:
211238
needs: test
212239
runs-on: ubuntu-latest
240+
permissions:
241+
contents: read
242+
checks: write
213243
steps:
214-
- name: Upload code coverage
215-
uses: coverallsapp/github-action@master
244+
- uses: actions/checkout@v4
245+
246+
- name: Install lcov
247+
shell: bash
248+
run: sudo apt-get -y install lcov
249+
250+
- name: Collect coverage reports
251+
uses: actions/download-artifact@v4
216252
with:
217-
github-token: ${{ secrets.github_token }}
218-
parallel-finished: true
253+
path: ./coverage
254+
pattern: coverage-node-*
255+
256+
- name: Merge coverage reports
257+
shell: bash
258+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
259+
260+
- name: Upload coverage report
261+
uses: coverallsapp/github-action@v2
262+
with:
263+
github-token: ${{ secrets.GITHUB_TOKEN }}
264+
file: ./lcov.info

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"scripts": {
4242
"lint": "eslint .",
4343
"test": "mocha --check-leaks --reporter spec",
44-
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
44+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
4545
"test-cov": "nyc --reporter=html --reporter=text npm test"
4646
}
4747
}

0 commit comments

Comments
 (0)