Skip to content

Commit bde1822

Browse files
authored
ci: add ci pipeline to lts branch (#1302)
1 parent 8ec534f commit bde1822

File tree

2 files changed

+170
-1
lines changed

2 files changed

+170
-1
lines changed

.github/workflows/ci.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: ci
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
name:
14+
- Node.js 6.x
15+
- Node.js 8.x
16+
- Node.js 10.x
17+
- Node.js 11.x
18+
- Node.js 12.x
19+
- Node.js 13.x
20+
- Node.js 14.x
21+
- Node.js 15.x
22+
- Node.js 16.x
23+
- Node.js 17.x
24+
- Node.js 18.x
25+
- Node.js 19.x
26+
- Node.js 20.x
27+
- Node.js 21.x
28+
- Node.js 22.x
29+
- Node.js 23.x
30+
- Node.js 24.x
31+
32+
include:
33+
- name: Node.js 6.x
34+
node-version: "6.17"
35+
36+
37+
- name: Node.js 8.x
38+
node-version: "8.17"
39+
40+
41+
- name: Node.js 10.x
42+
node-version: "10.24"
43+
44+
45+
- name: Node.js 11.x
46+
node-version: "11.15"
47+
48+
49+
- name: Node.js 12.x
50+
node-version: "12.22"
51+
52+
53+
- name: Node.js 13.x
54+
node-version: "13.14"
55+
56+
57+
- name: Node.js 14.x
58+
node-version: "14.21"
59+
60+
- name: Node.js 15.x
61+
node-version: "15.14"
62+
63+
- name: Node.js 16.x
64+
node-version: "16.20"
65+
66+
- name: Node.js 17.x
67+
node-version: "17.9"
68+
69+
- name: Node.js 18.x
70+
node-version: "18.18"
71+
72+
- name: Node.js 19.x
73+
node-version: "19.9"
74+
75+
- name: Node.js 20.x
76+
node-version: "20.9"
77+
78+
- name: Node.js 21.x
79+
node-version: "21"
80+
81+
- name: Node.js 22.x
82+
node-version: "22"
83+
84+
- name: Node.js 23.x
85+
node-version: "23"
86+
87+
- name: Node.js 24.x
88+
node-version: "24"
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Install Node.js ${{ matrix.node-version }}
94+
shell: bash -eo pipefail -l {0}
95+
run: |
96+
nvm install --default ${{ matrix.node-version }}
97+
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
98+
nvm install --alias=npm 0.10
99+
nvm use ${{ matrix.node-version }}
100+
if [[ "$(npm -v)" == 1.1.* ]]; then
101+
nvm exec npm npm install -g [email protected]
102+
ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
103+
else
104+
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
105+
fi
106+
npm config set strict-ssl false
107+
fi
108+
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
109+
110+
- name: Configure npm
111+
run: |
112+
if [[ "$(npm config get package-lock)" == "true" ]]; then
113+
npm config set package-lock false
114+
else
115+
npm config set shrinkwrap false
116+
fi
117+
118+
- name: Remove npm module(s) ${{ matrix.npm-rm }}
119+
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
120+
if: matrix.npm-rm != ''
121+
122+
- name: Install npm module(s) ${{ matrix.npm-i }}
123+
run: npm install --save-dev ${{ matrix.npm-i }}
124+
if: matrix.npm-i != ''
125+
126+
- name: Install Node.js dependencies
127+
run: npm install
128+
129+
- name: List environment
130+
id: list_env
131+
shell: bash
132+
run: |
133+
echo "node@$(node -v)"
134+
echo "npm@$(npm -v)"
135+
npm -s ls ||:
136+
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
137+
138+
- name: Lint code
139+
run: npm run lint
140+
141+
- name: Run tests
142+
shell: bash
143+
run: |
144+
if npm -ps ls nyc | grep -q nyc; then
145+
npm run test-ci
146+
else
147+
npm test
148+
fi
149+
150+
- name: Collect code coverage
151+
uses: coverallsapp/github-action@master
152+
if: steps.list_env.outputs.nyc != ''
153+
with:
154+
github-token: ${{ secrets.GITHUB_TOKEN }}
155+
flag-name: run-${{ matrix.test_number }}
156+
parallel: true
157+
158+
coverage:
159+
needs: test
160+
runs-on: ubuntu-latest
161+
steps:
162+
- name: Upload code coverage
163+
uses: coverallsapp/github-action@master
164+
with:
165+
github-token: ${{ secrets.GITHUB_TOKEN }}
166+
parallel-finished: true

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"lib/"
4848
],
4949
"scripts": {
50-
"test": "standard && mocha"
50+
"lint": "standard",
51+
"test": "mocha --reporter spec --exit --check-leaks test/",
52+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
53+
"test-cov": "nyc --reporter=html --reporter=text npm test"
5154
}
5255
}

0 commit comments

Comments
 (0)