27
27
run :
28
28
shell : bash
29
29
steps :
30
- - name : Get Workflow Job
31
- uses : actions/github-script@v6
32
- if : inputs.check-sha
33
- id : check-output
34
- env :
35
- JOB_NAME : " Lint All"
36
- MATRIX_NAME : " "
37
- with :
38
- script : |
39
- const { owner, repo } = context.repo
40
-
41
- const { data } = await github.rest.actions.listJobsForWorkflowRun({
42
- owner,
43
- repo,
44
- run_id: context.runId,
45
- per_page: 100
46
- })
47
-
48
- const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
49
- const job = data.jobs.find(j => j.name.endsWith(jobName))
50
- const jobUrl = job?.html_url
51
-
52
- const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
53
-
54
- let summary = `This check is assosciated with ${shaUrl}\n\n`
55
-
56
- if (jobUrl) {
57
- summary += `For run logs, click here: ${jobUrl}`
58
- } else {
59
- summary += `Run logs could not be found for a job with name: "${jobName}"`
60
- }
61
-
62
- return { summary }
63
- - name : Create Check
64
- uses : LouisBrunner/checks-action@v1.6.0
65
- id : check
66
- if : inputs.check-sha
67
- with :
68
- token : ${{ secrets.GITHUB_TOKEN }}
69
- status : in_progress
70
- name : Lint All
71
- sha : ${{ inputs.check-sha }}
72
- output : ${{ steps.check-output.outputs.result }}
73
30
- name : Checkout
74
31
uses : actions/checkout@v3
75
32
with :
@@ -78,58 +35,24 @@ jobs:
78
35
run : |
79
36
git config --global user.email "npm-cli+bot@github.com"
80
37
git config --global user.name "npm CLI robot"
38
+ - name : Create Check
39
+ id : create-check
40
+ if : ${{ inputs.check-sha }}
41
+ uses : ./.github/actions/create-check
42
+ with :
43
+ name : " Lint All"
44
+ token : ${{ secrets.GITHUB_TOKEN }}
45
+ sha : ${{ inputs.check-sha }}
81
46
- name : Setup Node
82
47
uses : actions/setup-node@v3
83
48
id : node
84
49
with :
85
50
node-version : 20.x
86
51
check-latest : contains('20.x', '.x')
87
-
88
- # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
89
- - name : Update Windows npm
90
- if : |
91
- matrix.platform.os == 'windows-latest' && (
92
- startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
93
- )
94
- run : |
95
- curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
96
- tar xf npm-7.5.4.tgz
97
- cd package
98
- node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
99
- cd ..
100
- rmdir /s /q package
101
-
102
- # Start on Node 10 because we dont test on anything lower
103
- - name : Install npm@7 on Node 10
104
- shell : bash
105
- if : startsWith(steps.node.outputs.node-version, 'v10.')
106
- id : npm-7
107
- run : |
108
- npm i --prefer-online --no-fund --no-audit -g npm@7
109
- echo "updated=true" >> "$GITHUB_OUTPUT"
110
-
111
- - name : Install npm@8 on Node 12
112
- shell : bash
113
- if : startsWith(steps.node.outputs.node-version, 'v12.')
114
- id : npm-8
115
- run : |
116
- npm i --prefer-online --no-fund --no-audit -g npm@8
117
- echo "updated=true" >> "$GITHUB_OUTPUT"
118
-
119
- - name : Install npm@9 on Node 14/16/18.0
120
- shell : bash
121
- if : startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
122
- id : npm-9
123
- run : |
124
- npm i --prefer-online --no-fund --no-audit -g npm@9
125
- echo "updated=true" >> "$GITHUB_OUTPUT"
126
-
127
- - name : Install npm@latest on Node
128
- if : ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
129
- run : npm i --prefer-online --no-fund --no-audit -g npm@latest
130
-
131
- - name : npm Version
132
- run : npm -v
52
+ - name : Install Latest npm
53
+ uses : ./.github/actions/install-latest-npm
54
+ with :
55
+ node : ${{ steps.node.outputs.node-version }}
133
56
- name : Install Dependencies
134
57
run : npm i --ignore-scripts --no-audit --no-fund
135
58
- name : Lint
@@ -138,11 +61,11 @@ jobs:
138
61
run : npm run postlint --ignore-scripts
139
62
- name : Conclude Check
140
63
uses : LouisBrunner/checks-action@v1.6.0
141
- if : steps.check.outputs.check_id && always()
64
+ if : always()
142
65
with :
143
66
token : ${{ secrets.GITHUB_TOKEN }}
144
67
conclusion : ${{ job.status }}
145
- check_id : ${{ steps.check.outputs.check_id }}
68
+ check_id : ${{ steps.create- check.outputs.check-id }}
146
69
147
70
test-all :
148
71
name : Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
@@ -173,49 +96,6 @@ jobs:
173
96
run :
174
97
shell : ${{ matrix.platform.shell }}
175
98
steps :
176
- - name : Get Workflow Job
177
- uses : actions/github-script@v6
178
- if : inputs.check-sha
179
- id : check-output
180
- env :
181
- JOB_NAME : " Test All"
182
- MATRIX_NAME : " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
183
- with :
184
- script : |
185
- const { owner, repo } = context.repo
186
-
187
- const { data } = await github.rest.actions.listJobsForWorkflowRun({
188
- owner,
189
- repo,
190
- run_id: context.runId,
191
- per_page: 100
192
- })
193
-
194
- const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
195
- const job = data.jobs.find(j => j.name.endsWith(jobName))
196
- const jobUrl = job?.html_url
197
-
198
- const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
199
-
200
- let summary = `This check is assosciated with ${shaUrl}\n\n`
201
-
202
- if (jobUrl) {
203
- summary += `For run logs, click here: ${jobUrl}`
204
- } else {
205
- summary += `Run logs could not be found for a job with name: "${jobName}"`
206
- }
207
-
208
- return { summary }
209
- - name : Create Check
210
- uses : LouisBrunner/checks-action@v1.6.0
211
- id : check
212
- if : inputs.check-sha
213
- with :
214
- token : ${{ secrets.GITHUB_TOKEN }}
215
- status : in_progress
216
- name : Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
217
- sha : ${{ inputs.check-sha }}
218
- output : ${{ steps.check-output.outputs.result }}
219
99
- name : Checkout
220
100
uses : actions/checkout@v3
221
101
with :
@@ -224,58 +104,24 @@ jobs:
224
104
run : |
225
105
git config --global user.email "npm-cli+bot@github.com"
226
106
git config --global user.name "npm CLI robot"
107
+ - name : Create Check
108
+ id : create-check
109
+ if : ${{ inputs.check-sha }}
110
+ uses : ./.github/actions/create-check
111
+ with :
112
+ name : " Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
113
+ token : ${{ secrets.GITHUB_TOKEN }}
114
+ sha : ${{ inputs.check-sha }}
227
115
- name : Setup Node
228
116
uses : actions/setup-node@v3
229
117
id : node
230
118
with :
231
119
node-version : ${{ matrix.node-version }}
232
120
check-latest : contains(matrix.node-version, '.x')
233
-
234
- # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
235
- - name : Update Windows npm
236
- if : |
237
- matrix.platform.os == 'windows-latest' && (
238
- startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
239
- )
240
- run : |
241
- curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
242
- tar xf npm-7.5.4.tgz
243
- cd package
244
- node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
245
- cd ..
246
- rmdir /s /q package
247
-
248
- # Start on Node 10 because we dont test on anything lower
249
- - name : Install npm@7 on Node 10
250
- shell : bash
251
- if : startsWith(steps.node.outputs.node-version, 'v10.')
252
- id : npm-7
253
- run : |
254
- npm i --prefer-online --no-fund --no-audit -g npm@7
255
- echo "updated=true" >> "$GITHUB_OUTPUT"
256
-
257
- - name : Install npm@8 on Node 12
258
- shell : bash
259
- if : startsWith(steps.node.outputs.node-version, 'v12.')
260
- id : npm-8
261
- run : |
262
- npm i --prefer-online --no-fund --no-audit -g npm@8
263
- echo "updated=true" >> "$GITHUB_OUTPUT"
264
-
265
- - name : Install npm@9 on Node 14/16/18.0
266
- shell : bash
267
- if : startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
268
- id : npm-9
269
- run : |
270
- npm i --prefer-online --no-fund --no-audit -g npm@9
271
- echo "updated=true" >> "$GITHUB_OUTPUT"
272
-
273
- - name : Install npm@latest on Node
274
- if : ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
275
- run : npm i --prefer-online --no-fund --no-audit -g npm@latest
276
-
277
- - name : npm Version
278
- run : npm -v
121
+ - name : Install Latest npm
122
+ uses : ./.github/actions/install-latest-npm
123
+ with :
124
+ node : ${{ steps.node.outputs.node-version }}
279
125
- name : Install Dependencies
280
126
run : npm i --ignore-scripts --no-audit --no-fund
281
127
- name : Add Problem Matcher
@@ -284,8 +130,8 @@ jobs:
284
130
run : npm test --ignore-scripts
285
131
- name : Conclude Check
286
132
uses : LouisBrunner/checks-action@v1.6.0
287
- if : steps.check.outputs.check_id && always()
133
+ if : always()
288
134
with :
289
135
token : ${{ secrets.GITHUB_TOKEN }}
290
136
conclusion : ${{ job.status }}
291
- check_id : ${{ steps.check.outputs.check_id }}
137
+ check_id : ${{ steps.create- check.outputs.check-id }}
0 commit comments