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 — Persist CodeQL version output to file rather than environment by mario-campos · Pull Request #4081 · github/codeql-action

Conversation

@mario-campos

@mario-campos mario-campos commented Aug 7, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Currently, the output of codeql version is cached and persisted between steps as an environment variable. This is fine, for now, but, as we begin to cache more of the CLI, we should persist that output to a file instead because:

  1. There is a limit to the size of a process' environment. On GitHub Actions, the runners already have a populated environment. And, the output of these CLI commands may be verbose.
  2. There is data to suggest that a larger environment has performance implications (more environment variables -> more memory for the kernel to copy during execve(2)).

To that end, and as a precaution, this PR replaces $CODEQL_ACTION_CLI_VERSION_INFO with $CODEQL_ACTION_TEMP/version.json, a file-backed cache for codeql version.

Changes

  • Moved the CodeQL CLI version caching logic from util.ts (which used environment variables) into a new module src/cli/output-cache.ts, which now uses a temporary on-disk file (codeql-action-command-cache.json) for cross-step persistence. This includes new functions for caching, retrieving, and resetting the cached version, as well as improved validation of persisted data.
  • Moved the VersionInfo type definition from codeql.ts to a new shared file src/cli/types.ts, and updated all references to use the new location. This centralizes type definitions to avoid cyclic dependencies.
  • Removed the now-obsolete CODEQL_VERSION_INFO environment variable from EnvVar in environment.ts.

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.

Which use cases does this change impact?

Workflow types:

  • Advanced setup - Impacts users who have custom CodeQL workflows.
  • Managed - Impacts users with dynamic workflows (Default Setup, Code Quality, ...).

Products:

  • Code Scanning - The changes impact analyses when analysis-kinds: code-scanning.
  • Code Quality - The changes impact analyses when analysis-kinds: code-quality.

Environments:

  • Dotcom - Impacts CodeQL workflows on github.com and/or GitHub Enterprise Cloud with Data Residency.
  • GHES - Impacts CodeQL workflows on GitHub Enterprise Server.

How did/will you validate this change?

  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).
  • End-to-end tests - I am depending on PR checks (i.e. tests in pr-checks).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Rollback - Change can only be disabled by rolling back the release or releasing a new version with a fix.

How will you know if something goes wrong after this change is released?

  • Telemetry - I rely on existing telemetry or have made changes to the telemetry.
    • Alerts - New or existing monitors will trip if something goes wrong with this change.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

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
@mario-campos
Persist CodeQL version output to file rather than environment
5f8c44b
Copilot AI balanced review requested due to automatic review settings August 7, 2026 20:18
@mario-campos
mario-campos requested a review from a team as a code owner August 7, 2026 20:18
@github-actions github-actions Bot added the size/S Should be easy to review label Aug 7, 2026
Copilot started reviewing on behalf of mario-campos August 7, 2026 20:18
View session
@mario-campos
mario-campos requested a review from mbg August 7, 2026 20:18
Copilot AI reviewed Aug 7, 2026
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

Moves persisted CodeQL CLI version metadata from an environment variable to a temporary JSON file.

Changes:

  • Writes and reads version metadata from $CODEQL_ACTION_TEMP/version.json.
  • Removes the obsolete environment variable.
  • Updates persistence tests.
Show a summary per file
File Description
src/util.ts Implements file-based version caching.
src/util.test.ts Updates cache-reading tests.
src/environment.ts Removes the old cache environment variable.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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.

@mario-campos
Handle file-read errors as cache misses
9183a7b
This is particularly important for the first time that `getCachedCodeQlVersion` is invoked, as this cache file will not yet exist.
@mario-campos
mario-campos force-pushed the mario-campos/version-cache-to-disk branch from a1f3399 to 9183a7b Compare August 10, 2026 15:45
mbg
mbg reviewed Aug 11, 2026
View reviewed changes

@mbg mbg left a comment •
edited
Loading

Uh oh!

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

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 picking this back up! I have added a few inline (mostly style) comments.

