11name : ci
22
33on :
4- - pull_request
5- - push
4+ push :
5+ branches :
6+ - master
7+ pull_request :
8+
9+ permissions :
10+ contents : read
11+
12+ # Cancel in progress workflows
13+ # in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run
14+ concurrency :
15+ group : " ${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
16+ cancel-in-progress : true
617
718jobs :
19+ lint :
20+ name : Lint
21+ runs-on : ubuntu-latest
22+ steps :
23+ - uses : actions/checkout@v4
24+ - name : Setup Node.js
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : ' lts/*'
28+
29+ - name : Install dependencies
30+ run : npm install --ignore-scripts --include=dev
31+
32+ - name : Run lint
33+ run : npm run lint
34+
835 test :
9- runs-on : ubuntu-20.04
1036 strategy :
37+ fail-fast : false
1138 matrix :
12- name :
13- - Node.js 0.8
14- - Node.js 0.10
15- - Node.js 0.12
16- - io.js 1.x
17- - io.js 2.x
18- - io.js 3.x
19- - Node.js 4.x
20- - Node.js 5.x
21- - Node.js 6.x
22- - Node.js 7.x
23- - Node.js 8.x
24- - Node.js 9.x
25- - Node.js 10.x
26- - Node.js 11.x
27- - Node.js 12.x
28- - Node.js 13.x
29- - Node.js 14.x
30- - Node.js 15.x
31- - Node.js 16.x
32- - Node.js 17.x
33- - Node.js 18.x
34- - Node.js 19.x
35- - Node.js 20.x
36- - Node.js 21.x
37- - Node.js 22.x
38-
39- include :
40- - name : Node.js 0.8
41- node-version : " 0.8"
42- 43- npm-rm : nyc
44-
45- - name : Node.js 0.10
46- node-version : " 0.10"
47- 48-
49- - name : Node.js 0.12
50- node-version : " 0.12"
51- 52-
53- - name : io.js 1.x
54- node-version : " 1.8"
55- 56-
57- - name : io.js 2.x
58- node-version : " 2.5"
59- 60-
61- - name : io.js 3.x
62- node-version : " 3.3"
63- 64-
65- - name : Node.js 4.x
66- node-version : " 4.9"
67- 68-
69- - name : Node.js 5.x
70- node-version : " 5.12"
71- 72-
73- - name : Node.js 6.x
74- node-version : " 6.17"
75- 76-
77- - name : Node.js 7.x
78- node-version : " 7.10"
79- 80-
81- - name : Node.js 8.x
82- node-version : " 8.17"
83- 84-
85- - name : Node.js 9.x
86- node-version : " 9.11"
87- 88-
89- - name : Node.js 10.x
90- node-version : " 10.24"
91- 92-
93- - name : Node.js 11.x
94- node-version : " 11.15"
95- 96-
97- - name : Node.js 12.x
98- node-version : " 12.22"
99- 100-
101- - name : Node.js 13.x
102- node-version : " 13.14"
103- 104-
105- - name : Node.js 14.x
106- node-version : " 14.21"
107-
108- - name : Node.js 15.x
109- node-version : " 15.14"
110-
111- - name : Node.js 16.x
112- node-version : " 16.20"
113-
114- - name : Node.js 17.x
115- node-version : " 17.9"
116-
117- - name : Node.js 18.x
118- node-version : " 18.18"
119-
120- - name : Node.js 19.x
121- node-version : " 19.9"
122-
123- - name : Node.js 20.x
124- node-version : " 20.9"
125-
126- - name : Node.js 21.x
127- node-version : " 21.1"
39+ os : [ubuntu-latest, windows-latest]
40+ node-version : [18, 19, 20, 21, 22, 23]
41+ # Node.js release schedule: https://nodejs.org/en/about/releases/
12842
129- - name : Node.js 22.x
130- node-version : " 22.0"
43+ name : Node.js ${{ matrix.node-version }} - ${{matrix.os}}
13144
45+ runs-on : ${{ matrix.os }}
13246 steps :
133- - uses : actions/checkout@v3
134-
135- - name : Install Node.js ${{ matrix.node-version }}
136- shell : bash -eo pipefail -l {0}
137- run : |
138- nvm install --default ${{ matrix.node-version }}
139- if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
140- nvm install --alias=npm 0.10
141- nvm use ${{ matrix.node-version }}
142- if [[ "$(npm -v)" == 1.1.* ]]; then
143- nvm exec npm npm install -g [email protected] 144- ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
145- else
146- sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
147- fi
148- npm config set strict-ssl false
149- fi
150- dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
151-
152- - name : Configure npm
153- run : |
154- if [[ "$(npm config get package-lock)" == "true" ]]; then
155- npm config set package-lock false
156- else
157- npm config set shrinkwrap false
158- fi
159-
160- - name : Remove npm module(s) ${{ matrix.npm-rm }}
161- run : npm rm --silent --save-dev ${{ matrix.npm-rm }}
162- if : matrix.npm-rm != ''
163-
164- - name : Install npm module(s) ${{ matrix.npm-i }}
165- run : npm install --save-dev ${{ matrix.npm-i }}
166- if : matrix.npm-i != ''
167-
168- - name : Setup Node.js version-specific dependencies
169- shell : bash
170- run : |
171- # eslint for linting
172- # - remove on Node.js < 12
173- if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
174- node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
175- grep -E '^eslint(-|$)' | \
176- sort -r | \
177- xargs -n1 npm rm --silent --save-dev
178- fi
179-
180- - name : Install Node.js dependencies
181- run : npm install
182-
183- - name : Install browserify
184- run : |
185- if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -ge 1 ]]; then
186- npm install --save-dev browserify@16
187- fi
188-
189- - name : List environment
190- id : list_env
191- shell : bash
192- run : |
193- echo "node@$(node -v)"
194- echo "npm@$(npm -v)"
195- npm -s ls ||:
196- (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
197-
198- - name : Run tests
199- shell : bash
200- run : |
201- if npm -ps ls nyc | grep -q nyc; then
202- npm run test-ci
203- else
204- npm test
205- fi
206-
207- - name : Lint code
208- if : steps.list_env.outputs.eslint != ''
209- run : npm run lint
210-
211- - name : Collect code coverage
212- uses : coverallsapp/github-action@master
213- if : steps.list_env.outputs.nyc != ''
214- with :
215- github-token : ${{ secrets.GITHUB_TOKEN }}
216- flag-name : run-${{ matrix.test_number }}
217- parallel : true
47+ - uses : actions/checkout@v4
48+ with :
49+ persist-credentials : false
50+
51+ - name : Setup Node.js ${{ matrix.node-version }}
52+ uses : actions/setup-node@v4
53+ with :
54+ node-version : ${{ matrix.node-version }}
55+
56+ - name : Configure npm loglevel
57+ run : |
58+ npm config set loglevel error
59+ shell : bash
60+
61+ - name : Install 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 }}-${{ matrix.os }}
77+ path : ./coverage/lcov.info
78+ retention-days : 1
21879
21980 coverage :
22081 needs : test
22182 runs-on : ubuntu-latest
83+ permissions :
84+ contents : read
85+ checks : write
22286 steps :
223- - name : Upload code coverage
224- uses : coverallsapp/github-action@master
225- with :
226- github-token : ${{ secrets.GITHUB_TOKEN }}
227- 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