|
1 | 1 | name: ci |
2 | 2 |
|
3 | 3 | on: |
4 | | -- pull_request |
5 | | -- push |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
6 | 8 |
|
7 | | -jobs: |
8 | | - test: |
9 | | - runs-on: ubuntu-latest |
10 | | - strategy: |
11 | | - 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 | | - |
38 | | - include: |
39 | | - - name: Node.js 0.8 |
40 | | - node-version: "0.8" |
41 | | - |
42 | | - npm-rm: nyc |
43 | | - |
44 | | - - name: Node.js 0.10 |
45 | | - node-version: "0.10" |
46 | | - |
47 | | - |
48 | | - - name: Node.js 0.12 |
49 | | - node-version: "0.12" |
50 | | - |
51 | | - |
52 | | - - name: io.js 1.x |
53 | | - node-version: "1.8" |
54 | | - |
55 | | - |
56 | | - - name: io.js 2.x |
57 | | - node-version: "2.5" |
58 | | - |
59 | | - |
60 | | - - name: io.js 3.x |
61 | | - node-version: "3.3" |
62 | | - |
63 | | - |
64 | | - - name: Node.js 4.x |
65 | | - node-version: "4.9" |
66 | | - |
| 9 | +permissions: |
| 10 | + contents: read |
67 | 11 |
|
68 | | - - name: Node.js 5.x |
69 | | - node-version: "5.12" |
70 | | - |
| 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 |
71 | 17 |
|
72 | | - - name: Node.js 6.x |
73 | | - node-version: "6.17" |
74 | | - |
75 | | - |
76 | | - - name: Node.js 7.x |
77 | | - node-version: "7.10" |
78 | | - |
| 18 | +jobs: |
| 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/*' |
79 | 28 |
|
80 | | - - name: Node.js 8.x |
81 | | - node-version: "8.17" |
82 | | - |
| 29 | + - name: Install dependencies |
| 30 | + run: npm install --ignore-scripts --include=dev |
83 | 31 |
|
84 | | - - name: Node.js 9.x |
85 | | - node-version: "9.11" |
86 | | - |
| 32 | + - name: Run lint |
| 33 | + run: npm run lint |
87 | 34 |
|
88 | | - - name: Node.js 10.x |
89 | | - node-version: "10.24" |
90 | | - |
| 35 | + test: |
| 36 | + name: Run tests |
| 37 | + strategy: |
| 38 | + fail-fast: false |
| 39 | + matrix: |
| 40 | + os: [ubuntu-latest, windows-latest] |
| 41 | + node-version: |
| 42 | + - "0.8" |
| 43 | + - "0.10" |
| 44 | + - "0.12" |
| 45 | + - "4" |
| 46 | + - "5" |
| 47 | + - "6" |
| 48 | + - "7" |
| 49 | + - "8" |
| 50 | + - "9" |
| 51 | + - "10" |
| 52 | + - "11" |
| 53 | + - "12" |
| 54 | + - "13" |
| 55 | + - "14" |
| 56 | + - "15" |
| 57 | + - "16" |
| 58 | + - "17" |
| 59 | + - "18" |
| 60 | + - "19" |
| 61 | + - "20" |
| 62 | + - "21" |
| 63 | + - "22" |
| 64 | + - "23" |
| 65 | + # Use supported versions of our testing tools under older versions of Node |
| 66 | + # Install npm in some specific cases where we need to |
| 67 | + include: |
| 68 | + include: |
| 69 | + - name: Node.js 0.8 |
| 70 | + node-version: "0.8" |
| 71 | + |
| 72 | + npm-rm: nyc |
| 73 | + - node-version: "0.10" |
| 74 | + |
| 75 | + # Npm isn't being installed on windows w/ setup-node for |
| 76 | + # 0.10 and 0.12, which will end up choking when npm uses es6 |
| 77 | + |
91 | 78 |
|
92 | | - - name: Node.js 11.x |
93 | | - node-version: "11.15" |
94 | | - |
| 79 | + - node-version: "0.12" |
| 80 | + |
| 81 | + |
95 | 82 |
|
96 | | - - name: Node.js 12.x |
97 | | - node-version: "12.22" |
98 | | - |
| 83 | + - node-version: "4" |
| 84 | + |
99 | 85 |
|
100 | | - - name: Node.js 13.x |
101 | | - node-version: "13.14" |
102 | | - |
| 86 | + - node-version: "5" |
| 87 | + |
| 88 | + # fixes https://github.com/npm/cli/issues/681 |
| 89 | + |
103 | 90 |
|
104 | | - - name: Node.js 14.x |
105 | | - node-version: "14.21" |
| 91 | + - node-version: "6" |
| 92 | + |
106 | 93 |
|
107 | | - - name: Node.js 15.x |
108 | | - node-version: "15.14" |
| 94 | + - node-version: "7" |
| 95 | + |
109 | 96 |
|
110 | | - - name: Node.js 16.x |
111 | | - node-version: "16.20" |
| 97 | + - node-version: "8" |
| 98 | + |
112 | 99 |
|
113 | | - - name: Node.js 17.x |
114 | | - node-version: "17.9" |
| 100 | + - node-version: "9" |
| 101 | + |
115 | 102 |
|
116 | | - - name: Node.js 18.x |
117 | | - node-version: "18.19" |
| 103 | + - node-version: "10" |
| 104 | + |
118 | 105 |
|
119 | | - - name: Node.js 19.x |
120 | | - node-version: "19.9" |
| 106 | + - node-version: "11" |
| 107 | + |
121 | 108 |
|
122 | | - - name: Node.js 20.x |
123 | | - node-version: "20.11" |
| 109 | + - node-version: "12" |
| 110 | + |
124 | 111 |
|
125 | | - - name: Node.js 21.x |
126 | | - node-version: "21.6" |
| 112 | + - node-version: "13" |
| 113 | + |
127 | 114 |
|
| 115 | + runs-on: ${{ matrix.os }} |
128 | 116 | steps: |
129 | | - - uses: actions/checkout@v4 |
130 | | - |
131 | | - - name: Install Node.js ${{ matrix.node-version }} |
132 | | - shell: bash -eo pipefail -l {0} |
133 | | - run: | |
134 | | - nvm install --default ${{ matrix.node-version }} |
135 | | - if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then |
136 | | - nvm install --alias=npm 0.10 |
137 | | - nvm use ${{ matrix.node-version }} |
138 | | - sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" |
139 | | - npm config set strict-ssl false |
140 | | - fi |
141 | | - dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" |
142 | | -
|
143 | | - - name: Configure npm |
144 | | - run: | |
145 | | - if [[ "$(npm config get package-lock)" == "true" ]]; then |
146 | | - npm config set package-lock false |
147 | | - else |
148 | | - npm config set shrinkwrap false |
149 | | - fi |
150 | | -
|
151 | | - - name: Remove npm module(s) ${{ matrix.npm-rm }} |
152 | | - run: npm rm --silent --save-dev ${{ matrix.npm-rm }} |
153 | | - if: matrix.npm-rm != '' |
154 | | - |
155 | | - - name: Install npm module(s) ${{ matrix.npm-i }} |
156 | | - run: npm install --save-dev ${{ matrix.npm-i }} |
157 | | - if: matrix.npm-i != '' |
158 | | - |
159 | | - - name: Setup Node.js version-specific dependencies |
160 | | - shell: bash |
161 | | - run: | |
162 | | - # eslint for linting |
163 | | - # - remove on Node.js < 12 |
164 | | - if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then |
165 | | - node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ |
166 | | - grep -E '^eslint(-|$)' | \ |
167 | | - sort -r | \ |
168 | | - xargs -n1 npm rm --silent --save-dev |
169 | | - fi |
170 | | -
|
171 | | - - name: Install Node.js dependencies |
172 | | - run: npm install |
173 | | - |
174 | | - - name: List environment |
175 | | - id: list_env |
176 | | - shell: bash |
177 | | - run: | |
178 | | - echo "node@$(node -v)" |
179 | | - echo "npm@$(npm -v)" |
180 | | - npm -s ls ||: |
181 | | - (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" |
182 | | -
|
183 | | - - name: Run tests |
184 | | - shell: bash |
185 | | - run: | |
186 | | - if npm -ps ls nyc | grep -q nyc; then |
187 | | - npm run test-ci |
188 | | - cp coverage/lcov.info "coverage/${{ matrix.node-version }}.lcov" |
189 | | - else |
190 | | - npm test |
191 | | - fi |
192 | | -
|
193 | | - - name: Lint code |
194 | | - if: steps.list_env.outputs.eslint != '' |
195 | | - run: npm run lint |
196 | | - |
197 | | - - name: Collect code coverage |
198 | | - if: steps.list_env.outputs.nyc != '' |
199 | | - run: | |
200 | | - if [[ -d ./coverage ]]; then |
201 | | - mv ./coverage "./${{ matrix.node-version }}" |
202 | | - mkdir ./coverage |
203 | | - mv "./${{ matrix.node-version }}" "./coverage/${{ matrix.node-version }}" |
204 | | - fi |
205 | | -
|
206 | | - - name: Upload code coverage |
207 | | - uses: actions/upload-artifact@v4 |
208 | | - if: steps.list_env.outputs.nyc != '' |
209 | | - with: |
210 | | - name: coverage-${{ matrix.node-version }} |
211 | | - path: "./coverage/${{ matrix.node-version }}" |
212 | | - retention-days: 1 |
| 117 | + - uses: actions/checkout@v4 |
| 118 | + with: |
| 119 | + persist-credentials: false |
| 120 | + |
| 121 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 122 | + uses: actions/setup-node@v4 |
| 123 | + with: |
| 124 | + node-version: ${{ matrix.node-version }} |
| 125 | + |
| 126 | + - name: Npm version fixes |
| 127 | + if: ${{matrix.npm-version != ''}} |
| 128 | + run: npm install -g ${{ matrix.npm-version }} |
| 129 | + |
| 130 | + - name: Configure npm loglevel |
| 131 | + run: | |
| 132 | + npm config set loglevel error |
| 133 | + shell: bash |
| 134 | + |
| 135 | + - name: Remove npm module(s) ${{ matrix.npm-rm }} |
| 136 | + run: npm rm --silent --save-dev ${{ matrix.npm-rm }} |
| 137 | + if: matrix.npm-rm != '' |
| 138 | + |
| 139 | + - name: Install Node version specific dev deps |
| 140 | + if: ${{ matrix.npm-i != '' }} |
| 141 | + run: npm install --save-dev ${{ matrix.npm-i }} |
| 142 | + |
| 143 | + - name: Install dependencies |
| 144 | + run: npm install |
| 145 | + |
| 146 | + - name: Output Node and NPM versions |
| 147 | + run: | |
| 148 | + echo "Node.js version: $(node -v)" |
| 149 | + echo "NPM version: $(npm -v)" |
| 150 | +
|
| 151 | + - name: Run tests |
| 152 | + shell: bash |
| 153 | + run: npm run test-ci |
| 154 | + |
| 155 | + - name: Upload code coverage |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + with: |
| 158 | + name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }} |
| 159 | + path: ./coverage/lcov.info |
| 160 | + retention-days: 1 |
213 | 161 |
|
214 | 162 | coverage: |
215 | 163 | needs: test |
216 | 164 | runs-on: ubuntu-latest |
| 165 | + permissions: |
| 166 | + contents: read |
| 167 | + checks: write |
217 | 168 | steps: |
218 | | - - uses: actions/checkout@v4 |
219 | | - |
220 | | - - name: Install lcov |
221 | | - shell: bash |
222 | | - run: sudo apt-get -y install lcov |
223 | | - |
224 | | - - name: Collect coverage reports |
225 | | - uses: actions/download-artifact@v4 |
226 | | - with: |
227 | | - path: ./coverage |
228 | | - |
229 | | - - name: Merge coverage reports |
230 | | - shell: bash |
231 | | - run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info |
232 | | - |
233 | | - - name: Upload coverage report |
234 | | - uses: coverallsapp/github-action@master |
235 | | - with: |
236 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
| 169 | + - uses: actions/checkout@v4 |
| 170 | + |
| 171 | + - name: Install lcov |
| 172 | + shell: bash |
| 173 | + run: sudo apt-get -y install lcov |
| 174 | + |
| 175 | + - name: Collect coverage reports |
| 176 | + uses: actions/download-artifact@v4 |
| 177 | + with: |
| 178 | + path: ./coverage |
| 179 | + pattern: coverage-node-* |
| 180 | + |
| 181 | + - name: Merge coverage reports |
| 182 | + shell: bash |
| 183 | + run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info |
| 184 | + |
| 185 | + - name: Upload coverage report |
| 186 | + uses: coverallsapp/github-action@v2 |
| 187 | + with: |
| 188 | + file: ./lcov.info |
0 commit comments