Skip to content

Commit

Permalink
Make snapshot warning messages clearer and more actionable
Browse files Browse the repository at this point in the history
  • Loading branch information
juxtin authored Sep 7, 2023
1 parent e4d20ce commit bed9726
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
22 changes: 19 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function run(): Promise<void> {
)

if (snapshot_warnings) {
summary.addSnapshotWarnings(snapshot_warnings)
summary.addSnapshotWarnings(config, snapshot_warnings)
}

if (config.vulnerability_check) {
Expand Down
30 changes: 26 additions & 4 deletions src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,34 @@ export function addScannedDependencies(changes: Changes): void {
}
}

export function addSnapshotWarnings(warnings: string): void {
function snapshotWarningRecommendation(
config: ConfigurationOptions,
warnings: string
): string {
const no_pr_snaps = warnings.includes(
'No snapshots were found for the head SHA'
)
const retries_disabled = !config.retry_on_snapshot_warnings
if (no_pr_snaps && retries_disabled) {
return 'Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings.'
} else if (no_pr_snaps) {
return 'Ensure that dependencies are being submitted on PR branches. Re-running this action after a short time may resolve the issue.'
} else if (retries_disabled) {
return 'Consider enabling retry-on-snapshot-warnings.'
}
return 'Re-running this action after a short time may resolve the issue.'
}

export function addSnapshotWarnings(
config: ConfigurationOptions,
warnings: string
): void {
core.summary.addHeading('Snapshot Warnings', 2)
core.summary.addQuote(`${icons.warning}: ${warnings}`)
core.summary.addRaw(
'Re-running this action after a short time may resolve the issue. See <a href="https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#best-practices-for-using-the-dependency-review-api-and-the-dependency-submission-api-together">the documentation</a> for more information and troubleshooting advice.'
)
const recommendation = snapshotWarningRecommendation(config, warnings)
const docsLink =
'See <a href="https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#best-practices-for-using-the-dependency-review-api-and-the-dependency-submission-api-together">the documentation</a> for more information and troubleshooting advice.'
core.summary.addRaw(`${recommendation} ${docsLink}}`)
}

function countLicenseIssues(
Expand Down

0 comments on commit bed9726

Please sign in to comment.