Skip to content

Commit fc499fc

Browse files
committed
Merge branch 'main' into fix/comment-warn-only
2 parents ac1d2d7 + b02ea3a commit fc499fc

File tree

12 files changed

+274
-324
lines changed

12 files changed

+274
-324
lines changed

.github/workflows/stale.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ jobs:
1515
- uses: actions/[email protected]
1616
name: Clean up stale PRs and Issues
1717
with:
18-
stale-pr-message: "👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing, this pull request will be closed eventually by the stale bot. Please see CONTRIBUTING.md for more policy details."
18+
stale-pr-message: "👋 This pull request has been marked as stale because it has been open with no activity for 180 days. You can: comment on the PR or remove the stale label to hold stalebot off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing, this pull request will be closed eventually by the stalebot. Please see CONTRIBUTING.md for more policy details."
1919
stale-pr-label: "Stale"
20+
close-pr-message: "👋 This pull request has been closed by stalebot because it has been open with no activity for over 180 days. Please see CONTRIBUTING.md for more policy details."
2021
stale-issue-label: "Stale"
22+
stale-issue-message: "👋 This issue has been marked as stale because it has been open with no activity for 180 days. You can: comment on the issue or remove the stale label to hold stalebot off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing, this issue will be closed eventually by the stalebot. Please see CONTRIBUTING.md for more policy details."
23+
close-issue-message: "👋 This issue has been closed by stalebot because it has been open with no activity for over 180 days. Please see CONTRIBUTING.md for more policy details."
2124
exempt-pr-labels: "Keep" # a "Keep" label will keep the PR from being closed as stale
2225
exempt-issue-labels: "Keep" # a "Keep" label will keep the issue from being closed as stale
2326
days-before-pr-stale: 180 # when the PR is considered stale

__tests__/config.test.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ test('it raises an error when no refs are provided and the event is not a pull r
124124
).toThrow()
125125
})
126126

127-
const pullRequestLikeEvents = [
128-
'pull_request',
129-
'pull_request_target',
130-
'merge_group'
131-
]
127+
const pullRequestLikeEvents = ['pull_request', 'pull_request_target']
132128

133129
test.each(pullRequestLikeEvents)(
134130
'it uses the given refs even when the event is %s',
@@ -152,7 +148,7 @@ test.each(pullRequestLikeEvents)(
152148
)
153149

154150
test.each(pullRequestLikeEvents)(
155-
'it uses the event refs when the event is %s and the no refs are input',
151+
'it uses the event refs when the event is %s and no refs are provided in config',
156152
async eventName => {
157153
const refs = getRefs(await readConfig(), {
158154
payload: {
@@ -169,6 +165,37 @@ test.each(pullRequestLikeEvents)(
169165
}
170166
)
171167

168+
test('it uses the given refs even when the event is merge_group', async () => {
169+
setInput('base-ref', 'a-custom-base-ref')
170+
setInput('head-ref', 'a-custom-head-ref')
171+
172+
const refs = getRefs(await readConfig(), {
173+
payload: {
174+
merge_group: {
175+
base_sha: 'pr-base-ref',
176+
head_sha: 'pr-head-ref'
177+
}
178+
},
179+
eventName: 'merge_group'
180+
})
181+
expect(refs.base).toEqual('a-custom-base-ref')
182+
expect(refs.head).toEqual('a-custom-head-ref')
183+
})
184+
185+
test('it uses the event refs when the event is merge_group and no refs are provided in config', async () => {
186+
const refs = getRefs(await readConfig(), {
187+
payload: {
188+
merge_group: {
189+
base_sha: 'pr-base-ref',
190+
head_sha: 'pr-head-ref'
191+
}
192+
},
193+
eventName: 'merge_group'
194+
})
195+
expect(refs.base).toEqual('pr-base-ref')
196+
expect(refs.head).toEqual('pr-head-ref')
197+
})
198+
172199
test('it defaults to runtime scope', async () => {
173200
const config = await readConfig()
174201
expect(config.fail_on_scopes).toEqual(['runtime'])

__tests__/summary.test.ts

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -109,42 +109,6 @@ test('prints headline as h1', () => {
109109
expect(text).toContain('<h1>Dependency Review</h1>')
110110
})
111111

112-
test('returns minimal summary in case the core.summary is too large for a PR comment', () => {
113-
let changes: Changes = [
114-
createTestChange({name: 'lodash', version: '1.2.3'}),
115-
createTestChange({name: 'colors', version: '2.3.4'}),
116-
createTestChange({name: '@foo/bar', version: '*'})
117-
]
118-
119-
let minSummary: string = summary.addSummaryToSummary(
120-
changes,
121-
emptyInvalidLicenseChanges,
122-
emptyChanges,
123-
scorecard,
124-
defaultConfig
125-
)
126-
127-
// side effect DR report into core.summary as happens in main.ts
128-
summary.addScannedDependencies(changes)
129-
const text = core.summary.stringify()
130-
131-
expect(text).toContain('<h1>Dependency Review</h1>')
132-
expect(minSummary).toContain('# Dependency Review')
133-
134-
expect(text).toContain('❌ 3 vulnerable package(s)')
135-
expect(text).not.toContain('* ❌ 3 vulnerable package(s)')
136-
expect(text).toContain('lodash')
137-
expect(text).toContain('colors')
138-
expect(text).toContain('@foo/bar')
139-
140-
expect(minSummary).toContain('* ❌ 3 vulnerable package(s)')
141-
expect(minSummary).not.toContain('lodash')
142-
expect(minSummary).not.toContain('colors')
143-
expect(minSummary).not.toContain('@foo/bar')
144-
145-
expect(text.length).toBeGreaterThan(minSummary.length)
146-
})
147-
148112
test('returns minimal summary formatted for posting as a PR comment', () => {
149113
const OLD_ENV = process.env
150114

@@ -232,14 +196,10 @@ test('groups dependencies with empty manifest paths together', () => {
232196
emptyScorecard,
233197
defaultConfig
234198
)
235-
summary.addScannedDependencies(changesWithEmptyManifests)
199+
summary.addScannedFiles(changesWithEmptyManifests)
236200
const text = core.summary.stringify()
237-
238-
expect(text).toContain('<summary>Unnamed Manifest</summary>')
239-
expect(text).toContain('castore')
240-
expect(text).toContain('connection')
241-
expect(text).toContain('<summary>python/dist-info/METADATA</summary>')
242-
expect(text).toContain('pygments')
201+
expect(text).toContain('Unnamed Manifest')
202+
expect(text).toContain('python/dist-info/METADATA')
243203
})
244204

245205
test('does not include status section if nothing was found', () => {

dist/index.js

Lines changed: 45 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)