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 — Introduce `CODEQL_ACTION_SKIP_SARIF_UPLOAD` by redsun82 · Pull Request #3180 · github/codeql-action

Conversation

@redsun82

@redsun82 redsun82 commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

This triggers a subset of the behavior of CODEQL_ACTION_TEST_MODE, specifically just skipping the SARIF upload step. This is required for our internal testing where we want the SARIF file (via CODEQL_ACTION_DUMP_SARIF_DIR) but don't want to actually upload it, but we don't want the rest of the behaviour of CODEQL_ACTION_TEST_MODE that is specific for codeql-action own CI checks.

This is a fresh take at #3089, with less impact on the codebase.

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.
  • High risk: Changes are not fully under feature flags, have limited visibility and/or cannot be tested outside of production.

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
@redsun82
Introduce CODEQL_ACTION_SKIP_SARIF_UPLOAD
e0b9da7
This triggers a subset of the behavior of `CODEQL_ACTION_TEST_MODE`,
specifically just skipping the SARIF upload step. This is required for
our internal testing where we want the SARIF file (via
`CODEQL_ACTION_DUMP_SARIF_DIR`) but don't want to actually upload it,
but we don't want the rest of the behaviour of `CODEQL_ACTION_TEST_MODE`
that is specific for `codeql-action` own CI checks.
@redsun82
redsun82 requested a review from a team as a code owner October 6, 2025 13:10
@redsun82
redsun82 requested review from Copilot and mbg October 6, 2025 13:10
Copilot AI reviewed Oct 6, 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 introduces a new environment variable CODEQL_ACTION_SKIP_SARIF_UPLOAD that provides more granular control over SARIF upload behavior. It allows skipping SARIF uploads without enabling full test mode, which is useful for internal testing scenarios where SARIF files are needed locally but should not be uploaded to GitHub.

Key changes:

  • Adds new environment variable CODEQL_ACTION_SKIP_SARIF_UPLOAD for selective SARIF upload control
  • Introduces shouldSkipSarifUpload() function that combines test mode and the new skip flag
  • Updates upload logic and messaging to use the new function instead of direct test mode checks

Reviewed Changes

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

