Skip to content

Commit fb86db2

Browse files
committed
fix: resolve race conditions in async core.group calls
1 parent 0a198ab commit fb86db2

File tree

3 files changed

+42
-36
lines changed

3 files changed

+42
-36
lines changed

dist/index.js

Lines changed: 20 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.

src/main.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async function run(): Promise<void> {
146146
if (config.vulnerability_check) {
147147
core.setOutput('vulnerable-changes', JSON.stringify(vulnerableChanges))
148148
summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity)
149-
issueFound ||= printVulnerabilitiesBlock(
149+
issueFound ||= await printVulnerabilitiesBlock(
150150
vulnerableChanges,
151151
minSeverity,
152152
warnOnly
@@ -158,12 +158,12 @@ async function run(): Promise<void> {
158158
JSON.stringify(invalidLicenseChanges)
159159
)
160160
summary.addLicensesToSummary(invalidLicenseChanges, config)
161-
issueFound ||= printLicensesBlock(invalidLicenseChanges, warnOnly)
161+
issueFound ||= await printLicensesBlock(invalidLicenseChanges, warnOnly)
162162
}
163163
if (config.deny_packages || config.deny_groups) {
164164
core.setOutput('denied-changes', JSON.stringify(deniedChanges))
165165
summary.addDeniedToSummary(deniedChanges)
166-
issueFound ||= printDeniedDependencies(deniedChanges, config)
166+
issueFound ||= await printDeniedDependencies(deniedChanges, config)
167167
}
168168
if (config.show_openssf_scorecard) {
169169
summary.addScorecardToSummary(scorecard, config)
@@ -214,9 +214,10 @@ function printVulnerabilitiesBlock(
214214
addedChanges: Changes,
215215
minSeverity: Severity,
216216
warnOnly: boolean
217-
): boolean {
218-
let vulFound = false
219-
core.group('Vulnerabilities', async () => {
217+
): Promise<boolean> {
218+
return core.group('Vulnerabilities', async () => {
219+
let vulFound = false
220+
220221
for (const change of addedChanges) {
221222
vulFound ||= printChangeVulnerabilities(change)
222223
}
@@ -233,8 +234,9 @@ function printVulnerabilitiesBlock(
233234
`Dependency review did not detect any vulnerable packages with severity level "${minSeverity}" or higher.`
234235
)
235236
}
237+
238+
return vulFound
236239
})
237-
return vulFound
238240
}
239241

240242
function printChangeVulnerabilities(change: Change): boolean {
@@ -254,9 +256,10 @@ function printChangeVulnerabilities(change: Change): boolean {
254256
function printLicensesBlock(
255257
invalidLicenseChanges: Record<string, Changes>,
256258
warnOnly: boolean
257-
): boolean {
258-
let issueFound = false
259-
core.group('Licenses', async () => {
259+
): Promise<boolean> {
260+
return core.group('Licenses', async () => {
261+
let issueFound = false
262+
260263
if (invalidLicenseChanges.forbidden.length > 0) {
261264
issueFound = true
262265
core.info('\nThe following dependencies have incompatible licenses:')
@@ -279,8 +282,9 @@ function printLicensesBlock(
279282
)
280283
}
281284
printNullLicenses(invalidLicenseChanges.unlicensed)
285+
286+
return issueFound
282287
})
283-
return issueFound
284288
}
285289

286290
function printLicensesError(changes: Changes): void {
@@ -382,9 +386,10 @@ function printScannedDependencies(changes: Changes): void {
382386
function printDeniedDependencies(
383387
changes: Changes,
384388
config: ConfigurationOptions
385-
): boolean {
386-
let issueFound = false
387-
core.group('Denied', async () => {
389+
): Promise<boolean> {
390+
return core.group('Denied', async () => {
391+
let issueFound = false
392+
388393
for (const denied of config.deny_packages) {
389394
core.info(`Config: ${denied}`)
390395
}
@@ -400,8 +405,9 @@ function printDeniedDependencies(
400405
} else {
401406
core.info('Dependency review did not detect any denied packages')
402407
}
408+
409+
return issueFound
403410
})
404-
return issueFound
405411
}
406412

407413
function getScorecardChanges(changes: Changes): Changes {

0 commit comments

Comments
 (0)