Skip to content

Commit f84baf2

Browse files
authored
fix(ci): updated github actions ci workflow (#70)
1 parent 91e7957 commit f84baf2

File tree

1 file changed

+59
-72
lines changed

1 file changed

+59
-72
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,90 +10,77 @@ on:
1010
paths-ignore:
1111
- '*.md'
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
17+
lint:
18+
name: Lint
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Install Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 'lts/*'
27+
28+
- name: Install Node.js dependencies
29+
run: npm install --ignore-scripts --include=dev
30+
31+
- name: Lint code
32+
run: npm run lint
33+
1434
test:
35+
name: Test - Node.js ${{ matrix.node-version }}
1536
runs-on: ubuntu-latest
1637
strategy:
1738
matrix:
18-
name:
19-
- Node.js 18.x
20-
- Node.js 19.x
21-
- Node.js 20.x
22-
- Node.js 21.x
23-
- Node.js 22.x
24-
25-
include:
26-
- name: Node.js 18.x
27-
node-version: "18"
39+
node-version: [18, 19, 20, 21, 22, 23]
2840

29-
- name: Node.js 19.x
30-
node-version: "19"
41+
steps:
42+
- uses: actions/checkout@v4
3143

32-
- name: Node.js 20.x
33-
node-version: "20"
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: ${{ matrix.node-version }}
47+
check-latest: true
3448

35-
- name: Node.js 21.x
36-
node-version: "21"
49+
- name: Install Node.js dependencies
50+
run: npm install
3751

38-
- name: Node.js 22.x
39-
node-version: "22"
52+
- name: Run tests
53+
run: npm run test-ci
4054

41-
steps:
42-
- uses: actions/checkout@v4
43-
44-
- name: Install Node.js ${{ matrix.node-version }}
45-
shell: bash -eo pipefail -l {0}
46-
run: |
47-
nvm install --default ${{ matrix.node-version }}
48-
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
49-
50-
- name: Configure npm
51-
run: |
52-
if [[ "$(npm config get package-lock)" == "true" ]]; then
53-
npm config set package-lock false
54-
else
55-
npm config set shrinkwrap false
56-
fi
57-
58-
- name: Install Node.js dependencies
59-
run: npm install
60-
61-
- name: List environment
62-
id: list_env
63-
shell: bash
64-
run: |
65-
echo "node@$(node -v)"
66-
echo "npm@$(npm -v)"
67-
npm -s ls ||:
68-
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }'
69-
70-
- name: Run tests
71-
shell: bash
72-
run: |
73-
if npm -ps ls nyc | grep -q nyc; then
74-
npm run test-ci
75-
else
76-
npm test
77-
fi
78-
79-
- name: Lint code
80-
if: steps.list_env.outputs.eslint != ''
81-
run: npm run lint
82-
83-
- name: Collect code coverage
84-
uses: coverallsapp/github-action@master
85-
if: steps.list_env.outputs.nyc != ''
86-
with:
87-
github-token: ${{ secrets.GITHUB_TOKEN }}
88-
flag-name: run-${{ matrix.test_number }}
89-
parallel: true
55+
- name: Upload code coverage
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: coverage-node-${{ matrix.node-version }}
59+
path: ./coverage/lcov.info
60+
retention-days: 1
9061

9162
coverage:
9263
needs: test
9364
runs-on: ubuntu-latest
65+
permissions:
66+
contents: read
67+
checks: write
9468
steps:
95-
- name: Upload code coverage
96-
uses: coverallsapp/github-action@master
97-
with:
98-
github-token: ${{ secrets.github_token }}
99-
parallel-finished: true
69+
- uses: actions/checkout@v4
70+
71+
- name: Install lcov
72+
run: sudo apt-get -y install lcov
73+
74+
- name: Collect coverage reports
75+
uses: actions/download-artifact@v4
76+
with:
77+
path: ./coverage
78+
pattern: coverage-node-*
79+
80+
- name: Merge coverage reports
81+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
82+
83+
- name: Upload coverage report
84+
uses: coverallsapp/github-action@v2
85+
with:
86+
file: ./lcov.info

0 commit comments

Comments
 (0)