Refactor SARIF-related types and functions into a separate module#3528
Open
Refactor SARIF-related types and functions into a separate module#3528
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors SARIF-related types/errors/helpers out of util.ts and upload-lib.ts into a dedicated src/sarif module to reduce coupling (and help avoid circular dependencies) while keeping existing call sites working via re-exports.
Changes:
- Introduces
src/sarif/index.tswith SARIF types and helper functions (e.g., parsing, combining, uniqueness checks) plusInvalidSarifUploadError. - Re-exports SARIF symbols from
src/util.tsand updatessrc/upload-lib.ts/src/upload-sarif-action.tsto reference the new module layout. - Moves the
getToolNamesunit test into a newsrc/sarif/index.test.tstest file.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/util.ts | Re-exports the new sarif module and removes inlined SARIF types/helpers. |
| src/util.test.ts | Removes SARIF-related tests that were moved out of util. |
| src/upload-sarif-action.ts | Updates error-type check to use InvalidSarifUploadError from the new SARIF module (via util re-export). |
| src/upload-lib.ts | Imports SARIF types/helpers from ./sarif instead of defining them inline; uses shared SARIF parsing helper. |
| src/sarif/index.ts | New module containing SARIF interfaces and helper functions previously located in util.ts/upload-lib.ts. |
| src/sarif/index.test.ts | New tests for SARIF helper(s) (currently getToolNames). |
| lib/upload-sarif-action.js | Generated bundle output update (not reviewed). |
| lib/upload-lib.js | Generated bundle output update (not reviewed). |
| lib/init-action-post.js | Generated bundle output update (not reviewed). |
| lib/analyze-action.js | Generated bundle output update (not reviewed). |
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.
This PR refactors SARIF-related types and functions from
util.tsandupload-lib.tsto a separatesarifmodule. The primary motivation for this is follow-up PRs in which we can then make use of thesarifmodule without introducing circular dependencies and add tests that mock functions from thesarifmodule more easily.Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.upload-sarifaction.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.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?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist