Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit da02fdd

Browse files
committed
fix: template-oss
1 parent 4282cc4 commit da02fdd

File tree

11 files changed

+4671
-2816
lines changed

11 files changed

+4671
-2816
lines changed

.github/actions/audit/action.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ inputs:
1010
runs:
1111
using: composite
1212
steps:
13-
- name: Run Audit
13+
- name: Run Production Audit
1414
shell: ${{ inputs.shell }}
1515
run: |
1616
npm audit --omit=dev
17+
- name: Run Full Audit
18+
shell: ${{ inputs.shell }}
19+
run: |
1720
npm audit --audit-level=none

.github/actions/changed-files/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ inputs:
88
required: true
99

1010
outputs:
11-
files:
11+
names:
1212
value: ${{ steps.files.outputs.result }}
1313

1414
runs:

.github/actions/changed-workspaces/action.yml

+4-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@ name: Get Changed Workspaces
55
inputs:
66
token:
77
description: GitHub token to use
8-
shell:
9-
description: shell to run on
10-
default: bash
11-
all:
12-
default: false
13-
type: boolean
148
files:
15-
description: json stringified array of file names
16-
type: string
9+
description: json stringified array of file names or --all
1710

1811
outputs:
1912
flags:
@@ -24,14 +17,14 @@ runs:
2417
steps:
2518
- name: Get Changed Files
2619
uses: ./.github/actions/changed-files
27-
if: ${{ !inputs.all && !inputs.files }}
20+
if: ${{ !inputs.files }}
2821
id: files
2922
with:
3023
token: ${{ inputs.token }}
3124

3225
- name: Get Workspaces
33-
shell: ${{ inputs.shell }}
26+
shell: bash
3427
id: workspaces
3528
run: |
36-
flags=$(npm exec --offline -- template-oss-changed-workspaces '${{ (inputs.all && '--all') || (inputs.files || steps.files.outputs.result) }}')
29+
flags=$(npm exec --offline -- template-oss-changed-workspaces '${{ inputs.files || steps.files.outputs.names }}')
3730
echo "flags=${flags}" >> $GITHUB_OUTPUT

.github/actions/lint/action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ runs:
1616
shell: ${{ inputs.shell }}
1717
run: |
1818
npm run lint --ignore-scripts ${{ inputs.flags }}
19+
- name: Post Lint
20+
shell: ${{ inputs.shell }}
21+
run: |
1922
npm run postlint --ignore-scripts ${{ inputs.flags }}

.github/actions/setup/action.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ inputs:
1212
default: latest
1313
cache:
1414
description: whether to cache npm install or not
15-
type: boolean
1615
default: true
1716
shell:
1817
description: shell to run on
1918
default: bash
2019
deps:
2120
description: whether to run the deps step
22-
type: boolean
23-
default: true
21+
default: 'true'
2422
deps-command:
2523
description: command to run for the dependencies step
2624
default: install --ignore-scripts --no-audit --no-fund
@@ -40,12 +38,12 @@ runs:
4038
uses: actions/setup-node@v3
4139
with:
4240
node-version: ${{ inputs.node-version }}
43-
cache: ${{ (inputs.cache && 'npm') || null }}
41+
cache: ${{ (inputs.cache == 'true' && 'npm') || '' }}
4442

4543
- name: Check Node Version
4644
if: inputs.npm-version
4745
id: node-version
48-
shell: ${{ inputs.shell }}
46+
shell: bash
4947
run: |
5048
NODE_VERSION=$(node --version)
5149
echo $NODE_VERSION
@@ -83,13 +81,13 @@ runs:
8381
run: npm -v
8482

8583
- name: Setup Dependencies
86-
if: inputs.deps
84+
if: inputs.deps == 'true'
8785
uses: ./.github/actions/deps
8886
with:
8987
command: ${{ inputs.deps-command }}
9088
flags: ${{ inputs.deps-flags }}
9189

9290
- name: Add Problem Matcher
93-
shell: ${{ inputs.shell }}
91+
shell: bash
9492
run: |
9593
[[ -f ./.github/matchers/tap.json ]] && echo "::add-matcher::.github/matchers/tap.json"

.github/dependabot.yml