Show a summary per file
File Description
src/environment.ts Adds the new SKIP_SARIF_UPLOAD environment variable enum
src/util.ts Introduces shouldSkipSarifUpload() function and updates test mode documentation
src/upload-lib.ts Updates upload logic to use new function and improves messaging
src/upload-sarif-action.ts Updates wait-for-processing logic to use new function
src/init-action-post-helper.ts Updates failed SARIF upload logic to use new function
lib/*.js Generated JavaScript code corresponding to TypeScript changes

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/util.ts Resolved

Uh oh!

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

redsun82 and others added 2 commits October 6, 2025 15:22
@redsun82
Update src/util.ts
882667e
Co-authored-by: Copilot <[email protected]>
@redsun82
Clarify comment about SKIP_SARIF_UPLOAD setting
11e4034
esbena
esbena reviewed Oct 6, 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, but Michael should have the say.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/upload-lib.ts Outdated

// If in test mode we don't want to upload the results
if (util.isInTestMode()) {
// If in test mode we don't want to upload the results,

@esbena esbena Oct 6, 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.

this comment is a bit stale now, ditto at the other isInTestMode/shouldSkipSarifUpload switch.

Sorry, something went wrong.

Uh oh!

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

redsun82 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
mbg
mbg reviewed Oct 6, 2025
View reviewed changes

@mbg mbg left a comment

Copy link
Copy Markdown
Member

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.

Thanks, this is generally much neater! I've added a few minor comments.

It is probably worth adding a test case for this.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/environment.ts Outdated

/**
* Whether to skip uploading SARIF results to GitHub. Intended for testing purposes.
* This setting is implied but is more specific than `CODEQL_ACTION_TEST_MODE`.

@mbg mbg Oct 6, 2025

Copy link
Copy Markdown
Member

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.

Minor: the wording here isn't great.

Suggested change
* This setting is implied but is more specific than `CODEQL_ACTION_TEST_MODE`.
* This setting is more specific than `CODEQL_ACTION_TEST_MODE`, which also implies this option.

Sorry, something went wrong.

Uh oh!

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

redsun82 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread src/upload-lib.ts Outdated
logger.info(
`In test mode. Results are not uploaded. Saving to ${payloadSaveFile}`,
);
logger.info(`SARIF upload disabled. Saving to ${payloadSaveFile}`);

@mbg mbg Oct 6, 2025

Copy link
Copy Markdown
Member

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.

Minor: This no longer explains why the SARIF upload is disabled. A simple fix might be wording it like this:

Suggested change
logger.info(`SARIF upload disabled. Saving to ${payloadSaveFile}`);
logger.info(`SARIF upload disabled with an environment variable. Saving to ${payloadSaveFile}`);

A better fix would be to include the responsible environment variable, perhaps with:

Suggested change
logger.info(`SARIF upload disabled. Saving to ${payloadSaveFile}`);
logger.info(`SARIF upload disabled by `${ isInTestMode() ? EnvVar.TEST_MODE : EnvVar.SKIP_SARIF_UPLOAD }`. Saving to ${payloadSaveFile}`);

Sorry, something went wrong.

Uh oh!

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

redsun82 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread src/util.ts Resolved

Uh oh!

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

@redsun82
Specify reason for skipping SARIF upload in logs
680b070
@redsun82

redsun82 commented Oct 6, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

It is probably worth adding a test case for this

@mbg: how would you go on about this?

  • the PR checks set CODEQL_ACTION_TEST_MODE, which "hides" this new behaviour. Maybe a PR check could unset that and set CODEQL_ACTION_SKIP_SARIF_UPLOAD instead? Wouldn't there be some other unwanted effects in the PR checks though?
  • on the unit test side, there's currently no unit tests for uploadSpecifiedFiles, and CODEQL_ACTION_TEST_MODE is not covered at all in there. Adding tests for uploadSpecifiedFiles would probably be nice, but maybe a tad too much for the scope of this PR?
All reactions

Sorry, something went wrong.

Uh oh!

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

mbg
mbg reviewed Oct 6, 2025
View reviewed changes
Comment thread src/util.ts Outdated
Comment on lines +776 to +784
export function getSarifUploadSkipReason(): string | null {
if (isInTestMode()) {
return `SARIF upload is disabled via ${EnvVar.TEST_MODE}`;
}
if (process.env[EnvVar.SKIP_SARIF_UPLOAD] === "true") {
return `SARIF upload is disabled via ${EnvVar.SKIP_SARIF_UPLOAD}`;
}
return null;
}

@mbg mbg Oct 6, 2025

Copy link
Copy Markdown
Member

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.

I had considered something like this when I wrote my comment, but wasn't too keen on it. I also don't love using the human-readable reason phrase to mean true for enablement purposes. The previous version with the boolean function was preferable.

Also, in general, we don't use null in the codeql-action codebase (unless it comes to us from outside the codebase) and would go for undefined here.

Sorry, something went wrong.

Uh oh!

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

redsun82 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@redsun82 redsun82 Oct 6, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor 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.

I was trying to avoid something like

    logger.info(`SARIF upload disabled by `${ isInTestMode() ? EnvVar.TEST_MODE : EnvVar.SKIP_SARIF_UPLOAD }`. Saving to ${payloadSaveFile}`);

as I didn't want to expose that util implementation detail. So I think I'll just go with your first proposal for a generic with an environment variable. The users of those variables (us) probably are savvy enough for that to be enough for them.

Sorry, something went wrong.

Uh oh!

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

mbg reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@mbg

mbg commented Oct 6, 2025

Copy link
Copy Markdown
Member

how would you go on about this?
on the unit test side, there's currently no unit tests [..]

Hmm yes. Unit tests for uploadPayload would be best. I don't think it would be too hard to set this up with mocks for the IO operations (fs.writeFileSync and client.request) and checking which ones were called for given permutations of the environment variables. That said, if there aren't any unit tests here already, then don't feel obligated to set this up as part of this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@redsun82

redsun82 commented Oct 6, 2025

Copy link
Copy Markdown
Contributor Author

how would you go on about this?
on the unit test side, there's currently no unit tests [..]

Hmm yes. Unit tests for uploadPayload would be best. I don't think it would be too hard to set this up with mocks for the IO operations (fs.writeFileSync and client.request) and checking which ones were called for given permutations of the environment variables. That said, if there aren't any unit tests here already, then don't feel obligated to set this up as part of this PR.

Let's make that into a follow-up PR. I'll try to see what copilot can do there.

All reactions

Sorry, something went wrong.

Uh oh!

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

redsun82 added 4 commits October 6, 2025 16:59
@redsun82
Revert "Specify reason for skipping SARIF upload in logs"
25c8db9
This reverts commit 680b070.
@redsun82
Tweak SARIF skipping logs
00a6e13
@redsun82
Merge branch 'main' into redsun82/skip-sarif-upload
5dfb610
@redsun82
Remove unneeded comment
86b2ad6
mbg
mbg reviewed Oct 7, 2025
View reviewed changes

@mbg mbg left a comment

Copy link
Copy Markdown
Member

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.

Looks like you accidentally reverted one of the changes we wanted to keep. Also two other minor suggestions for wording improvements.

Otherwise this LGTM and I am happy to approve.

Sorry, something went wrong.

Uh oh!

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

redsun82 reacted with laugh emoji
All reactions
  • 😄 1 reaction
Comment thread src/environment.ts Outdated
/**
* Whether to skip uploading SARIF results to GitHub. Intended for testing purposes.
* This setting is implied by `CODEQL_ACTION_TEST_MODE`, but is more specific.
* This setting is implied by but is more specific than `CODEQL_ACTION_TEST_MODE`.

@mbg mbg Oct 7, 2025

Copy link
Copy Markdown
Member

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.

Did you intend to revert this?

Sorry, something went wrong.

Uh oh!

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

All reactions

@redsun82 redsun82 Oct 7, 2025

Copy link
Copy Markdown
Contributor 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.

nope 😅

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/upload-lib.ts Outdated
);
logger.info(
`In test mode. Results are not uploaded. Saving to ${payloadSaveFile}`,
`SARIF upload disabled via environment variable. Saving to ${payloadSaveFile}`,

@mbg mbg Oct 7, 2025

Copy link
Copy Markdown
Member

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.

Minor:

Suggested change
`SARIF upload disabled via environment variable. Saving to ${payloadSaveFile}`,
`SARIF upload disabled by an environment variable. Saving to ${payloadSaveFile}`,

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/upload-sarif-action.ts Outdated
core.debug("In test mode. Waiting for processing is disabled.");
if (shouldSkipSarifUpload()) {
core.debug(
"SARIF upload disabled via environment variable. Waiting for processing is disabled.",

@mbg mbg Oct 7, 2025

Copy link
Copy Markdown
Member

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.

Suggested change
"SARIF upload disabled via environment variable. Waiting for processing is disabled.",
"SARIF upload disabled by an environment variable. Waiting for processing is disabled.",

Sorry, something went wrong.

Uh oh!

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

All reactions
redsun82 added 2 commits October 7, 2025 17:17
@redsun82
Address review
1b09eb4
@redsun82
Merge branch 'main' into redsun82/skip-sarif-upload
df65651
@redsun82
redsun82 enabled auto-merge October 7, 2025 15:18
@redsun82

redsun82 commented Oct 7, 2025

Copy link
Copy Markdown
Contributor Author

@mbg thanks for the review! I think I addressed everything. I also opened a follow-up with unit tests: #3185 (with a little help from copilot)

All reactions

Sorry, something went wrong.

Uh oh!

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

redsun82 added 2 commits October 8, 2025 09:34
@redsun82
Tweak comment
d05f225
@redsun82
Merge branch 'main' into redsun82/skip-sarif-upload
1707898
mbg
mbg approved these changes Oct 8, 2025
View reviewed changes

@mbg mbg left a comment

Copy link
Copy Markdown
Member

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.

Thanks for fixing those minor issues!

Sorry, something went wrong.

Uh oh!

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

All reactions
@redsun82
redsun82 merged commit 8301b8b into main Oct 8, 2025
@redsun82
redsun82 deleted the redsun82/skip-sarif-upload branch October 8, 2025 10:09
@mbg mbg mentioned this pull request Oct 8, 2025
Add unit tests for uploadPayload #3185
Merged
@github-actions github-actions Bot mentioned this pull request Oct 10, 2025
Merge main into releases/v4 #3198
Merged
6 of 8 tasks
@github-actions github-actions Bot mentioned this pull request Oct 10, 2025
Merge releases/v4 into releases/v3 #3201
Merged
7 of 8 tasks
@redsun82 redsun82 mentioned this pull request Oct 14, 2025
Implement dumping of processed sarif file #3089
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

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

Uh oh!

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

Assignees

No one assigned

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.

4 participants

@redsun82 @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.