Skip failed SARIF upload if Code Quality is the only analysis kind#3209
Merged
Skip failed SARIF upload if Code Quality is the only analysis kind#3209
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a check to skip SARIF upload for failed runs when code-quality is the only enabled analysis kind, since code-quality doesn't involve Code Scanning.
- Added early return in
tryUploadSarifIfRunFailedto skip upload when only code-quality is enabled - Updated test helper function to support configurable analysis kinds
- Added test case to verify the skip behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/init-action-post-helper.ts | Added check to skip failed SARIF upload when code-quality is the only analysis kind |
| src/init-action-post-helper.test.ts | Updated test infrastructure and added test case for the new skip behavior |
| lib/init-action-post.js | Generated JavaScript code reflecting the TypeScript changes |
henrymercer
previously approved these changes
Oct 16, 2025
henrymercer
reviewed
Oct 16, 2025
src/init-action-post-helper.ts
Outdated
Comment on lines
143
to
148
| // If the only enabled analysis kind is `code-quality`, then we shouldn't | ||
| // upload the failed SARIF to Code Scanning. | ||
| if (!isCodeScanningEnabled(config)) { | ||
| return { | ||
| upload_failed_run_skipped_because: | ||
| "Code Quality is the only enabled analysis kind.", |
Contributor
There was a problem hiding this comment.
Suggested change
| // If the only enabled analysis kind is `code-quality`, then we shouldn't | |
| // upload the failed SARIF to Code Scanning. | |
| if (!isCodeScanningEnabled(config)) { | |
| return { | |
| upload_failed_run_skipped_because: | |
| "Code Quality is the only enabled analysis kind.", | |
| // Code scanning is the only analysis kind that makes use of failed SARIF uploads. | |
| if (!isCodeScanningEnabled(config)) { | |
| return { | |
| upload_failed_run_skipped_because: | |
| "The code scanning analysis kind is not enabled.", |
src/init-action-post-helper.test.ts
Outdated
| }); | ||
| t.is( | ||
| result.upload_failed_run_skipped_because, | ||
| "Code Quality is the only enabled analysis kind.", |
Contributor
There was a problem hiding this comment.
Suggested change
| "Code Quality is the only enabled analysis kind.", | |
| "The code scanning analysis kind is not enabled.", |
d1ac956 to
db6938a
Compare
henrymercer
approved these changes
Oct 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the
init-postaction, we upload a SARIF file to Code Scanning if theanalyzestep did not complete successfully. This doesn't make sense ifanalysis-kinds: code-quality, since that does not involve Code Scanning.This PR adds a check to see if
code-qualityis the only enabled analysis kind and skips the upload if so.Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
analysis-kinds: code-quality).How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Merge / deployment checklist