Skip to content

Commit bcdd8dd

Browse files
committed
chore: postinstall for dependabot template-oss PR
1 parent 39ffabc commit bcdd8dd

File tree

14 files changed

+344
-320
lines changed

14 files changed

+344
-320
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: 'Create Check'
4+
inputs:
5+
name:
6+
required: true
7+
token:
8+
required: true
9+
sha:
10+
required: true
11+
check-name:
12+
default: ''
13+
outputs:
14+
check-id:
15+
value: ${{ steps.create-check.outputs.check_id }}
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Get Workflow Job
20+
uses: actions/github-script@v6
21+
id: workflow
22+
env:
23+
JOB_NAME: "${{ inputs.name }}"
24+
SHA: "${{ inputs.sha }}"
25+
with:
26+
result-encoding: string
27+
script: |
28+
const { repo: { owner, repo}, runId, serverUrl } = context
29+
const { JOB_NAME, SHA } = process.env
30+
31+
const job = await github.rest.actions.listJobsForWorkflowRun({
32+
owner,
33+
repo,
34+
run_id: runId,
35+
per_page: 100
36+
}).then(r => r.data.jobs.find(j => j.name.endsWith(JOB_NAME)))
37+
38+
return [
39+
`This check is assosciated with ${serverUrl}/${owner}/${repo}/commit/${SHA}.`,
40+
'Run logs:',
41+
job?.html_url || `could not be found for a job ending with: "${JOB_NAME}"`,
42+
].join(' ')
43+
- name: Create Check
44+
uses: LouisBrunner/[email protected]
45+
id: create-check
46+
with:
47+
token: ${{ inputs.token }}
48+
sha: ${{ inputs.sha }}
49+
status: in_progress
50+
name: ${{ inputs.check-name || inputs.name }}
51+
output: |
52+
{"summary":"${{ steps.workflow.outputs.result }}"}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: 'Install Latest npm'
4+
description: 'Install the latest version of npm compatible with the Node version'
5+
inputs:
6+
node:
7+
description: 'Current Node version'
8+
required: true
9+
runs:
10+
using: "composite"
11+
steps:
12+
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
13+
- name: Update Windows npm
14+
if: |
15+
runner.os == 'Windows' && (
16+
startsWith(inputs.node, 'v10.') ||
17+
startsWith(inputs.node, 'v12.') ||
18+
startsWith(inputs.node, 'v14.')
19+
)
20+
shell: cmd
21+
run: |
22+
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
23+
tar xf npm-7.5.4.tgz
24+
cd package
25+
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
26+
cd ..
27+
rmdir /s /q package
28+
- name: Install Latest npm
29+
shell: bash
30+
env:
31+
NODE_VERSION: ${{ inputs.node }}
32+
working-directory: ${{ runner.temp }}
33+
run: |
34+
MATCH=""
35+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
36+
37+
echo "node@$NODE_VERSION"
38+
39+
for SPEC in ${SPECS[@]}; do
40+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
41+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
42+
43+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
44+
MATCH=$SPEC
45+
echo "Found compatible version: npm@$MATCH"
46+
break
47+
fi
48+
done
49+
50+
if [ -z $MATCH ]; then
51+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
52+
exit 1
53+
fi
54+
55+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
56+
- name: npm Version
57+
shell: bash
58+
run: npm -v

.github/workflows/audit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
with:
3030
node-version: 20.x
3131
check-latest: contains('20.x', '.x')
32-
3332
- name: Remove Template-OSS
3433
if: matrix && matrix.node-version == '6.17.1'
3534
run: |

.github/workflows/ci-release.yml

Lines changed: 20 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,6 @@ jobs:
2727
run:
2828
shell: bash
2929
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/[email protected]
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 }}
7330
- name: Checkout
7431
uses: actions/checkout@v3
7532
with:
@@ -78,13 +35,20 @@ jobs:
7835
run: |
7936
git config --global user.email "[email protected]"
8037
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 }}
8146
- name: Setup Node
8247
uses: actions/setup-node@v3
8348
id: node
8449
with:
8550
node-version: 20.x
8651
check-latest: contains('20.x', '.x')
87-
8852
- name: Remove Template-OSS
8953
if: matrix && matrix.node-version == '6.17.1'
9054
run: |
@@ -100,11 +64,11 @@ jobs:
10064
run: npm run postlint --ignore-scripts
10165
- name: Conclude Check
10266
uses: LouisBrunner/[email protected]
103-
if: steps.check.outputs.check_id && always()
67+
if: always()
10468
with:
10569
token: ${{ secrets.GITHUB_TOKEN }}
10670
conclusion: ${{ job.status }}
107-
check_id: ${{ steps.check.outputs.check_id }}
71+
check_id: ${{ steps.create-check.outputs.check-id }}
10872

