Skip to content

Commit 83c7cc6

Browse files
hmaurerelireisman
authored andcommitted
Do not list changes dependencies in summary
1 parent b3559aa commit 83c7cc6

File tree

6 files changed

+18
-76
lines changed

6 files changed

+18
-76
lines changed

__tests__/summary.test.ts

+3-43
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

+6-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/create_summary.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async function createSummary(
143143
...licenseIssues.unlicensed
144144
]
145145

146-
summary.addScannedDependencies(allChanges)
146+
summary.addScannedFiles(allChanges)
147147

148148
const text = core.summary.stringify()
149149
await fs.promises.writeFile(path.resolve(tmpDir, fileName), text, {

src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async function run(): Promise<void> {
166166
}
167167

168168
core.setOutput('dependency-changes', JSON.stringify(changes))
169-
summary.addScannedDependencies(changes)
169+
summary.addScannedFiles(changes)
170170
printScannedDependencies(changes)
171171

172172
// include full summary in output; Actions will truncate if oversized

src/summary.ts

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as core from '@actions/core'
2-
import {ConfigurationOptions, Changes, Change, Scorecard} from './schemas'
32
import {SummaryTableRow} from '@actions/core/lib/summary'
43
import {InvalidLicenseChanges, InvalidLicenseChangeTypes} from './licenses'
4+
import {Change, Changes, ConfigurationOptions, Scorecard} from './schemas'
55
import {groupDependenciesByManifest, getManifestsSet, renderUrl} from './utils'
66

77
const icons = {
@@ -263,21 +263,11 @@ function formatLicense(license: string | null): string {
263263
return license
264264
}
265265

266-
export function addScannedDependencies(changes: Changes): void {
267-
const dependencies = groupDependenciesByManifest(changes)
268-
const manifests = dependencies.keys()
269-
270-
const summary = core.summary.addHeading('Scanned Manifest Files', 2)
271-
272-
for (const manifest of manifests) {
273-
const deps = dependencies.get(manifest)
274-
if (deps) {
275-
const dependencyNames = deps.map(
276-
dependency => `<li>${dependency.name}@${dependency.version}</li>`
277-
)
278-
summary.addDetails(manifest, `<ul>${dependencyNames.join('')}</ul>`)
279-
}
280-
}
266+
export function addScannedFiles(changes: Changes): void {
267+
const manifests = Array.from(
268+
groupDependenciesByManifest(changes).keys()
269+
).sort()
270+
core.summary.addHeading('Scanned Files', 2).addList(manifests)
281271
}
282272

283273
function snapshotWarningRecommendation(

0 commit comments

Comments
 (0)