-72
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,3 @@ updates:
1515
prefix-development: chore
1616
labels:
1717
- "Dependencies"
18-
- package-ecosystem: npm
19-
directory: pkg1/
20-
schedule:
21-
interval: daily
22-
allow:
23-
- dependency-type: direct
24-
versioning-strategy: increase-if-necessary
25-
commit-message:
26-
prefix: deps
27-
prefix-development: chore
28-
labels:
29-
- "Dependencies"
30-
- package-ecosystem: npm
31-
directory: pkg2/
32-
schedule:
33-
interval: daily
34-
allow:
35-
- dependency-type: direct
36-
versioning-strategy: increase-if-necessary
37-
commit-message:
38-
prefix: deps
39-
prefix-development: chore
40-
labels:
41-
- "Dependencies"
42-
- package-ecosystem: npm
43-
directory: pkg3/
44-
schedule:
45-
interval: daily
46-
allow:
47-
- dependency-type: direct
48-
versioning-strategy: increase-if-necessary
49-
commit-message:
50-
prefix: deps
51-
prefix-development: chore
52-
labels:
53-
- "Dependencies"
54-
- package-ecosystem: npm
55-
directory: workspaces/arbitrary-name/
56-
schedule:
57-
interval: daily
58-
allow:
59-
- dependency-type: direct
60-
versioning-strategy: increase-if-necessary
61-
commit-message:
62-
prefix: deps
63-
prefix-development: chore
64-
labels:
65-
- "Dependencies"
66-
- package-ecosystem: npm
67-
directory: workspaces/not-the-name/
68-
schedule:
69-
interval: daily
70-
allow:
71-
- dependency-type: direct
72-
versioning-strategy: increase-if-necessary
73-
commit-message:
74-
prefix: deps
75-
prefix-development: chore
76-
labels:
77-
- "Dependencies"
78-
- package-ecosystem: npm
79-
directory: workspaces/pkg6/
80-
schedule:
81-
interval: daily
82-
allow:
83-
- dependency-type: direct
84-
versioning-strategy: increase-if-necessary
85-
commit-message:
86-
prefix: deps
87-
prefix-development: chore
88-
labels:
89-
- "Dependencies"

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
uses: ./.github/actions/changed-workspaces
6868
with:
6969
token: ${{ secrets.GITHUB_TOKEN }}
70-
all: ${{ inputs.all }}
70+
files: ${{ (inputs.all && '--all') || '' }}
7171

7272
- name: Lint
7373
uses: ./.github/actions/lint
@@ -107,6 +107,7 @@ jobs:
107107
steps:
108108
- name: Continue Matrix Run
109109
id: continue-matrix
110+
shell: bash
110111
run: |
111112
if [[ "${{ matrix.node-version }}" == "14.17.0" || "${{ inputs.all }}" == "true" ]]; then
112113
echo "result=true" >> $GITHUB_OUTPUT
@@ -142,9 +143,8 @@ jobs:
142143
continue-on-error: ${{ !!steps.check.outputs.check-id }}
143144
uses: ./.github/actions/changed-workspaces
144145
with:
145-
shell: ${{ matrix.platform.shell }}
146146
token: ${{ secrets.GITHUB_TOKEN }}
147-
all: ${{ inputs.all }}
147+
files: ${{ (inputs.all && '--all') || '' }}
148148

149149
- name: Test
150150
if: steps.continue-matrix.outputs.result

.github/workflows/post-dependabot.yml

+45-20
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22

33
name: Post Dependabot
44

5-
on: pull_request
5+
on:
6+
# workflow dispatch is only for testing
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: ref to test
11+
directory:
12+
description: package directory to test
13+
update-type:
14+
description: update type to test
15+
pull_request:
16+
617

718
jobs:
8-
template-oss:
9-
name: template-oss
19+
dependency:
20+
name: "@npmcli/template-oss"
1021
permissions:
1122
contents: write
23+
outputs:
24+
sha: ${{ steps.push-on-error.outputs.sha || steps.push.outputs.sha }}
25+
changes: ${{ steps.apply.outputs.changes }}
26+
message: ${{ steps.apply.outputs.message }}
1227
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
1328
runs-on: ubuntu-latest
1429
defaults:
@@ -17,20 +32,21 @@ jobs:
1732
steps:
1833
- name: Fetch Dependabot Metadata
1934
id: metadata
35+
if: github.event_name != 'workflow_dispatch'
2036
uses: dependabot/fetch-metadata@v1
2137
with:
2238
github-token: ${{ secrets.GITHUB_TOKEN }}
2339

2440
- name: Is Dependency
25-
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
41+
if: github.event_name == 'workflow_dispatch' || contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
2642
id: dependency
2743
run: echo "continue=true" >> $GITHUB_OUTPUT
2844

