Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e233806
Add `diagnostics export` command
henrymercer Nov 9, 2022
44ae944
Add a workflow to test reporting a failed run
henrymercer Nov 22, 2022
9de6c31
Log matrix input
henrymercer Nov 22, 2022
4d4e250
Use a matrix in testing workflow
henrymercer Nov 22, 2022
3cf2a1b
Add function for retrieving the "upload" input
henrymercer Nov 23, 2022
3afc2b1
Add feature flag for uploading failed SARIF
henrymercer Nov 23, 2022
5296a76
Upload failed SARIF files to Code Scanning
henrymercer Nov 23, 2022
8337c2b
Only upload failed SARIF if the run failed
henrymercer Nov 25, 2022
122b180
Add an integration test for uploading SARIF when the run fails
henrymercer Nov 25, 2022
37b4358
Handle API versions that reject unsuccessful executions
henrymercer Nov 25, 2022
d0517be
Ensure we finish the log group when waiting for processing
henrymercer Nov 25, 2022
24fd4c0
Generate the "Submit SARIF after failure" workflow
henrymercer Nov 25, 2022
7fc3c60
Add changelog note
henrymercer Nov 25, 2022
e628ee0
Push unsuccessful execution API error detection into upload library
henrymercer Nov 29, 2022
00a3c45
Always wait for processing when uploading a failed SARIF file
henrymercer Nov 29, 2022
e0dec83
Explicitly mention surrounding by try/catch in JSDoc
henrymercer Nov 29, 2022
58b2ab0
Add unit test for typical workflow
henrymercer Nov 29, 2022
6c5cad7
Merge branch 'henrymercer/parse-category' into henrymercer/report-fai…
henrymercer Nov 29, 2022
3d90c4f
Improve error message when failed SARIF file doesn't process as expected
henrymercer Nov 30, 2022
77cda4d
Add testing environment to submit SARIF after failure PR check
henrymercer Nov 30, 2022
98b2ddc
Merge branch 'main' into henrymercer/report-failed-runs
henrymercer Dec 1, 2022
e0ff272
Merge branch 'main' into henrymercer/report-failed-runs
henrymercer Dec 2, 2022
375daca
Only print the full error message in debug mode
henrymercer Dec 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Push unsuccessful execution API error detection into upload library
  • Loading branch information
henrymercer committed Nov 29, 2022
commit e628ee0ae18b5296ad4579ca8c0ad0481b30bc59
14 changes: 2 additions & 12 deletions lib/init-action-post-helper.js

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

2 changes: 1 addition & 1 deletion lib/init-action-post-helper.js.map

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

17 changes: 16 additions & 1 deletion lib/upload-lib.js

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

2 changes: 1 addition & 1 deletion lib/upload-lib.js.map

Large diffs are not rendered by default.

23 changes: 7 additions & 16 deletions src/init-action-post-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,13 @@ async function uploadFailedSarif(
category,
logger
);
if (uploadResult !== undefined && waitForProcessing) {
try {
await uploadLib.waitForProcessing(
repositoryNwo,
uploadResult.sarifID,
logger
);
} catch (e) {
if (e instanceof Error && e.message.includes("unsuccessful execution")) {
logger.info(
"Submitting a SARIF file for the failed run isn't yet supported, continuing."
);
} else {
throw e;
}
}
if (waitForProcessing) {
await uploadLib.waitForProcessing(
repositoryNwo,
uploadResult.sarifID,
logger,
{ isUnsuccessfulExecution: true }
);
}
}

Expand Down
27 changes: 26 additions & 1 deletion src/upload-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
export async function waitForProcessing(
repositoryNwo: RepositoryNwo,
sarifID: string,
logger: Logger
logger: Logger,
options: { isUnsuccessfulExecution: boolean } = {
isUnsuccessfulExecution: false,
}
): Promise<void> {
logger.startGroup("Waiting for processing to finish");
try {
Expand Down Expand Up @@ -427,6 +430,28 @@ export async function waitForProcessing(
}
const status = response.data.processing_status;
logger.info(`Analysis upload status is ${status}.`);

if (
options.isUnsuccessfulExecution &&
status === "failed" &&
Array.isArray(response.data.errors) &&
response.data.errors.length === 1 &&
response.data.errors[0].toString().startsWith("unsuccessful execution")
) {
logger.debug(
"Successfully uploaded a SARIF file for the unsuccessful execution. Received expected " +
'"unsuccessful execution" error, and no other errors.'
);
break;
} else if (options.isUnsuccessfulExecution && status !== "pending") {
throw new Error(
`${
"Did not receive expected 'unsuccessful execution' error from the API. " +
"Code scanning status information may be out of date."
}${status === "failed" ? `\n${response.data.errors}` : ""}`
);
}

if (status === "complete") {
break;
} else if (status === "pending") {
Expand Down