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

Persist CodeQL version output to file rather than environment #4081

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.

Sign up for GitHub

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

Merged
mario-campos merged 23 commits into main from mario-campos/version-cache-to-disk
Aug 13, 2026

Uh oh!

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

Merged

Persist CodeQL version output to file rather than environment #4081

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5f8c44b
Persist CodeQL version output to file rather than environment
mario-campos Aug 7, 2026
9183a7b
Handle file-read errors as cache misses
mario-campos Aug 10, 2026
208a88a
Simplify JSDoc of `getCachedCodeQlVersion`
mario-campos Aug 11, 2026
bfcd769
Fix JSDoc of `env` param
mario-campos Aug 11, 2026
0e85c0e
Refactor unit test to extract testing values
mario-campos Aug 11, 2026
bb19330
Add test of `getCachedCodeQlVersion` with no file
mario-campos Aug 11, 2026
4dc327a
Introduce basic `cli/output-cache.ts` module
mario-campos Aug 11, 2026
1332611
Move cache-related util functions into dedicated module
mario-campos Aug 11, 2026
246018e
Move `VersionInfo` to dedicated module
mario-campos Aug 11, 2026
0a99875
Move `VersionInfo`-related types to `cli/output-cache.ts`
mario-campos Aug 11, 2026
11569df
Update JSDoc of `getCachedCodeQlVersion`
mario-campos Aug 11, 2026
b222c3a
Generalize file cache data structure
mario-campos Aug 11, 2026
40f80a8
Rename type to better match generic intention
mario-campos Aug 11, 2026
33d7086
Pass environment explicitly to CLI caching functions
mario-campos Aug 12, 2026
a9baab8
Export CLI cache types
mario-campos Aug 12, 2026
337136a
Rename `CommandCacheRecord` -> `OutputCache`
mario-campos Aug 12, 2026
bf96b0d
Expand test to ensure it does not throw an exception
mario-campos Aug 12, 2026
6c0d901
Change `OutputCache` to use object for `entries`
mario-campos Aug 12, 2026
6dc6332
Bolster output-cache unit tests with more test cases
mario-campos Aug 12, 2026
2d49edb
Re-order `env` to be first argument for consistency
mario-campos Aug 13, 2026
43250d6
Change cache key to string type to include CLI args
mario-campos Aug 13, 2026
aa0eadc
Merge branch 'main' into mario-campos/version-cache-to-disk
mario-campos Aug 13, 2026
c56f48e
Log unexpected conditions during caching CLI output
mario-campos Aug 13, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view
Prev Previous commit
Next Next commit
Change cache key to string type to include CLI args
  • Loading branch information

Uh oh!

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

@mario-campos
mario-campos committed Aug 13, 2026
commit 43250d671a78c42987337835cd6d6f95ac3d98b1

There are no files selected for viewing

6 changes: 3 additions & 3 deletions 6 lib/entry-points.js
Show comments
View file
Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Oops, something went wrong.

Uh oh!

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

1 change: 1 addition & 0 deletions 1 src/cli/output-cache.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ test.serial(
{ cmd: "/path/to/codeql" },
{ entries: { version: { version: "2.20.0" } } },
{ cmd: "/path/to/codeql", entries: {} },
{ cmd: "/path/to/codeql", entries: null },
{ cmd: "/path/to/codeql", entries: { version: {} } },
{ cmd: "/path/to/codeql", entries: { version: null } },
{ cmd: "/path/to/codeql", entries: { version: "2.20.0" } },
Expand Down
29 changes: 9 additions & 20 deletions 29 src/cli/output-cache.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,14 @@ import type { VersionInfo } from "./types";
/**
* The keys of the command cache. Each key corresponds to a command whose output we cache.
*/
export enum CommandCacheKey {
Version = "version",
}

/**
* The mapping of CLI commands to the types of the output of each command that we cache.
*/
export type CommandCacheKeyOutputMap = {
[CommandCacheKey.Version]: VersionInfo;
};
export type CommandCacheKey = string;

/**
* The type of the command cache that is persisted to disk.
*/
export interface OutputCache<K extends CommandCacheKey> {
export interface OutputCache {
cmd: string;
entries: {
[P in K]: CommandCacheKeyOutputMap[K];
};
entries: Record<CommandCacheKey, unknown>;
}

/**
Expand Down Expand Up @@ -74,8 +63,8 @@ export function cacheCodeQlVersion(
cachedCodeQlVersion = version;
const outputCache = {
cmd,
entries: { [CommandCacheKey.Version]: version },
} satisfies OutputCache<CommandCacheKey.Version>;
entries: { version },
} satisfies OutputCache;
// Persist the version so that subsequent Actions steps, which run in separate
// processes, can reuse it rather than invoking `codeql version` again. We
// record the CLI path so that a different step using a different CodeQL bundle
Expand Down Expand Up @@ -122,7 +111,7 @@ export function getCachedCodeQlVersion(
}
// Memoize the parsed value so that subsequent calls in this process don't
// re-parse the environment variable.
cachedCodeQlVersion = persisted.entries[CommandCacheKey.Version];
cachedCodeQlVersion = persisted.entries.version as VersionInfo;
return cachedCodeQlVersion;
}

Expand All @@ -148,13 +137,13 @@ function isVersionInfo(x: unknown): x is VersionInfo {
* Determines whether a value is a `OutputCache` object.
* @param x The value to test
*/
function isOutputCache(x: unknown): x is OutputCache<CommandCacheKey.Version> {
const candidate = x as Partial<OutputCache<CommandCacheKey.Version>> | null;
function isOutputCache(x: unknown): x is OutputCache {
const candidate = x as Partial<OutputCache> | null;
return (
typeof candidate === "object" &&
candidate !== null &&
typeof candidate.cmd === "string" &&
candidate.entries !== undefined &&
isVersionInfo(candidate.entries[CommandCacheKey.Version])
isVersionInfo(candidate.entries.version)
);
}
Loading
Oops, something went wrong.

Uh oh!

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

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 01402520 — 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.