Skip to content

Commit 16b3c62

Browse files
committed
ci: updated ci workflow
1 parent 2ceda41 commit 16b3c62

File tree

1 file changed

+79
-54
lines changed

1 file changed

+79
-54
lines changed

.github/workflows/ci.yml

Lines changed: 79 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,96 @@ on:
1111
paths-ignore:
1212
- '*.md'
1313

14+
permissions:
15+
contents: read
16+
17+
# Cancel in progress workflows
18+
# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run
19+
concurrency:
20+
group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
21+
cancel-in-progress: true
22+
1423
jobs:
24+
lint:
25+
name: Lint
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "lts/*"
34+
35+
- name: Install dependencies
36+
run: npm install --ignore-scripts --include=dev
37+
38+
- name: Run lint
39+
run: npm run lint
40+
1541
test:
42+
name: Test - Node.js ${{ matrix.node-version }}
1643
runs-on: ubuntu-latest
1744
strategy:
45+
fail-fast: false
1846
matrix:
19-
name:
20-
- Node.js 18.x
21-
- Node.js 20.x
22-
- Node.js 22.x
47+
# Node.js release schedule: https://nodejs.org/en/about/releases/
48+
node-version: [18, 19, 20, 21, 22, 23]
2349

24-
include:
25-
- name: Node.js 18.x
26-
node-version: "18"
50+
steps:
51+
- uses: actions/checkout@v4
2752

28-
- name: Node.js 20.x
29-
node-version: "20"
53+
- name: Setup Node.js ${{ matrix.node-version }}
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: ${{ matrix.node-version }}
3057

31-
- name: Node.js 22.x
32-
node-version: "22"
58+
- name: Configure npm loglevel
59+
run: npm config set loglevel error
3360

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

7380
coverage:
7481
needs: test
7582
runs-on: ubuntu-latest
83+
permissions:
84+
contents: read
85+
checks: write
7686
steps:
77-
- name: Upload code coverage
78-
uses: coverallsapp/github-action@master
79-
with:
80-
github-token: ${{ secrets.github_token }}
81-
parallel-finished: true
87+
- uses: actions/checkout@v4
88+
89+
- name: Install lcov
90+
shell: bash
91+
run: sudo apt-get -y install lcov
92+
93+
- name: Collect coverage reports
94+
uses: actions/download-artifact@v4
95+
with:
96+
path: ./coverage
97+
pattern: coverage-node-*
98+
99+
- name: Merge coverage reports
100+
shell: bash
101+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
102+
103+
- name: Upload coverage report
104+
uses: coverallsapp/github-action@v2
105+
with:
106+
file: ./lcov.info

0 commit comments

Comments
 (0)