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