2945
- name: Checkout
3046
if: steps.dependency.outputs.continue
3147
uses: actions/checkout@v3
3248
with:
33-
ref: ${{ github.event.pull_request.head.ref }}
49+
ref: ${{ inputs.ref || github.event.pull_request.head.ref }}
3450

3551
- name: Setup
3652
if: steps.dependency.outputs.continue
@@ -42,7 +58,7 @@ jobs:
4258
id: workspaces
4359
with:
4460
token: ${{ secrets.GITHUB_TOKEN }}
45-
files: '["${{ steps.metadata.outputs.directory }}"]'
61+
files: '["${{ inputs.directory || steps.metadata.outputs.directory }}"]'
4662

4763
- name: Apply Changes
4864
if: steps.workspaces.outputs.flags
@@ -55,7 +71,7 @@ jobs:
5571
# This only sets the conventional commit prefix. This workflow can't reliably determine
5672
# what the breaking change is though. If a BREAKING CHANGE message is required then
5773
# this PR check will fail and the commit will be amended with stafftools
58-
if [[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
74+
if [[ "${{ inputs.update-type || steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
5975
prefix='feat!'
6076
else
6177
prefix='chore'
@@ -74,12 +90,14 @@ jobs:
7490
run: |
7591
git commit -am "${{ steps.apply.outputs.message }}"
7692
git push
93+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
7794
7895
# If the previous step failed, then reset the commit and remove any workflow changes
7996
# and attempt to commit and push again. This is helpful because we will have a commit
8097
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
8198
- name: Push All Changes Except Workflows
8299
if: steps.apply.outputs.changes && steps.push.outcome == 'failure'
100+
id: push-on-error
83101
env:
84102
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85103
run: |
@@ -88,22 +106,29 @@ jobs:
88106
git clean -fd .github/workflows/
89107
git commit -am "${{ steps.apply.outputs.message }}"
90108
git push
109+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
91110
92-
# Check if all the necessary template-oss changes were applied. Since we continued
93-
# on errors in one of the previous steps, this check will fail if our follow up
94-
# only applied a portion of the changes and we need to followup manually.
95-
#
96-
# Note that this used to run `lint` and `postlint` but that will fail this action
97-
# if we've also shipped any linting changes separate from template-oss. We do
98-
# linting in another action, so we want to fail this one only if there are
99-
# template-oss changes that could not be applied.
100-
- name: Check Changes
101-
if: steps.apply.outputs.changes
102-
run: |
103-
npm exec --offline ${{ steps.workspaces.outputs.flags }} -- template-oss-check
111+
ci:
112+
name: Dependency - CI
113+
needs: [ dependency ]
114+
continue-on-error: true
115+
if: needs.dependency.outputs.changes
116+
uses: ./.github/workflows/ci.yml
117+
with:
118+
ref: ${{ inputs.ref || github.base_ref }}
119+
check-sha: ${{ needs.dependency.outputs.sha }}
104120

121+
post-ci:
122+
name: Dependency - Post CI
123+
needs: [ ci, dependency ]
124+
if: needs.dependency.outputs.changes
125+
runs-on: ubuntu-latest
126+
defaults:
127+
run:
128+
shell: bash
129+
steps:
105130
- name: Fail on Breaking Change
106-
if: steps.apply.outputs.changes && startsWith(steps.apply.outputs.message, 'feat!')
131+
if: needs.dependency.outputs.changes && startsWith(needs.dependency.outputs.message, 'feat!')
107132
run: |
108133
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
109134
echo "for more information on how to fix this with a BREAKING CHANGE footer."

SECURITY.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ GitHub takes the security of our software products and services seriously, inclu
44

55
If you believe you have found a security vulnerability in this GitHub-owned open source repository, you can report it to us in one of two ways.
66

7-
If the vulnerability you have found is *not* [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) or if you do not wish to be considered for a bounty reward, please report the issue to us directly using [private vulnerability reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).
7+
If the vulnerability you have found is *not* [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) or if you do not wish to be considered for a bounty reward, please report the issue to us directly through [[email protected]](mailto:opensource-security@github.com).
88

99
If the vulnerability you have found is [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) and you would like for your finding to be considered for a bounty reward, please submit the vulnerability to us through [HackerOne](https://hackerone.com/github) in order to be eligible to receive a bounty award.
1010

1111
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
1212

1313
Thanks for helping make GitHub safe for everyone.
14-

0 commit comments

Comments
 (0)