Skip to content

Commit 2a3af7e

Browse files
Phillip9587wesleytodd
authored andcommitted
ci: updated github actions ci workflow
1 parent 7a93a21 commit 2a3af7e

File tree

1 file changed

+45
-97
lines changed

1 file changed

+45
-97
lines changed

.github/workflows/ci.yml

+45-97
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,74 @@
11
name: ci
2-
32
on:
43
push:
54
branches:
65
- master
7-
- '2.0'
86
paths-ignore:
97
- '*.md'
108
pull_request:
119
paths-ignore:
1210
- '*.md'
1311

12+
permissions:
13+
contents: read
14+
1415
jobs:
1516
test:
17+
name: Test - Node.js ${{ matrix.node-version }}
1618
runs-on: ubuntu-latest
1719
strategy:
1820
fail-fast: false
1921
matrix:
20-
name:
21-
- Node.js 18.x
22-
- Node.js 19.x
23-
- Node.js 20.x
24-
- Node.js 21.x
25-
- Node.js 22.x
26-
27-
include:
28-
- name: Node.js 18.x
29-
node-version: "18"
30-
31-
- name: Node.js 19.x
32-
node-version: "19"
33-
34-
- name: Node.js 20.x
35-
node-version: "20"
36-
37-
- name: Node.js 21.x
38-
node-version: "21"
39-
40-
- name: Node.js 22.x
41-
node-version: "22"
22+
node-version: [18, 19, 20, 21, 22, 23]
4223

4324
steps:
44-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v4
4526

46-
- name: Install Node.js ${{ matrix.node-version }}
47-
shell: bash -eo pipefail -l {0}
48-
run: |
49-
nvm install --default ${{ matrix.node-version }}
50-
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
check-latest: true
5131

52-
- name: Configure npm
53-
run: |
54-
if [[ "$(npm config get package-lock)" == "true" ]]; then
55-
npm config set package-lock false
56-
else
57-
npm config set shrinkwrap false
58-
fi
32+
- name: Install Node.js dependencies
33+
run: npm install
5934

60-
- name: Install Node.js dependencies
61-
run: npm install
35+
- name: Run tests
36+
run: npm run test-ci
6237

63-
- name: List environment
64-
id: list_env
65-
shell: bash
66-
run: |
67-
echo "node@$(node -v)"
68-
echo "npm@$(npm -v)"
69-
npm -s ls ||:
70-
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
38+
- name: Lint code
39+
run: npm run lint
7140

72-
- name: Run tests
73-
shell: bash
74-
run: |
75-
if npm -ps ls nyc | grep -q nyc; then
76-
npm run test-ci
77-
cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov"
78-
else
79-
npm test
80-
fi
81-
82-
- name: Lint code
83-
if: steps.list_env.outputs.eslint != ''
84-
run: npm run lint
85-
86-
- name: Collect code coverage
87-
if: steps.list_env.outputs.nyc != ''
88-
run: |
89-
if [[ -d ./coverage ]]; then
90-
mv ./coverage "./${{ matrix.name }}"
91-
mkdir ./coverage
92-
mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}"
93-
fi
94-
- name: Upload code coverage
95-
uses: actions/upload-artifact@v3
96-
97-
if: steps.list_env.outputs.nyc != ''
98-
with:
99-
name: coverage
100-
path: ./coverage
101-
retention-days: 1
41+
- name: Upload code coverage
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: coverage-node-${{ matrix.node-version }}
45+
path: ./coverage/lcov.info
46+
retention-days: 1
10247

10348
coverage:
10449
needs: test
10550
runs-on: ubuntu-latest
51+
permissions:
52+
contents: read
53+
checks: write
10654
steps:
107-
- uses: actions/checkout@v3
108-
109-
- name: Install lcov
110-
shell: bash
111-
run: sudo apt-get -y install lcov
112-
113-
- name: Collect coverage reports
114-
uses: actions/download-artifact@v3
115-
with:
116-
name: coverage
117-
path: ./coverage
118-
119-
- name: Merge coverage reports
120-
shell: bash
121-
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
122-
123-
- name: Upload coverage report
124-
uses: coverallsapp/github-action@master
125-
with:
126-
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
- uses: actions/checkout@v4
56+
57+
- name: Install lcov
58+
shell: bash
59+
run: sudo apt-get -y install lcov
60+
61+
- name: Collect coverage reports
62+
uses: actions/download-artifact@v4
63+
with:
64+
path: ./coverage
65+
pattern: coverage-node-*
66+
67+
- name: Merge coverage reports
68+
shell: bash
69+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
70+
71+
- name: Upload coverage report
72+
uses: coverallsapp/github-action@v2
73+
with:
74+
file: ./lcov.info

0 commit comments

Comments
 (0)