From 25694c08ea5f721b3785623909130d99cf84ab57 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2026 11:01:07 +0000 Subject: [PATCH 1/9] Bump @octokit/plugin-rest-endpoint-methods from 17.0.0 to 18.0.0 Bumps [@octokit/plugin-rest-endpoint-methods](https://github.com/octokit/plugin-rest-endpoint-methods.js) from 17.0.0 to 18.0.0. - [Release notes](https://github.com/octokit/plugin-rest-endpoint-methods.js/releases) - [Commits](https://github.com/octokit/plugin-rest-endpoint-methods.js/compare/v17.0.0...v18.0.0) --- updated-dependencies: - dependency-name: "@octokit/plugin-rest-endpoint-methods" dependency-version: 18.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 42 +++++++++++++++++++++--------------------- package.json | 2 +- pr-checks/package.json | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e59f20e9..be2ec415c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "@actions/tool-cache": "^3.0.1", "@octokit/core": "^7.0.7", "@octokit/plugin-paginate-rest": "^15.0.0", - "@octokit/plugin-rest-endpoint-methods": "^17.0.0", + "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "@octokit/plugin-retry": "^8.1.1", "archiver": "^8.0.0", "fast-deep-equal": "^3.1.3", @@ -538,6 +538,21 @@ "@octokit/core": ">=6" } }, + "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", + "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, "node_modules/@actions/github/node_modules/@octokit/types": { "version": "16.0.0", "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", @@ -2210,12 +2225,12 @@ } }, "node_modules/@octokit/plugin-rest-endpoint-methods": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", - "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-18.0.0.tgz", + "integrity": "sha512-1wM02pQTHEarWYij0Bb4gu8X8fBy2FJdI4HMTSFDxtYLbOkJErGVx5ywmM6jeS8tOmC0iCiRLrn6YsSIecUeOQ==", "license": "MIT", "dependencies": { - "@octokit/types": "^16.0.0" + "@octokit/types": "^17.0.0" }, "engines": { "node": ">= 20" @@ -2224,21 +2239,6 @@ "@octokit/core": ">=6" } }, - "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/openapi-types": { - "version": "27.0.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz", - "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", - "license": "MIT" - }, - "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/types": { - "version": "16.0.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", - "integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==", - "license": "MIT", - "dependencies": { - "@octokit/openapi-types": "^27.0.0" - } - }, "node_modules/@octokit/plugin-retry": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-8.1.1.tgz", @@ -9802,7 +9802,7 @@ "@actions/github": "^8.0.1", "@octokit/core": "^7.0.7", "@octokit/plugin-paginate-rest": ">=15.0.0", - "@octokit/plugin-rest-endpoint-methods": "^17.0.0", + "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "semver": "^7.8.5", "yaml": "^2.9.0" }, diff --git a/package.json b/package.json index da24ad389..99aa528b9 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@actions/tool-cache": "^3.0.1", "@octokit/core": "^7.0.7", "@octokit/plugin-paginate-rest": "^15.0.0", - "@octokit/plugin-rest-endpoint-methods": "^17.0.0", + "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "@octokit/plugin-retry": "^8.1.1", "archiver": "^8.0.0", "fast-deep-equal": "^3.1.3", diff --git a/pr-checks/package.json b/pr-checks/package.json index a29253523..00f4b813c 100644 --- a/pr-checks/package.json +++ b/pr-checks/package.json @@ -6,7 +6,7 @@ "@actions/github": "^8.0.1", "@octokit/core": "^7.0.7", "@octokit/plugin-paginate-rest": ">=15.0.0", - "@octokit/plugin-rest-endpoint-methods": "^17.0.0", + "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "semver": "^7.8.5", "yaml": "^2.9.0" }, From 1bcdd0c019f29ad522ba46d210df10af670d96ec Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Thu, 27 Aug 2026 18:56:47 +0100 Subject: [PATCH 2/9] Derive the API client type from `@actions/github` `ApiClient` was hand-composed from `Octokit`, `Api` and `PaginateInterface`, imported directly from separately versioned Octokit packages. That asserted a shape matching what `@actions/github` actually returns, which held only while the versions happened to agree. `@octokit/plugin-rest-endpoint-methods` v18 adds twelve Actions cache-limit methods. `@actions/github` still depends on `^17.0.0`, so the client it constructs no longer satisfies the v18-derived alias and the build fails. Deriving the type from the constructor removes the assumption, so the alias tracks whatever `@actions/github` returns. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- lib/entry-points.js | 16 ++++++++-------- pr-checks/api-client.ts | 5 +---- src/api-client.ts | 5 +---- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 95d1cc64a..8cbf9a593 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -23510,18 +23510,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -25815,7 +25815,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -25866,7 +25866,7 @@ function decorate(octokit, scope, methodName, defaults3, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -25944,7 +25944,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -25964,7 +25964,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; diff --git a/pr-checks/api-client.ts b/pr-checks/api-client.ts index 93675dba7..b8f914d81 100644 --- a/pr-checks/api-client.ts +++ b/pr-checks/api-client.ts @@ -1,10 +1,7 @@ import * as githubUtils from "@actions/github/lib/utils"; -import { type Octokit } from "@octokit/core"; -import { type PaginateInterface } from "@octokit/plugin-paginate-rest"; -import { type Api } from "@octokit/plugin-rest-endpoint-methods"; /** The type of the Octokit client. */ -export type ApiClient = Octokit & Api & { paginate: PaginateInterface }; +export type ApiClient = InstanceType; /** Constructs an `ApiClient` using `token` for authentication. */ export function getApiClient(token: string): ApiClient { diff --git a/src/api-client.ts b/src/api-client.ts index ba800a258..bc6018877 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -1,8 +1,5 @@ import * as core from "@actions/core"; import * as githubUtils from "@actions/github/lib/utils"; -import { type Octokit } from "@octokit/core"; -import { type PaginateInterface } from "@octokit/plugin-paginate-rest"; -import { type Api } from "@octokit/plugin-rest-endpoint-methods"; import * as retry from "@octokit/plugin-retry"; import { RequestRequestOptions } from "@octokit/types"; import { @@ -128,7 +125,7 @@ export function makeProxyRequestOptions( } /** The type of GitHub API client we use. */ -export type ApiClient = Octokit & Api & { paginate: PaginateInterface }; +export type ApiClient = InstanceType; /** Options for `createApiClientWithDetails`. */ interface CreateApiClientOptions { From 2f3c1c964a44e3cb80f182ee1d38fc341e7aad63 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Thu, 3 Sep 2026 18:21:14 +0100 Subject: [PATCH 3/9] Add an internal `job-status` input to the `init` Action Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- init/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init/action.yml b/init/action.yml index 1b64e8d2a..7787a0a07 100644 --- a/init/action.yml +++ b/init/action.yml @@ -164,6 +164,13 @@ inputs: [Internal] The ID of the check run, as provided by the Actions runtime environment. Do not set this value manually. default: ${{ job.check_run_id }} required: false + job-status: + description: >- + [Internal] The status of the job, as provided by the Actions runtime environment. This is how the + post step learns whether the job as a whole succeeded, failed, or was cancelled. Do not set this + value manually. + default: ${{ job.status }} + required: false outputs: codeql-path: description: The path of the CodeQL binary used for analysis From 38dd4a088a2d38c5d48640c3506dc86215880d92 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Thu, 3 Sep 2026 18:21:46 +0100 Subject: [PATCH 4/9] Don't record an overlay status when the job was cancelled Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- lib/entry-points.js | 18 +++++- src/init-action-post-helper.test.ts | 95 +++++++++++++++++++++++++++++ src/init-action-post-helper.ts | 34 ++++++++++- src/init-action-post.ts | 7 +++ 4 files changed, 150 insertions(+), 4 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 497e44d9d..7666a9d2b 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -162277,8 +162277,8 @@ async function tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger return createFailedUploadFailedSarifResult(e); } } -async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLogs2, codeql, config, repositoryNwo, features, logger) { - await recordOverlayStatus(codeql, config, features, logger); +async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLogs2, codeql, config, repositoryNwo, features, jobStatus, logger) { + await recordOverlayStatus(codeql, config, features, jobStatus, logger); const uploadFailedSarifResult = await tryUploadSarifIfRunFailed( config, repositoryNwo, @@ -162340,10 +162340,20 @@ async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLog } return uploadFailedSarifResult; } -async function recordOverlayStatus(codeql, config, features, logger) { +function didCodeQlReportError() { + const jobStatus = process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */]; + return jobStatus === "JOB_STATUS_FAILURE" /* FailureStatus */ || jobStatus === "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */; +} +async function recordOverlayStatus(codeql, config, features, jobStatus, logger) { if (config.overlayDatabaseMode !== "overlay-base" /* OverlayBase */ || process.env["CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */] === "true" || !await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */)) { return; } + if (jobStatus?.trim().toLowerCase() === "cancelled" && !didCodeQlReportError()) { + logger.info( + "Not recording an improved incremental analysis failure for this job because the workflow run was cancelled." + ); + return; + } const checkRunIdInput = getOptionalInput("check-run-id"); const checkRunId = checkRunIdInput !== void 0 ? parseInt(checkRunIdInput, 10) : void 0; const overlayStatus = createOverlayStatus( @@ -162445,6 +162455,7 @@ async function run4(startedAt) { let uploadFailedSarifResult; let dependencyCachingUsage; try { + const jobStatus2 = getOptionalInput("job-status"); restoreInputs(); const gitHubVersion = await getGitHubVersion(); checkGitHubVersionInRange(gitHubVersion, logger); @@ -162469,6 +162480,7 @@ async function run4(startedAt) { config, repositoryNwo, features, + jobStatus2, logger ); if (await isAnalyzingDefaultBranch() && config.dependencyCachingEnabled !== "none" /* None */) { diff --git a/src/init-action-post-helper.test.ts b/src/init-action-post-helper.test.ts index f24cc5e4e..8f2868ef7 100644 --- a/src/init-action-post-helper.test.ts +++ b/src/init-action-post-helper.test.ts @@ -15,6 +15,7 @@ import { getRunnerLogger } from "./logging"; import { OverlayDatabaseMode } from "./overlay/overlay-database-mode"; import * as overlayStatus from "./overlay/status"; import { parseRepositoryNwo } from "./repository"; +import { JobStatus } from "./status-report"; import { createFeatures, createTestConfig, @@ -58,6 +59,7 @@ test.serial("init-post action with debug mode off", async (t) => { createTestConfig({ debugMode: false }), parseRepositoryNwo("github/codeql-action"), createFeatures([]), + "success", getRunnerLogger(true), ); @@ -80,6 +82,7 @@ test.serial("init-post action with debug mode on", async (t) => { createTestConfig({ debugMode: true }), parseRepositoryNwo("github/codeql-action"), createFeatures([]), + "success", getRunnerLogger(true), ); @@ -375,6 +378,7 @@ test.serial( }), parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.OverlayAnalysisStatusSave]), + "success", getRunnerLogger(true), ); @@ -443,6 +447,7 @@ test.serial( }), parseRepositoryNwo("github/codeql-action"), createFeatures([]), + "success", getRunnerLogger(true), ); @@ -480,6 +485,7 @@ test.serial("does not save overlay status when build successful", async (t) => { }), parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.OverlayAnalysisStatusSave]), + "success", getRunnerLogger(true), ); @@ -517,6 +523,7 @@ test.serial( }), parseRepositoryNwo("github/codeql-action"), createFeatures([]), + "success", getRunnerLogger(true), ); @@ -528,6 +535,94 @@ test.serial( }, ); +/** + * Runs `uploadFailureInfo` for an overlay-base job that did not complete successfully, for a job + * that the Actions runtime environment reports as cancelled. + */ +async function testCancelledOverlayJob({ + jobStatus = "cancelled", + codeQlReportedError = false, +}: { + jobStatus?: string; + codeQlReportedError?: boolean; +} = {}) { + return await util.withTmpDir(async (tmpDir) => { + setupActionsVars(tmpDir, tmpDir); + delete process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY]; + if (codeQlReportedError) { + process.env[EnvVar.JOB_STATUS] = JobStatus.FailureStatus; + } else { + delete process.env[EnvVar.JOB_STATUS]; + } + + sinon.stub(util, "checkDiskUsage").resolves({ + numAvailableBytes: 100 * NUM_BYTES_PER_GIB, + numTotalBytes: 200 * NUM_BYTES_PER_GIB, + }); + + const saveOverlayStatusStub = sinon + .stub(overlayStatus, "saveOverlayStatus") + .resolves(true); + + await initActionPostHelper.uploadFailureInfo( + sinon.spy(), + sinon.spy(), + codeql.createStubCodeQL({}), + createTestConfig({ + debugMode: false, + languages: ["javascript"], + overlayDatabaseMode: OverlayDatabaseMode.OverlayBase, + }), + parseRepositoryNwo("github/codeql-action"), + createFeatures([Feature.OverlayAnalysisStatusSave]), + jobStatus, + getRunnerLogger(true), + ); + + return { saveOverlayStatusStub }; + }); +} + +test.serial( + "does not save overlay status when the job was cancelled", + async (t) => { + const { saveOverlayStatusStub } = await testCancelledOverlayJob(); + + t.true( + saveOverlayStatusStub.notCalled, + "a cancellation tells us nothing about whether the analysis would have succeeded", + ); + }, +); + +test.serial( + "saves overlay status when the job failed rather than being cancelled", + async (t) => { + const { saveOverlayStatusStub } = await testCancelledOverlayJob({ + jobStatus: "failure", + }); + + t.true( + saveOverlayStatusStub.calledOnce, + "only cancellations are treated as unrelated to the analysis", + ); + }, +); + +test.serial( + "saves overlay status when a CodeQL Action reported an error before the run was cancelled", + async (t) => { + const { saveOverlayStatusStub } = await testCancelledOverlayJob({ + codeQlReportedError: true, + }); + + t.true( + saveOverlayStatusStub.calledOnce, + "the analysis genuinely failed, even though the run was later cancelled", + ); + }, +); + function createTestWorkflow( steps: workflow.WorkflowJobStep[], ): workflow.Workflow { diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index 7b7b056a1..72c9a6236 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -316,6 +316,7 @@ export async function tryUploadSarifIfRunFailed( * @param config The CodeQL Action configuration. * @param repositoryNwo The name and owner of the repository. * @param features Information about enabled features. + * @param jobStatus The status of the job, as reported by the Actions runtime environment. * @param logger The logger to use. * @returns The results of uploading the SARIF file for the failure. */ @@ -331,9 +332,10 @@ export async function uploadFailureInfo( config: Config, repositoryNwo: RepositoryNwo, features: FeatureEnablement, + jobStatus: string | undefined, logger: Logger, ): Promise { - await recordOverlayStatus(codeql, config, features, logger); + await recordOverlayStatus(codeql, config, features, jobStatus, logger); const uploadFailedSarifResult = await tryUploadSarifIfRunFailed( config, @@ -412,6 +414,21 @@ export async function uploadFailureInfo( return uploadFailedSarifResult; } +/** + * Whether one of the CodeQL Actions reported an error for this job, which means the analysis + * genuinely failed. + * + * Note that the converse does not hold: an Action that is terminated abruptly, or that fails before + * it can gather telemetry, does not get to report anything. + */ +function didCodeQlReportError(): boolean { + const jobStatus = process.env[EnvVar.JOB_STATUS]; + return ( + jobStatus === JobStatus.FailureStatus || + jobStatus === JobStatus.ConfigErrorStatus + ); +} + /** * If overlay base database creation was attempted but the analysis did not complete * successfully, save the failure status to the Actions cache so that subsequent runs @@ -421,6 +438,7 @@ async function recordOverlayStatus( codeql: CodeQL, config: Config, features: FeatureEnablement, + jobStatus: string | undefined, logger: Logger, ) { if ( @@ -431,6 +449,20 @@ async function recordOverlayStatus( return; } + // A cancelled run tells us nothing about whether the analysis would have succeeded, so recording + // a failure would disable overlay analysis needlessly. Note that we still record a failure if one + // of our own Actions reported an error before the run was cancelled. + if ( + jobStatus?.trim().toLowerCase() === "cancelled" && + !didCodeQlReportError() + ) { + logger.info( + "Not recording an improved incremental analysis failure for this job because the workflow " + + "run was cancelled.", + ); + return; + } + const checkRunIdInput = actionsUtil.getOptionalInput("check-run-id"); const checkRunId = checkRunIdInput !== undefined ? parseInt(checkRunIdInput, 10) : undefined; diff --git a/src/init-action-post.ts b/src/init-action-post.ts index 2261b56ea..6d6b653e6 100644 --- a/src/init-action-post.ts +++ b/src/init-action-post.ts @@ -8,6 +8,7 @@ import * as core from "@actions/core"; import { restoreInputs, + getOptionalInput, getTemporaryDirectory, printDebugLogs, } from "./actions-util"; @@ -55,6 +56,11 @@ async function run(startedAt: Date) { | undefined; let dependencyCachingUsage: DependencyCachingUsageReport | undefined; try { + // Read the job status before restoring inputs, since it is provided by the Actions runtime + // environment for this step and would otherwise be overwritten by the value that the `init` + // Action saw, which is always a success. + const jobStatus = getOptionalInput("job-status"); + // Restore inputs from `init` Action. restoreInputs(); @@ -84,6 +90,7 @@ async function run(startedAt: Date) { config, repositoryNwo, features, + jobStatus, logger, ); From 36cbf13b5e1d1b4ef93c4828c59b8bf5d6290e3f Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Thu, 3 Sep 2026 16:04:02 +0200 Subject: [PATCH 5/9] Address review comments - Analyze all languages CodeQL supports on Linux Arm64 (except Swift, which is macOS only) in the Linux Arm64 check, building the compiled ones via the shared multi-language-repo build.sh - De-duplicate the check's language list via a shared LANGUAGES env var used by both the init input and the assert loop - Fix CHANGELOG tense: "download" -> "downloads" Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/__linux-arm64.yml | 25 ++++++++++++++++++++----- CHANGELOG.md | 2 +- pr-checks/checks/linux-arm64.yml | 12 ++++++++---- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/__linux-arm64.yml b/.github/workflows/__linux-arm64.yml index a1764426d..cea1f5d5b 100644 --- a/.github/workflows/__linux-arm64.yml +++ b/.github/workflows/__linux-arm64.yml @@ -20,6 +20,11 @@ on: - cron: '0 5 * * *' workflow_dispatch: inputs: + dotnet-version: + type: string + description: The version of .NET to install + required: false + default: 9.x go-version: type: string description: The version of Go to install @@ -27,6 +32,11 @@ on: default: '>=1.21.0' workflow_call: inputs: + dotnet-version: + type: string + description: The version of .NET to install + required: false + default: 9.x go-version: type: string description: The version of Go to install @@ -37,7 +47,7 @@ defaults: shell: bash concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' || false }} - group: linux-arm64-${{github.ref}}-${{inputs.go-version}} + group: linux-arm64-${{github.ref}}-${{inputs.dotnet-version}}-${{inputs.go-version}} jobs: linux-arm64: strategy: @@ -56,6 +66,10 @@ jobs: steps: - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Install .NET + uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + with: + dotnet-version: ${{ inputs.dotnet-version || '9.x' }} - name: Install Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: @@ -70,21 +84,22 @@ jobs: setup-kotlin: 'true' - uses: ./../action/init with: - languages: javascript,python,go + languages: ${{ env.LANGUAGES }} tools: ${{ steps.prepare-test.outputs.tools-url }} - - name: Build Go code - run: go build main.go + - name: Build code + run: ./build.sh - uses: ./../action/analyze with: upload-database: false - name: Assert databases exist run: | cd "$RUNNER_TEMP/codeql_databases" - for lang in javascript python go; do + for lang in ${LANGUAGES//,/ }; do if [[ ! -d "$lang" ]]; then echo "Did not find a database for $lang" exit 1 fi done env: + LANGUAGES: cpp,csharp,go,java,javascript,python,ruby CODEQL_ACTION_TEST_MODE: true diff --git a/CHANGELOG.md b/CHANGELOG.md index dc22e818d..617419b55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th ## [UNRELEASED] -- The CodeQL Action now supports CodeQL releases that are compatible with Linux Arm64 and download the native `linux-arm64` CodeQL bundle when available. [#4072](https://github.com/github/codeql-action/pull/4072) +- The CodeQL Action now supports CodeQL releases that are compatible with Linux Arm64 and downloads the native `linux-arm64` CodeQL bundle when available. [#4072](https://github.com/github/codeql-action/pull/4072) ## 4.37.9 - 26 Aug 2026 diff --git a/pr-checks/checks/linux-arm64.yml b/pr-checks/checks/linux-arm64.yml index 94e03da17..a938db8ee 100644 --- a/pr-checks/checks/linux-arm64.yml +++ b/pr-checks/checks/linux-arm64.yml @@ -9,20 +9,24 @@ operatingSystems: versions: - nightly-latest installGo: true +installDotNet: true +# The set of languages CodeQL supports on this platform, excluding Swift (macOS only). +env: + LANGUAGES: cpp,csharp,go,java,javascript,python,ruby steps: - uses: ./../action/init with: - languages: javascript,python,go + languages: ${{ env.LANGUAGES }} tools: ${{ steps.prepare-test.outputs.tools-url }} - - name: Build Go code - run: go build main.go + - name: Build code + run: ./build.sh - uses: ./../action/analyze with: upload-database: false - name: Assert databases exist run: | cd "$RUNNER_TEMP/codeql_databases" - for lang in javascript python go; do + for lang in ${LANGUAGES//,/ }; do if [[ ! -d "$lang" ]]; then echo "Did not find a database for $lang" exit 1 From 16da74769ed25d08c9bd0b5304ed8bafc97bd5e5 Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Fri, 4 Sep 2026 12:27:23 +0200 Subject: [PATCH 6/9] Log found databases in Linux Arm64 check Log a success line for each language database found in the Linux Arm64 PR check. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/__linux-arm64.yml | 1 + pr-checks/checks/linux-arm64.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/__linux-arm64.yml b/.github/workflows/__linux-arm64.yml index cea1f5d5b..de045d895 100644 --- a/.github/workflows/__linux-arm64.yml +++ b/.github/workflows/__linux-arm64.yml @@ -99,6 +99,7 @@ jobs: echo "Did not find a database for $lang" exit 1 fi + echo "Found database for $lang" done env: LANGUAGES: cpp,csharp,go,java,javascript,python,ruby diff --git a/pr-checks/checks/linux-arm64.yml b/pr-checks/checks/linux-arm64.yml index a938db8ee..29d3eea41 100644 --- a/pr-checks/checks/linux-arm64.yml +++ b/pr-checks/checks/linux-arm64.yml @@ -31,4 +31,5 @@ steps: echo "Did not find a database for $lang" exit 1 fi + echo "Found database for $lang" done From d2fe508a6d480a4c90dd74cacbb40cf0812b4e5a Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 4 Sep 2026 17:22:52 +0100 Subject: [PATCH 7/9] Don't upload the ESLint SARIF from merge queue refs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pr-checks.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index b1e131425..3915fddf5 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -67,7 +67,12 @@ jobs: - name: Upload sarif uses: ./upload-sarif - if: matrix.os == 'ubuntu-latest' && matrix.node-version == 24 + # The merge queue deletes its `gh-readonly-queue` ref as soon as the queue entry resolves, + # so uploading against it races with that deletion. Both the `merge_group` run and the + # paired `push` run that the queue branch creates use that ref, so gate on the ref itself + # rather than the event. The same results are uploaded by the `pull_request` run and again + # by the `push` run on `main`. + if: matrix.os == 'ubuntu-latest' && matrix.node-version == 24 && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') with: sarif_file: eslint.sarif category: eslint From 657964c39f90c08ebf0224f0e2e264eab1d5fc15 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 4 Sep 2026 17:31:24 +0100 Subject: [PATCH 8/9] Read the job status from a `ReadOnlyEnv` in `recordOverlayStatus` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- lib/entry-points.js | 15 ++++++++------- src/init-action-post-helper.test.ts | 25 +++++++++++++++++++------ src/init-action-post-helper.ts | 15 +++++++++------ src/init-action-post.ts | 3 ++- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 7666a9d2b..67cd84b78 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -162277,8 +162277,8 @@ async function tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger return createFailedUploadFailedSarifResult(e); } } -async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLogs2, codeql, config, repositoryNwo, features, jobStatus, logger) { - await recordOverlayStatus(codeql, config, features, jobStatus, logger); +async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLogs2, codeql, config, repositoryNwo, features, jobStatus, env, logger) { + await recordOverlayStatus(codeql, config, features, jobStatus, env, logger); const uploadFailedSarifResult = await tryUploadSarifIfRunFailed( config, repositoryNwo, @@ -162340,15 +162340,15 @@ async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLog } return uploadFailedSarifResult; } -function didCodeQlReportError() { - const jobStatus = process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */]; +function didCodeQlReportError(env) { + const jobStatus = env.getOptional("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */); return jobStatus === "JOB_STATUS_FAILURE" /* FailureStatus */ || jobStatus === "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */; } -async function recordOverlayStatus(codeql, config, features, jobStatus, logger) { - if (config.overlayDatabaseMode !== "overlay-base" /* OverlayBase */ || process.env["CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */] === "true" || !await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */)) { +async function recordOverlayStatus(codeql, config, features, jobStatus, env, logger) { + if (config.overlayDatabaseMode !== "overlay-base" /* OverlayBase */ || env.getOptional("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */) === "true" || !await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */)) { return; } - if (jobStatus?.trim().toLowerCase() === "cancelled" && !didCodeQlReportError()) { + if (jobStatus?.trim().toLowerCase() === "cancelled" && !didCodeQlReportError(env)) { logger.info( "Not recording an improved incremental analysis failure for this job because the workflow run was cancelled." ); @@ -162481,6 +162481,7 @@ async function run4(startedAt) { repositoryNwo, features, jobStatus2, + getEnv(), logger ); if (await isAnalyzingDefaultBranch() && config.dependencyCachingEnabled !== "none" /* None */) { diff --git a/src/init-action-post-helper.test.ts b/src/init-action-post-helper.test.ts index 8f2868ef7..95ec27f4b 100644 --- a/src/init-action-post-helper.test.ts +++ b/src/init-action-post-helper.test.ts @@ -20,6 +20,7 @@ import { createFeatures, createTestConfig, DEFAULT_ACTIONS_VARS, + getTestEnv, makeMacro, makeVersionInfo, RecordingLogger, @@ -60,6 +61,7 @@ test.serial("init-post action with debug mode off", async (t) => { parseRepositoryNwo("github/codeql-action"), createFeatures([]), "success", + getTestEnv(), getRunnerLogger(true), ); @@ -83,6 +85,7 @@ test.serial("init-post action with debug mode on", async (t) => { parseRepositoryNwo("github/codeql-action"), createFeatures([]), "success", + getTestEnv(), getRunnerLogger(true), ); @@ -379,6 +382,7 @@ test.serial( parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.OverlayAnalysisStatusSave]), "success", + getTestEnv(), getRunnerLogger(true), ); @@ -448,6 +452,7 @@ test.serial( parseRepositoryNwo("github/codeql-action"), createFeatures([]), "success", + getTestEnv(), getRunnerLogger(true), ); @@ -462,8 +467,13 @@ test.serial( test.serial("does not save overlay status when build successful", async (t) => { return await util.withTmpDir(async (tmpDir) => { setupActionsVars(tmpDir, tmpDir); - // Mark analyze as having completed successfully. + // Mark analyze as having completed successfully. `tryUploadSarifIfRunFailed` reads this from + // the process environment, while `recordOverlayStatus` reads it from the environment it is + // given. process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] = "true"; + const env = getTestEnv({ + [EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY]: "true", + }); sinon.stub(util, "checkDiskUsage").resolves({ numAvailableBytes: 100 * NUM_BYTES_PER_GIB, @@ -486,6 +496,7 @@ test.serial("does not save overlay status when build successful", async (t) => { parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.OverlayAnalysisStatusSave]), "success", + env, getRunnerLogger(true), ); @@ -524,6 +535,7 @@ test.serial( parseRepositoryNwo("github/codeql-action"), createFeatures([]), "success", + getTestEnv(), getRunnerLogger(true), ); @@ -549,11 +561,11 @@ async function testCancelledOverlayJob({ return await util.withTmpDir(async (tmpDir) => { setupActionsVars(tmpDir, tmpDir); delete process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY]; - if (codeQlReportedError) { - process.env[EnvVar.JOB_STATUS] = JobStatus.FailureStatus; - } else { - delete process.env[EnvVar.JOB_STATUS]; - } + const env = getTestEnv( + codeQlReportedError + ? { [EnvVar.JOB_STATUS]: JobStatus.FailureStatus } + : {}, + ); sinon.stub(util, "checkDiskUsage").resolves({ numAvailableBytes: 100 * NUM_BYTES_PER_GIB, @@ -576,6 +588,7 @@ async function testCancelledOverlayJob({ parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.OverlayAnalysisStatusSave]), jobStatus, + env, getRunnerLogger(true), ); diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index 72c9a6236..4363fc755 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -18,7 +18,7 @@ import { sanitizeArtifactName, } from "./debug-artifacts"; import * as dependencyCaching from "./dependency-caching"; -import { EnvVar } from "./environment"; +import { EnvVar, ReadOnlyEnv } from "./environment"; import { Feature, FeatureEnablement } from "./feature-flags"; import { Logger } from "./logging"; import { OverlayDatabaseMode } from "./overlay/overlay-database-mode"; @@ -317,6 +317,7 @@ export async function tryUploadSarifIfRunFailed( * @param repositoryNwo The name and owner of the repository. * @param features Information about enabled features. * @param jobStatus The status of the job, as reported by the Actions runtime environment. + * @param env The environment to read variables from. * @param logger The logger to use. * @returns The results of uploading the SARIF file for the failure. */ @@ -333,9 +334,10 @@ export async function uploadFailureInfo( repositoryNwo: RepositoryNwo, features: FeatureEnablement, jobStatus: string | undefined, + env: ReadOnlyEnv, logger: Logger, ): Promise { - await recordOverlayStatus(codeql, config, features, jobStatus, logger); + await recordOverlayStatus(codeql, config, features, jobStatus, env, logger); const uploadFailedSarifResult = await tryUploadSarifIfRunFailed( config, @@ -421,8 +423,8 @@ export async function uploadFailureInfo( * Note that the converse does not hold: an Action that is terminated abruptly, or that fails before * it can gather telemetry, does not get to report anything. */ -function didCodeQlReportError(): boolean { - const jobStatus = process.env[EnvVar.JOB_STATUS]; +function didCodeQlReportError(env: ReadOnlyEnv): boolean { + const jobStatus = env.getOptional(EnvVar.JOB_STATUS); return ( jobStatus === JobStatus.FailureStatus || jobStatus === JobStatus.ConfigErrorStatus @@ -439,11 +441,12 @@ async function recordOverlayStatus( config: Config, features: FeatureEnablement, jobStatus: string | undefined, + env: ReadOnlyEnv, logger: Logger, ) { if ( config.overlayDatabaseMode !== OverlayDatabaseMode.OverlayBase || - process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] === "true" || + env.getOptional(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY) === "true" || !(await features.getValue(Feature.OverlayAnalysisStatusSave)) ) { return; @@ -454,7 +457,7 @@ async function recordOverlayStatus( // of our own Actions reported an error before the run was cancelled. if ( jobStatus?.trim().toLowerCase() === "cancelled" && - !didCodeQlReportError() + !didCodeQlReportError(env) ) { logger.info( "Not recording an improved incremental analysis failure for this job because the workflow " + diff --git a/src/init-action-post.ts b/src/init-action-post.ts index 6d6b653e6..749020ac6 100644 --- a/src/init-action-post.ts +++ b/src/init-action-post.ts @@ -21,7 +21,7 @@ import { DependencyCachingUsageReport, getDependencyCacheUsage, } from "./dependency-caching"; -import { EnvVar } from "./environment"; +import { EnvVar, getEnv } from "./environment"; import { initFeatures } from "./feature-flags"; import * as gitUtils from "./git-utils"; import * as initActionPostHelper from "./init-action-post-helper"; @@ -91,6 +91,7 @@ async function run(startedAt: Date) { repositoryNwo, features, jobStatus, + getEnv(), logger, ); From a48f2d30771d5b2b049495b82e4e6b1eeeac932d Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 4 Sep 2026 17:33:02 +0100 Subject: [PATCH 9/9] Record an overlay status only for conclusive job statuses Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- lib/entry-points.js | 13 +++++- src/init-action-post-helper.test.ts | 68 +++++++++++++++++++++++------ src/init-action-post-helper.ts | 32 ++++++++++---- 3 files changed, 89 insertions(+), 24 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 67cd84b78..24cf3af70 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -162344,13 +162344,22 @@ function didCodeQlReportError(env) { const jobStatus = env.getOptional("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */); return jobStatus === "JOB_STATUS_FAILURE" /* FailureStatus */ || jobStatus === "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */; } +function isConclusiveJobStatus(jobStatus) { + switch (jobStatus?.trim().toLowerCase()) { + case "failure": + case "success": + return true; + default: + return false; + } +} async function recordOverlayStatus(codeql, config, features, jobStatus, env, logger) { if (config.overlayDatabaseMode !== "overlay-base" /* OverlayBase */ || env.getOptional("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */) === "true" || !await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */)) { return; } - if (jobStatus?.trim().toLowerCase() === "cancelled" && !didCodeQlReportError(env)) { + if (!isConclusiveJobStatus(jobStatus) && !didCodeQlReportError(env)) { logger.info( - "Not recording an improved incremental analysis failure for this job because the workflow run was cancelled." + `Not recording an improved incremental analysis failure for this job because the job status (${jobStatus ?? "unset"}) does not tell us whether the analysis itself failed.` ); return; } diff --git a/src/init-action-post-helper.test.ts b/src/init-action-post-helper.test.ts index 95ec27f4b..fd1f489f7 100644 --- a/src/init-action-post-helper.test.ts +++ b/src/init-action-post-helper.test.ts @@ -548,16 +548,16 @@ test.serial( ); /** - * Runs `uploadFailureInfo` for an overlay-base job that did not complete successfully, for a job - * that the Actions runtime environment reports as cancelled. + * Runs `uploadFailureInfo` for an overlay-base job that did not complete successfully, with the + * given job status from the Actions runtime environment. */ -async function testCancelledOverlayJob({ - jobStatus = "cancelled", +async function runOverlayPostStep({ + jobStatus, codeQlReportedError = false, }: { - jobStatus?: string; + jobStatus: string | undefined; codeQlReportedError?: boolean; -} = {}) { +}) { return await util.withTmpDir(async (tmpDir) => { setupActionsVars(tmpDir, tmpDir); delete process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY]; @@ -599,7 +599,9 @@ async function testCancelledOverlayJob({ test.serial( "does not save overlay status when the job was cancelled", async (t) => { - const { saveOverlayStatusStub } = await testCancelledOverlayJob(); + const { saveOverlayStatusStub } = await runOverlayPostStep({ + jobStatus: "cancelled", + }); t.true( saveOverlayStatusStub.notCalled, @@ -609,23 +611,63 @@ test.serial( ); test.serial( - "saves overlay status when the job failed rather than being cancelled", + "does not save overlay status when the job status is not recognised", async (t) => { - const { saveOverlayStatusStub } = await testCancelledOverlayJob({ - jobStatus: "failure", + const { saveOverlayStatusStub } = await runOverlayPostStep({ + jobStatus: "some-new-status", }); t.true( - saveOverlayStatusStub.calledOnce, - "only cancellations are treated as unrelated to the analysis", + saveOverlayStatusStub.notCalled, + "a status we do not recognise tells us nothing about whether the analysis would have succeeded", ); }, ); +test.serial( + "does not save overlay status when the job status is unavailable", + async (t) => { + const { saveOverlayStatusStub } = await runOverlayPostStep({ + jobStatus: undefined, + }); + + t.true( + saveOverlayStatusStub.notCalled, + "without a job status we cannot tell whether the analysis would have succeeded", + ); + }, +); + +test.serial( + "saves overlay status when the job failed rather than being cancelled", + async (t) => { + const { saveOverlayStatusStub } = await runOverlayPostStep({ + jobStatus: "failure", + }); + + t.true( + saveOverlayStatusStub.calledOnce, + "a failed job indicates that the analysis itself failed", + ); + }, +); + +test.serial("saves overlay status when the job succeeded", async (t) => { + const { saveOverlayStatusStub } = await runOverlayPostStep({ + jobStatus: "success", + }); + + t.true( + saveOverlayStatusStub.calledOnce, + "the analysis did not complete successfully even though the job as a whole succeeded", + ); +}); + test.serial( "saves overlay status when a CodeQL Action reported an error before the run was cancelled", async (t) => { - const { saveOverlayStatusStub } = await testCancelledOverlayJob({ + const { saveOverlayStatusStub } = await runOverlayPostStep({ + jobStatus: "cancelled", codeQlReportedError: true, }); diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index 4363fc755..0e6dae13a 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -431,6 +431,22 @@ function didCodeQlReportError(env: ReadOnlyEnv): boolean { ); } +/** + * Whether the job status tells us anything about whether the analysis itself would have succeeded. + * + * We check for the statuses we know to be meaningful rather than excluding the ones that are not, + * so that a status we do not recognise is treated as inconclusive. + */ +function isConclusiveJobStatus(jobStatus: string | undefined): boolean { + switch (jobStatus?.trim().toLowerCase()) { + case "failure": + case "success": + return true; + default: + return false; + } +} + /** * If overlay base database creation was attempted but the analysis did not complete * successfully, save the failure status to the Actions cache so that subsequent runs @@ -452,16 +468,14 @@ async function recordOverlayStatus( return; } - // A cancelled run tells us nothing about whether the analysis would have succeeded, so recording - // a failure would disable overlay analysis needlessly. Note that we still record a failure if one - // of our own Actions reported an error before the run was cancelled. - if ( - jobStatus?.trim().toLowerCase() === "cancelled" && - !didCodeQlReportError(env) - ) { + // Only record a failure when the job outcome tells us something about the analysis. A cancelled + // job, or a status we do not recognise, says nothing about whether the analysis would have + // succeeded, so recording a failure would disable overlay analysis needlessly. We still record + // one if a CodeQL Action reported an error before the job ended. + if (!isConclusiveJobStatus(jobStatus) && !didCodeQlReportError(env)) { logger.info( - "Not recording an improved incremental analysis failure for this job because the workflow " + - "run was cancelled.", + "Not recording an improved incremental analysis failure for this job because the job " + + `status (${jobStatus ?? "unset"}) does not tell us whether the analysis itself failed.`, ); return; }