Some high-level points:

  • Also added as an in-line comment, but do you plan to have a separate file for each command? If so, why? On the same topic, if not, then should the file be more structured to allow for relevant metadata and other command output down the line?
  • Have you had any more thoughts about either checking that the cached file is intended for the current analysis (e.g. by checking the generated jobUuid) or deleting cache files on "startup"?
  • Add a unit test for the case where the file cannot be read (e.g. because it doesn't exist).
  • The linter CI is failing. Remember to run npm lint locally before committing / pushing changes.

Much more minor, but I spotted this in the PR description:

This is fine, for now, but, as we begin to cache more of the CLI, we should persist that output to a file instead.

The reasoning here ("as we begin to cache more of the CLI") doesn't really justify the conclusion ("we should persist that output to a file instead). Could you edit that to actually highlight why files are preferable to environment variables?

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.

Comment thread src/util.ts Resolved

Uh oh!

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

Comment thread src/util.ts Resolved

Uh oh!

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

Comment thread src/util.ts Resolved

Uh oh!

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

Comment thread src/util.ts Resolved

Uh oh!

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

Comment thread src/util.ts Resolved

Uh oh!

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

Comment thread src/util.test.ts Resolved

Uh oh!

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

Comment thread src/util.test.ts Resolved

Uh oh!

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

mario-campos and others added 5 commits August 11, 2026 11:06
@mario-campos @mbg
Simplify JSDoc of getCachedCodeQlVersion
208a88a
Co-authored-by: Michael B. Gale <[email protected]>
@mario-campos
Fix JSDoc of env param
bfcd769
@mario-campos
Refactor unit test to extract testing values
0e85c0e
@mario-campos
Add test of getCachedCodeQlVersion with no file
bb19330
@mario-campos
Introduce basic cli/output-cache.ts module
4dc327a
@github-actions github-actions Bot added size/L May be hard to review and removed size/S Should be easy to review labels Aug 11, 2026
mario-campos added 4 commits August 11, 2026 15:55
@mario-campos
Move cache-related util functions into dedicated module
1332611
@mario-campos
Move VersionInfo to dedicated module
246018e
@mario-campos
Move VersionInfo-related types to cli/output-cache.ts
0a99875
This brings them out of the crowded all-purpose `util.ts` and into `cli/output-cache.ts` where they are exclusively used.
@mario-campos
Update JSDoc of getCachedCodeQlVersion
11569df
@mario-campos
mario-campos force-pushed the mario-campos/version-cache-to-disk branch from 139c544 to 11569df Compare August 11, 2026 20:55
mario-campos added 2 commits August 11, 2026 18:09
@mario-campos
Generalize file cache data structure
b222c3a
@mario-campos
Rename type to better match generic intention
40f80a8
@mario-campos
mario-campos force-pushed the mario-campos/version-cache-to-disk branch from b11737e to 40f80a8 Compare August 11, 2026 23:09
mbg
mbg reviewed Aug 12, 2026
View reviewed changes
Comment thread src/util.test.ts Resolved

Uh oh!

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

Comment thread src/cli/output-cache.ts Resolved

Uh oh!

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

Comment thread src/cli/output-cache.ts Resolved

Uh oh!

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

Comment thread src/cli/output-cache.ts Resolved

Uh oh!

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

Comment thread src/cli/output-cache.ts Resolved

Uh oh!

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

Comment thread src/cli/output-cache.ts Resolved

Uh oh!

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

mario-campos added 4 commits August 12, 2026 11:24
@mario-campos
Pass environment explicitly to CLI caching functions
33d7086
@mario-campos
Export CLI cache types
a9baab8
@mario-campos
Rename CommandCacheRecord -> OutputCache
337136a
@mario-campos
Expand test to ensure it does not throw an exception
bf96b0d
mario-campos added 2 commits August 12, 2026 12:01
@mario-campos
Change OutputCache to use object for entries
6c0d901
This will ensure it works nicely with `JSON.stringify`. And, then we can validate the type before marshaling.
@mario-campos
Bolster output-cache unit tests with more test cases
6dc6332
mbg
mbg reviewed Aug 13, 2026
View reviewed changes
Comment thread src/cli/output-cache.ts Resolved

Uh oh!

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

mario-campos added 3 commits August 13, 2026 08:13
@mario-campos
Re-order env to be first argument for consistency
2d49edb
@mario-campos
Change cache key to string type to include CLI args
43250d6
@mario-campos
Merge branch 'main' into mario-campos/version-cache-to-disk
aa0eadc
# Conflicts:
#	lib/entry-points.js
mbg
mbg previously approved these changes Aug 13, 2026
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.

LGTM, aside from addressing the minor point about the logging the error and resolving the merge conflict.

Sorry, something went wrong.

Uh oh!

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

All reactions
@mario-campos
Log unexpected conditions during caching CLI output
c56f48e
@mario-campos
mario-campos dismissed mbg’s stale review via c56f48e August 13, 2026 14:14
mbg
mbg approved these changes Aug 13, 2026
View reviewed changes
@mario-campos
mario-campos enabled auto-merge August 13, 2026 14:27
@mario-campos
mario-campos added this pull request to the merge queue Aug 13, 2026
Merged via the queue into main with commit c2fd8f5 Aug 13, 2026
222 checks passed

Uh oh!

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

@mario-campos
mario-campos deleted the mario-campos/version-cache-to-disk branch August 13, 2026 14:42
This was referenced Aug 14, 2026
Delete CLI output-cache file during init #4097
Closed
Cache CLI extractor paths across Actions steps #3950
Closed
This was referenced Aug 21, 2026
Merge main into releases/v4 #4102
Merged
Merge releases/v4 into releases/v3 #4104
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
@mbg mbg mbg approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

size/L May be hard to review

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

@mario-campos @mbg
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 01402503 — 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.