Skip to content

Commit 1fe49ae

Browse files
authored
ci: updated ci pipeline (#80)
1 parent 38f05a9 commit 1fe49ae

2 files changed

Lines changed: 63 additions & 82 deletions

File tree

.github/workflows/ci.yml

Lines changed: 59 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- master
7-
- '1.x'
87
paths-ignore:
98
- '*.md'
109
pull_request:
@@ -15,94 +14,76 @@ permissions:
1514
contents: read
1615

1716
jobs:
17+
lint:
18+
name: Lint
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
23+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
24+
with:
25+
node-version: 'lts/*'
26+
27+
- name: Install Node.js dependencies
28+
run: npm install --ignore-scripts --include=dev
29+
30+
- name: Lint code
31+
run: npm run lint
32+
1833
test:
19-
permissions:
20-
checks: write # for coverallsapp/github-action to create new checks
21-
contents: read # for actions/checkout to fetch code
34+
name: Test - Node.js ${{ matrix.node-version }}
2235
runs-on: ubuntu-latest
2336
strategy:
37+
fail-fast: false
2438
matrix:
25-
name:
26-
- Node.js 18.x
27-
- Node.js 19.x
28-
- Node.js 20.x
29-
- Node.js 21.x
30-
- Node.js 22.x
31-
32-
include:
33-
- name: Node.js 18.x
34-
node-version: "18"
39+
# Node.js release schedule: https://nodejs.org/en/about/releases/
40+
node-version: [18, 19, 20, 21, 22, 23, 24]
3541

36-
- name: Node.js 19.x
37-
node-version: "19"
42+
steps:
43+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3844

39-
- name: Node.js 20.x
40-
node-version: "20"
45+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
46+
with:
47+
node-version: ${{ matrix.node-version }}
48+
check-latest: true
4149

42-
- name: Node.js 21.x
43-
node-version: "21"
50+
- name: Install Node.js dependencies
51+
run: npm install
4452

45-
- name: Node.js 22.x
46-
node-version: "22"
53+
- name: Run tests
54+
run: npm run test-ci
4755

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

9863
coverage:
99-
permissions:
100-
checks: write # for coverallsapp/github-action to create new checks
10164
needs: test
10265
runs-on: ubuntu-latest
66+
permissions:
67+
contents: read
68+
checks: write
10369
steps:
104-
- name: Upload code coverage
105-
uses: coverallsapp/github-action@master
106-
with:
107-
github-token: ${{ secrets.GITHUB_TOKEN }}
108-
parallel-finished: true
70+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+
72+
- name: Install lcov
73+
shell: bash
74+
run: sudo apt-get -y install lcov
75+
76+
- name: Collect coverage reports
77+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
78+
with:
79+
path: ./coverage
80+
pattern: coverage-node-*
81+
82+
- name: Merge coverage reports
83+
shell: bash
84+
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
85+
86+
- name: Upload coverage report
87+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
88+
with:
89+
file: ./lcov.info

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"devDependencies": {
2525
"eslint": "7.32.0",
2626
"eslint-plugin-markdown": "2.2.1",
27-
"mocha": "9.1.3",
28-
"nyc": "15.1.0"
27+
"mocha": "^11.7.0",
28+
"nyc": "^17.1.0"
2929
},
3030
"files": [
3131
"lib/",
@@ -39,9 +39,9 @@
3939
},
4040
"scripts": {
4141
"lint": "eslint .",
42-
"test": "mocha --reporter spec --check-leaks --bail test/",
42+
"test": "mocha --reporter spec --check-leaks test/",
4343
"test:debug": "mocha --reporter spec --check-leaks --inspect --inspect-brk test/",
44-
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
44+
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
4545
"test-cov": "nyc --reporter=html --reporter=text npm test"
4646
}
4747
}

0 commit comments

Comments
 (0)