10973
test-all:
11074
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
@@ -124,49 +88,6 @@ jobs:
12488
run:
12589
shell: ${{ matrix.platform.shell }}
12690
steps:
127-
- name: Get Workflow Job
128-
uses: actions/github-script@v6
129-
if: inputs.check-sha
130-
id: check-output
131-
env:
132-
JOB_NAME: "Test All"
133-
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
134-
with:
135-
script: |
136-
const { owner, repo } = context.repo
137-
138-
const { data } = await github.rest.actions.listJobsForWorkflowRun({
139-
owner,
140-
repo,
141-
run_id: context.runId,
142-
per_page: 100
143-
})
144-
145-
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
146-
const job = data.jobs.find(j => j.name.endsWith(jobName))
147-
const jobUrl = job?.html_url
148-
149-
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
150-
151-
let summary = `This check is assosciated with ${shaUrl}\n\n`
152-
153-
if (jobUrl) {
154-
summary += `For run logs, click here: ${jobUrl}`
155-
} else {
156-
summary += `Run logs could not be found for a job with name: "${jobName}"`
157-
}
158-
159-
return { summary }
160-
- name: Create Check
161-
uses: LouisBrunner/[email protected]
162-
id: check
163-
if: inputs.check-sha
164-
with:
165-
token: ${{ secrets.GITHUB_TOKEN }}
166-
status: in_progress
167-
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
168-
sha: ${{ inputs.check-sha }}
169-
output: ${{ steps.check-output.outputs.result }}
17091
- name: Checkout
17192
uses: actions/checkout@v3
17293
with:
@@ -175,13 +96,20 @@ jobs:
17596
run: |
17697
git config --global user.email "[email protected]"
17798
git config --global user.name "npm CLI robot"
99+
- name: Create Check
100+
id: create-check
101+
if: ${{ inputs.check-sha }}
102+
uses: ./.github/actions/create-check
103+
with:
104+
name: "Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
105+
token: ${{ secrets.GITHUB_TOKEN }}
106+
sha: ${{ inputs.check-sha }}
178107
- name: Setup Node
179108
uses: actions/setup-node@v3
180109
id: node
181110
with:
182111
node-version: ${{ matrix.node-version }}
183112
check-latest: contains(matrix.node-version, '.x')
184-
185113
- name: Remove Template-OSS
186114
if: matrix && matrix.node-version == '6.17.1'
187115
run: |
@@ -197,8 +125,8 @@ jobs:
197125
run: npm test --ignore-scripts
198126
- name: Conclude Check
199127
uses: LouisBrunner/[email protected]
200-
if: steps.check.outputs.check_id && always()
128+
if: always()
201129
with:
202130
token: ${{ secrets.GITHUB_TOKEN }}
203131
conclusion: ${{ job.status }}
204-
check_id: ${{ steps.check.outputs.check_id }}
132+
check_id: ${{ steps.create-check.outputs.check-id }}

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
with:
3535
node-version: 20.x
3636
check-latest: contains('20.x', '.x')
37-
3837
- name: Remove Template-OSS
3938
if: matrix && matrix.node-version == '6.17.1'
4039
run: |
@@ -79,7 +78,6 @@ jobs:
7978
with:
8079
node-version: ${{ matrix.node-version }}
8180
check-latest: contains(matrix.node-version, '.x')
82-
8381
- name: Remove Template-OSS
8482
if: matrix && matrix.node-version == '6.17.1'
8583
run: |

.github/workflows/pull-request.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ jobs:
3333
with:
3434
node-version: 20.x
3535
check-latest: contains('20.x', '.x')
36-
3736
- name: Remove Template-OSS
3837
if: matrix && matrix.node-version == '6.17.1'
3938
run: |
@@ -46,11 +45,9 @@ jobs:
4645
- name: Run Commitlint on Commits
4746
id: commit
4847
continue-on-error: true
49-
run: |
50-
npx --offline commitlint -V --from 'origin/${{ github.base_ref }}' --to ${{ github.event.pull_request.head.sha }}
48+
run: npx --offline commitlint -V --from 'origin/${{ github.base_ref }}' --to ${{ github.event.pull_request.head.sha }}
5149
- name: Run Commitlint on PR Title
5250
if: steps.commit.outcome == 'failure'
5351
env:
5452
PR_TITLE: ${{ github.event.pull_request.title }}
55-
run: |
56-
echo "$PR_TITLE" | npx --offline commitlint -V
53+
run: echo "$PR_TITLE" | npx --offline commitlint -V

0 commit comments

Comments
 (0)