GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add tests for `upload-sarif` by mbg · Pull Request #3166 · github/codeql-action

Conversation

@mbg

@mbg mbg commented Sep 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This PR takes parts of #3157:

  • Moves logic from upload-sarif-action.ts to upload-sarif.ts
  • Adds unit test coverage for the functions in upload-sarif.ts
  • Fixes sarif-ids output format to match documentation
  • Throws a ConfigurationError if no SARIF files were uploaded, matching the behaviour of upload-sarif prior to Fix upload-sarif Action failing if there are no Code Scanning SARIF files #3123

This doesn't make any further changes to the actual upload logic beyond the hotfix we added in #3160. I am planning a follow-up PR to improve on that after having come up with an idea for a good approach over the weekend, but want to the tests, sarif-ids fix, and error for the case where no files were uploaded merged first.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mbg added 6 commits September 29, 2025 08:44
@mbg
Move findAndUpload to a new module
5fc9e66
@mbg
Move core upload-sarif logic to upload-sarif module
9f452fa
Note that this also fixes the format of the `sarif-ids` outputs to match what is documented
@mbg
Add some tests for findAndUpload and uploadSarif
6e0b087
@mbg
Test that uploaded files match expectations for each analysis kind
5b3f0de
@mbg
Tests: ensure uploadSpecifiedFiles wasn't called if we don't expect…
2adc894
… it to be
@mbg
Fail if no SARIF files were uploaded
5fd2cfe
@mbg
mbg requested a review from a team as a code owner September 29, 2025 08:07
Copilot AI review requested due to automatic review settings September 29, 2025 08:07
Copilot AI reviewed Sep 29, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

This PR refactors the upload-sarif functionality by extracting upload logic from the action file into a separate module and adding comprehensive unit tests. The changes also fix the output format for sarif-ids and add error handling for cases where no SARIF files are found.

Key changes:

  • Moves core upload logic from upload-sarif-action.ts to upload-sarif.ts for better separation of concerns
  • Adds extensive unit tests covering various SARIF file scenarios and upload combinations
  • Changes sarif-ids output format from array to object structure for easier consumption

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/upload-sarif.ts New module containing extracted upload logic with findAndUpload and uploadSarif functions
src/upload-sarif.test.ts Comprehensive unit tests for the new upload-sarif module functions
src/upload-sarif-action.ts Refactored to use the new upload-sarif module and simplified upload flow
pr-checks/checks/upload-quality-sarif.yml Updated test to use new sarif-ids object format
lib/upload-sarif-action.js Generated JavaScript reflecting the TypeScript changes
.github/workflows/__upload-quality-sarif.yml Updated workflow to use new sarif-ids object format

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-sarif.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mbg mbg self-assigned this Sep 29, 2025
@mbg
mbg requested review from esbena and henrymercer September 29, 2025 08:09
@mbg
Update src/upload-sarif.test.ts
73fbfb0
Co-authored-by: Copilot <[email protected]>
esbena
esbena previously approved these changes Sep 29, 2025
View reviewed changes

@esbena esbena left a comment

Copy link
Copy Markdown
Contributor

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.

LGTM.

It's not blocking, but I'm getting a bit concerned about the complexity of the tests, especially
2adc894. It's the classic tradeoff between what tests current behaviour/API and what is maintainable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-sarif.test.ts
Comment on lines +147 to +149
analysisKind === AnalysisKind.CodeScanning
? CodeScanning
: CodeQuality,

@esbena esbena Sep 29, 2025

Copy link
Copy Markdown
Contributor

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.

could this just be analysisKind? Or do we prefer the explicit casing?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Sep 29, 2025

Copy link
Copy Markdown
Member Author

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.

analysisKind: AnalysisKind while CodeScanning: AnalysisConfig and CodeQuality: AnalysisConfig. It maps the kind to the matching configuration. We could have this as a function for reusability instead of this ad-hoc mechanism, but we can't just use analysisKind here since we need an AnalysisConfig object for uploadSpecifiedFiles.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@esbena esbena Sep 29, 2025

Copy link
Copy Markdown
Contributor

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.

right. My eyes missed the AnalysisKind. prefix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mbg

mbg commented Sep 29, 2025

Copy link
Copy Markdown
Member Author

I'm getting a bit concerned about the complexity of the tests

I could modify UploadResult to include the array of files, but then we'd probably have to mock a bunch of other functions that uploadSpecifiedFiles calls or have more things for the tests to set up.

I'm inclined to accept the tests as they are for now, since I am planning to make further changes anyway and they might affect these tests and allow us to simplify this again later.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mbg mbg mentioned this pull request Sep 29, 2025
Find, then filter, SARIF files for upload-sarif Action #3167
Merged
@mbg
Fix condition in test workflow
9715962
@mbg
mbg dismissed esbena’s stale review via 9715962 September 29, 2025 13:34
esbena
esbena approved these changes Sep 29, 2025
View reviewed changes
@mbg
mbg merged commit 36adfa7 into main Sep 29, 2025
@mbg
mbg deleted the mbg/upload-sarif/add-tests branch September 29, 2025 14:06
@mbg mbg mentioned this pull request Sep 29, 2025
Fix upload-sarif not uploading non-.sarif files #3157
Closed
@github-actions github-actions Bot mentioned this pull request Oct 2, 2025
Merge main into releases/v3 #3172
Merged
8 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Apr 3, 2026
chore: integrate Detekt for static code analysis and add configuration files twangodev/jetplay#12
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@esbena esbena esbena approved these changes
@henrymercer henrymercer Awaiting requested review from henrymercer

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@mbg mbg

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mbg @esbena
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.