Skip to content

Commit a5055df

Browse files
authored
ci: updated github actions ci workflow (#546)
1 parent 1aad750 commit a5055df

File tree

1 file changed

+44
-82
lines changed

1 file changed

+44
-82
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3,108 +3,70 @@ on:
33
push:
44
branches:
55
- master
6-
- '2.x'
76
paths-ignore:
87
- '*.md'
98
pull_request:
109
paths-ignore:
1110
- '*.md'
11+
permissions:
12+
contents: read
1213

1314
jobs:
1415
test:
16+
name: Test - Node.js ${{ matrix.node-version }}
1517
runs-on: ubuntu-latest
1618
strategy:
1719
matrix:
18-
name:
19-
- Node.js 18.x
20-
- Node.js 20.x
21-
- Node.js 22.x
22-
23-
include:
24-
- name: Node.js 18.x
25-
node-version: "18"
26-
27-
- name: Node.js 20.x
28-
node-version: "20"
29-
30-
- name: Node.js 22.x
31-
node-version: "22"
20+
node-version: [18, 19, 20, 21, 22, 23]
3221

3322
steps:
34-
- uses: actions/checkout@v4
35-
36-
- name: Install Node.js ${{ matrix.node-version }}
37-
shell: bash -eo pipefail -l {0}
38-
run: |
39-
nvm install --default ${{ matrix.node-version }}
40-
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
41-
42-
- name: Configure npm
43-
run: |
44-
if [[ "$(npm config get package-lock)" == "true" ]]; then
45-
npm config set package-lock false
46-
else
47-
npm config set shrinkwrap false
48-
fi
23+
- uses: actions/checkout@v4
4924

50-
- name: Install Node.js dependencies
51-
run: npm install
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
check-latest: true
5229

53-
- name: List environment
54-
id: list_env
55-
shell: bash
56-
run: |
57-
echo "node@$(node -v)"
58-
echo "npm@$(npm -v)"
59-
npm -s ls ||:
60-
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
30+
- name: Install Node.js dependencies
31+
run: npm install
6132

62-
- name: Run tests
63-
shell: bash
64-
run: |
65-
npm run test-ci
66-
cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov"
33+
- name: Run tests
34+
run: npm run test-ci
6735

68-
- name: Lint code
69-
if: steps.list_env.outputs.eslint != ''
70-
run: npm run lint
36+
- name: Lint code
37+
run: npm run lint
7138

72-
- name: Collect code coverage
73-
run: |
74-
if [[ -d ./coverage ]]; then
75-
mv ./coverage "./${{ matrix.name }}"
76-
mkdir ./coverage
77-
mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}"
78-
fi
79-
80-
- name: Upload code coverage
81-
uses: actions/upload-artifact@v3
82-
with:
83-
name: coverage
84-
path: ./coverage
85-
retention-days: 1
39+
- name: Upload code coverage
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: coverage-node-${{ matrix.node-version }}
43+
path: ./coverage/lcov.info
44+
retention-days: 1
8645

8746
coverage:
8847
needs: test
8948
runs-on: ubuntu-latest
49+
permissions:
50+
contents: read
51+
checks: write
9052
steps:
91-
- uses: actions/checkout@v4
92-
93-
- name: Install lcov
94-
shell: bash
95-
run: sudo apt-get -y install lcov
96-
97-
- name: Collect coverage reports
98-
uses: actions/download-artifact@v3
99-
with:
100-
name: coverage
101-
path: ./coverage
102-
103-
- name: Merge coverage reports
104-
shell: bash
105-
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
106-
107-
- name: Upload coverage report
108-
uses: coverallsapp/github-action@master
109-
with:
110-
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
- uses: actions/checkout@v4
54+
55+
- name: Install lcov
56+
shell: bash
57+
run: sudo apt-get -y install lcov
58+
59+
- name: Collect coverage reports
60+
uses: actions/download-artifact@v4
61+
with:
62+
path: ./coverage
63+
pattern: coverage-node-*
64+
65+
- name: Merge coverage reports
66+
shell: bash
67+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
68+
69+
- name: Upload coverage report
70+
uses: coverallsapp/github-action@v2
71+
with:
72+
file: ./lcov.info

0 commit comments

Comments
 (0)