-
Notifications
You must be signed in to change notification settings - Fork 413
Skip failed SARIF upload if Code Quality is the only analysis kind #3209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
src/init-action-post-helper.ts
Outdated
| // 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.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "Code Quality is the only enabled analysis kind.", | |
| "The code scanning analysis kind is not enabled.", |
d1ac956 to
db6938a
Compare
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