Compare commits

...
Author SHA1 Message Date
Henry Mercer 394261f58c Merge pull request #4345 from github/henrymercer/cancelled-runs-reporting
Report cancelled jobs with a separate job status in `init-post`
2026-11-30 14:05:17 +00:00
Sam Robson 776237d428 Merge pull request #4349 from github/mergeback/v4.39.5-to-main-915412ff
Mergeback v4.39.5 refs/heads/releases/v4 into main
2026-11-24 15:18:32 +00:00
github-actions[bot] 743c02edee Rebuild 2026-11-24 14:58:39 +00:00
github-actions[bot] c27036f19d Update changelog and version after v4.39.5 2026-11-24 14:58:25 +00:00
Sam Robson 915412ff23 Merge pull request #4348 from github/update-v4.39.5-bed9c837c
Merge main into releases/v4
2026-11-24 14:56:45 +00:00
github-actions[bot] 35d990cd3b Update changelog for v4.39.5 2026-11-24 14:37:31 +00:00
Henry Mercer bed9c837cf Merge pull request #4346 from github/henrymercer/rename-to-overlay-analysis
Rename improved incremental analysis to overlay analysis
2026-11-24 12:25:45 +00:00
Henry Mercer 1f73992007 Merge pull request #4332 from github/henrymercer/codeql-action-bumps
Update the `minimatch` copies used by `archiver` and `eslint-plugin-import-x` to v11
2026-11-24 10:49:45 +00:00
Henry Mercer becf94ae7b Merge pull request #4344 from github/henrymercer/deflake-workflow-list
Generate the Deflake workflow list
2026-11-24 10:49:37 +00:00
Sam Robson 5d7d6cdfdb Merge pull request #4347 from github/update-bundle/codeql-bundle-v2.27.6
Update default bundle to 2.27.6
2026-11-24 10:32:01 +00:00
github-actions[bot] 0006d1f62f Add changenote 2026-11-24 09:59:57 +00:00
github-actions[bot] ca37df17a9 Update default bundle to codeql-bundle-v2.27.6 2026-11-24 09:59:50 +00:00
Henry MercerandCopilot App 7f3a2f5c7f Rename improved incremental analysis to overlay analysis
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-23 20:22:02 +00:00
Henry MercerandCopilot App b69d569f2c Report cancelled jobs with a separate job status in init-post
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-23 19:55:31 +00:00
Henry MercerandCopilot App 73d9b6db16 Generate the Deflake workflow list in pr-checks/sync.ts
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-23 17:32:55 +00:00
Henry MercerandCopilot App 9ee158cbfd Update the Deflake workflow list to match the current PR checks
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-23 17:32:55 +00:00
github-actions[bot] fa7acb99cd Rebuild 2026-11-19 13:21:30 +00:00
Henry MercerandCopilot App a27b4d64b7 Update minimatch to 11.0.8 where existing ranges allow
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-19 13:19:15 +00:00
Henry MercerandCopilot App 3fd9439bde Override archiver's readdir-glob to v4 to pick up minimatch v11
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-19 13:18:50 +00:00
17 changed files with 2917 additions and 1777 deletions

No files matched your search

+16 -16
View File
@@ -6,19 +6,19 @@ name: Deflake
on:
workflow_run:
types: [completed]
# Exclude workflows that have significant side effects, like publishing releases. It's OK to
# retry CodeQL analysis.
# Generated by `pr-checks/sync.sh` from the templates in `pr-checks/checks` and the other
# workflows listed in `pr-checks/deflake.ts`.
workflows:
- Check Expected Release Files
- Code-Scanning config CLI tests
- CodeQL action
- Manual Check - go
- "Check Expected Release Files"
- "Code-Scanning config CLI tests"
- "CodeQL action"
- "Manual Check - go"
- "PR Check - All-platform bundle"
- "PR Check - Analysis kinds"
- "PR Check - Analyze: 'ref' and 'sha' from inputs"
- "PR Check - autobuild-action"
- "PR Check - Autobuild direct tracing (custom working directory)"
- "PR Check - Autobuild working directory"
- "PR Check - autobuild-action"
- "PR Check - Build mode autobuild"
- "PR Check - Build mode manual"
- "PR Check - Build mode none"
@@ -26,7 +26,6 @@ on:
- "PR Check - Bundle: Caching checks"
- "PR Check - Bundle: From nightly"
- "PR Check - Bundle: From toolcache"
- "PR Check - Bundle: Zstandard checks"
- "PR Check - C/C\\+\\+: autoinstalling dependencies (Linux)"
- "PR Check - C/C\\+\\+: autoinstalling dependencies is skipped (macOS)"
- "PR Check - C/C\\+\\+: disabling autoinstalling dependencies (Linux)"
@@ -37,11 +36,12 @@ on:
- "PR Check - Debug artifact upload"
- "PR Check - Debug artifacts after failure"
- "PR Check - Diagnostic export"
- "PR Check - Diagnostic export without database"
- "PR Check - Export file baseline information"
- "PR Check - Extractor ram and threads options test"
- "PR Check - Go: Custom queries"
- "PR Check - Go: diagnostic when Go is changed after init step"
- "PR Check - Go: diagnostic when `file` is not installed"
- "PR Check - Go: diagnostic when Go is changed after init step"
- "PR Check - Go: tracing with autobuilder step"
- "PR Check - Go: tracing with custom build steps"
- "PR Check - Go: tracing with legacy workflow"
@@ -56,6 +56,7 @@ on:
- "PR Check - Packaging: Config and input passed to the CLI"
- "PR Check - Packaging: Config file"
- "PR Check - Packaging: Download using registries"
- "PR Check - Per-language bundles"
- "PR Check - Proxy test"
- "PR Check - Remote config file"
- "PR Check - Resolve environment"
@@ -69,19 +70,18 @@ on:
- "PR Check - Swift analysis using autobuild"
- "PR Check - Test different uses of `upload-sarif`"
- "PR Check - Test unsetting environment variables"
- "PR Check - Upload-sarif: ref and sha from inputs"
- "PR Check - Unsupported macOS"
- "PR Check - Upload-sarif: 'ref' and 'sha' from inputs"
- "PR Check - Use a custom `checkout_path`"
- PR Checks
- Query filters tests
- Test that the workaround for python 3.12 on windows works
- "PR Checks"
- "Query filters tests"
- "Test that the workaround for python 3.12 on windows works"
jobs:
rerun-on-failure:
name: Rerun failed jobs
if: >-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt == 1 &&
(
github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt == 1 && (
github.event.workflow_run.head_branch == 'main' ||
startsWith(github.event.workflow_run.head_branch, 'releases/') ||
github.event.workflow_run.event == 'merge_group'
+4
View File
@@ -6,6 +6,10 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
No user facing changes.
## 4.39.5 - 24 Nov 2026
- Update default CodeQL bundle version to [2.27.6](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.27.6). [#4347](https://github.com/github/codeql-action/pull/4347)
## 4.39.4 - 20 Nov 2026
- Update default CodeQL bundle version to [2.27.5](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.27.5). [#4333](https://github.com/github/codeql-action/pull/4333)
+2 -2
View File
@@ -154,8 +154,8 @@ inputs:
trap-caching:
description: >-
Explicitly enable or disable TRAP caching instead of using the automatically determined default.
TRAP caching is disabled by default when improved incremental analysis is enabled,
because improved incremental analysis of a pull request only extracts changed files,
TRAP caching is disabled by default when overlay analysis is enabled,
because overlay analysis of a pull request only extracts changed files,
which rarely benefit from TRAP caching.
required: false
dependency-caching:
+4 -4
View File
@@ -1,6 +1,6 @@
{
"bundleVersion": "codeql-bundle-v2.27.5",
"cliVersion": "2.27.5",
"priorBundleVersion": "codeql-bundle-v2.27.4",
"priorCliVersion": "2.27.4"
"bundleVersion": "codeql-bundle-v2.27.6",
"cliVersion": "2.27.6",
"priorBundleVersion": "codeql-bundle-v2.27.5",
"priorCliVersion": "2.27.5"
}
+2456 -1696
View File
File diff suppressed because it is too large. Load diff
+30 -28
View File
@@ -1,12 +1,12 @@
{
"name": "codeql",
"version": "4.39.5",
"version": "4.39.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "codeql",
"version": "4.39.5",
"version": "4.39.6",
"license": "MIT",
"workspaces": [
"pr-checks"
@@ -1789,9 +1789,9 @@
}
},
"node_modules/@isaacs/nonrecursive-glob-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.0.2.tgz",
"integrity": "sha512-GJPHIgPPtFl+nLhFHyF0zZoFcOFLsZWbHFFzo+Zr+PWDXJbl9hHxb2w+9SiF2fHmLgKaXIpUzQo3SbBBZ9WObw==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz",
"integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==",
"license": "BlueOak-1.0.0"
},
"node_modules/@mapbox/node-pre-gyp": {
@@ -5412,16 +5412,17 @@
}
},
"node_modules/eslint-plugin-import-x/node_modules/minimatch": {
"version": "10.2.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.4.tgz",
"integrity": "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==",
"version": "11.0.8",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz",
"integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"brace-expansion": "^5.0.2"
"@isaacs/nonrecursive-glob-match": "^1.1.0",
"brace-expansion": "^5.0.12"
},
"engines": {
"node": "18 || 20 || >=22"
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@@ -6337,16 +6338,16 @@
}
},
"node_modules/glob/node_modules/minimatch": {
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.2.tgz",
"integrity": "sha512-pWTgz5CN3tjqyZNSK2tePlSmu9IwM41q8yn8Usdqqwe9TIHh+9dEpLLjF4uApsfPEAZY71qtSiA2B2APEr+1Yw==",
"version": "11.0.8",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz",
"integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==",
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/nonrecursive-glob-match": "^1.0.2",
"@isaacs/nonrecursive-glob-match": "^1.1.0",
"brace-expansion": "^5.0.12"
},
"engines": {
"node": "18 || 20 || >=22"
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@@ -8814,15 +8815,15 @@
}
},
"node_modules/readdir-glob": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-3.0.0.tgz",
"integrity": "sha512-AhNB2KgKeVJr16nK9LLZbJNWnYoT23ZrumNKFDebHBdkC8KHSqWo871JAUhoWC/RtjEVdqNMFpM6qrwRbaUqpw==",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-4.0.0.tgz",
"integrity": "sha512-TG+tPOT85yLmgnlsp6xIu7/cOZsFYs74utMOZRahGQ1HAm3QGT63MSUD64WyzbQg/WN8hciv/+43XTzeIgn83w==",
"license": "Apache-2.0",
"dependencies": {
"minimatch": "^10.2.2"
"minimatch": "^11.0.1"
},
"engines": {
"node": ">=18"
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/yqnn"
@@ -8838,9 +8839,9 @@
}
},
"node_modules/readdir-glob/node_modules/brace-expansion": {
"version": "5.0.12",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
"version": "5.0.13",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz",
"integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==",
"license": "MIT",
"dependencies": {
"balanced-match": "^4.0.2"
@@ -8850,15 +8851,16 @@
}
},
"node_modules/readdir-glob/node_modules/minimatch": {
"version": "10.2.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz",
"integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==",
"version": "11.0.8",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz",
"integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==",
"license": "BlueOak-1.0.0",
"dependencies": {
"brace-expansion": "^5.0.5"
"@isaacs/nonrecursive-glob-match": "^1.1.0",
"brace-expansion": "^5.0.12"
},
"engines": {
"node": "18 || 20 || >=22"
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
+4 -1
View File
@@ -1,6 +1,6 @@
{
"name": "codeql",
"version": "4.39.5",
"version": "4.39.6",
"private": true,
"description": "CodeQL action",
"scripts": {
@@ -90,6 +90,9 @@
"@octokit/plugin-paginate-rest": {
"semver": ">=9.2.2"
},
"archiver@^8.0.0": {
"readdir-glob": "^4.0.0"
},
"eslint-plugin-import": {
"semver": ">=6.3.1"
},
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/env npx tsx
/*
Tests for `deflake.ts`.
*/
import * as assert from "node:assert/strict";
import { describe, it } from "node:test";
import { escapeWorkflowName, setWorkflowRunWorkflows } from "./deflake";
describe("escapeWorkflowName", async () => {
await it("escapes the characters that filter patterns treat as glob syntax", () => {
assert.equal(
escapeWorkflowName(
String.raw`!Name with C/C++, [a-z]?, *, ! and \ in it`,
),
String.raw`\!Name with C/C\+\+, \[a-z]\?, \*, \! and \\ in it`,
);
});
await it("leaves names without glob syntax unchanged", () => {
const name = "PR Check - Upload-sarif: 'ref' and `sha` (Linux) ]";
assert.equal(escapeWorkflowName(name), name);
});
});
describe("setWorkflowRunWorkflows", async () => {
await it("replaces the list with sorted, escaped names and leaves the rest of the workflow unchanged", () => {
const workflow = `on:
workflow_run:
types: [completed]
# A comment about the list.
workflows:
- Existing workflow
# A comment within the list.
- "Removed workflow"
jobs:
rerun:
if: |-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt == 1
`;
assert.equal(
setWorkflowRunWorkflows(workflow, [
"PR Check - b",
"PR Check - C/C++",
"Existing workflow",
"PR Check - a",
]),
String.raw`on:
workflow_run:
types: [completed]
# A comment about the list.
workflows:
- "Existing workflow"
- "PR Check - a"
- "PR Check - b"
- "PR Check - C/C\\+\\+"
jobs:
rerun:
if: |-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt == 1
`,
);
});
await it("uses single quotes only for patterns that contain double quotes and no backslashes", () => {
// These are the quotes that Prettier uses when formatting these strings.
assert.equal(
setWorkflowRunWorkflows(
"on:\n workflow_run:\n workflows:\n - Old\n",
['Upload "quoted" SARIF', `It's "quoted"`, 'C++ "quoted"'],
),
String.raw`on:
workflow_run:
workflows:
- "C\\+\\+ \"quoted\""
- 'It''s "quoted"'
- 'Upload "quoted" SARIF'
`,
);
});
await it("leaves comments and keys after the last item unchanged", () => {
const after = ` # A comment after the list.
branches: [main]
`;
assert.equal(
setWorkflowRunWorkflows(
`on:\n workflow_run:\n workflows:\n - Old\n${after}`,
["New"],
),
`on:\n workflow_run:\n workflows:\n - "New"\n${after}`,
);
});
await it("returns an up-to-date workflow unchanged", () => {
const workflow = String.raw`on:
workflow_run:
workflows:
- "C/C\\+\\+"
- "Other"
`;
assert.equal(
setWorkflowRunWorkflows(workflow, ["Other", "C/C++"]),
workflow,
);
});
await it("writes a flow sequence as a block sequence", () => {
assert.equal(
setWorkflowRunWorkflows("on:\n workflow_run:\n workflows: [Old]\n", [
"New",
]),
'on:\n workflow_run:\n workflows:\n - "New"\n',
);
});
await it("throws if the workflow isn't valid YAML", () => {
// Duplicate keys are an error in the `yaml` library, though Prettier accepts them.
assert.throws(
() =>
setWorkflowRunWorkflows(
"on:\n workflow_run:\n workflows:\n - Old\njobs: {}\njobs: {}\n",
["New"],
),
/Failed to parse the workflow: .* at line 6, column 1/,
);
});
await it("throws if the workflow has no workflow_run trigger", () => {
assert.throws(
() => setWorkflowRunWorkflows("on:\n push: {}\n", ["Other"]),
/Expected `on.workflow_run.workflows` to be a sequence/,
);
});
});
+111
View File
@@ -0,0 +1,111 @@
import * as fs from "fs";
import * as path from "path";
import * as yaml from "yaml";
import { REPO_ROOT } from "./config";
/** The path of the workflow that reruns failed jobs in other workflows. */
const DEFLAKE_WORKFLOW_FILE = path.join(
REPO_ROOT,
".github",
"workflows",
"deflake.yml",
);
/**
* The names of workflows that `sync.ts` doesn't generate, but whose failed jobs the Deflake
* workflow should rerun.
*
* Exclude workflows that have significant side effects, like publishing releases. It's OK to retry
* CodeQL analysis.
*/
const NON_GENERATED_WORKFLOWS_TO_RERUN = [
"Check Expected Release Files",
"Code-Scanning config CLI tests",
"CodeQL action",
"PR Check - Debug artifact upload",
"PR Check - Debug artifacts after failure",
"PR Checks",
"Query filters tests",
"Test that the workaround for python 3.12 on windows works",
];
/**
* Escapes the characters in a workflow name that `on.workflow_run.workflows` would otherwise treat
* as glob syntax.
*
* @returns A pattern that matches only the workflow called `name`.
*/
export function escapeWorkflowName(name: string): string {
// These are the characters that can be escaped in GitHub Actions filter patterns. `]` is only
// special after an unescaped `[`, so it doesn't need escaping.
return name.replace(/[\\[?*+!]/g, "\\$&");
}
/**
* Replaces the items in the `on.workflow_run.workflows` list of a workflow, and any comments on
* their lines or between them, with patterns that match the workflows called `workflowNames`,
* sorted by name. The list is written as a block sequence.
*
* The whole workflow is rewritten with the `yaml` library, so any other parts that aren't
* formatted the way that library formats them are reformatted, for example by joining lines of
* folded (`>`) block scalars. Prettier, which checks the formatting of YAML files in this
* repository, formats non-empty flow mappings, and flow sequences that don't fit within 80
* columns, differently from that library, so the workflow is expected not to contain any.
*
* @param workflow The contents of the workflow file.
* @param workflowNames The names of the workflows that should trigger the workflow.
* @returns The updated contents of the workflow file.
* @throws If the workflow isn't valid YAML, or `on.workflow_run.workflows` isn't a sequence.
*/
export function setWorkflowRunWorkflows(
workflow: string,
workflowNames: string[],
): string {
const document = yaml.parseDocument(workflow);
if (document.errors.length > 0) {
throw new Error(
`Failed to parse the workflow: ${document.errors[0].message}`,
);
}
const workflows = document.getIn(["on", "workflow_run", "workflows"], true);
if (!yaml.isSeq(workflows)) {
throw new Error("Expected `on.workflow_run.workflows` to be a sequence.");
}
workflows.flow = false;
workflows.items = workflowNames
.toSorted((a, b) => a.localeCompare(b, "en"))
.map((name) => {
const pattern = escapeWorkflowName(name);
const item = new yaml.Scalar(pattern);
// Quote the pattern in the same way as Prettier, which uses single quotes for strings that
// contain `"` but no `\`, and double quotes otherwise.
item.type =
pattern.includes('"') && !pattern.includes("\\")
? yaml.Scalar.QUOTE_SINGLE
: yaml.Scalar.QUOTE_DOUBLE;
return item;
});
// These options match how Prettier formats short flow sequences, such as `[completed]`, and long
// strings.
return document.toString({ flowCollectionPadding: false, lineWidth: 0 });
}
/**
* Updates the Deflake workflow so that it reruns failed jobs in the workflows called
* `generatedWorkflowNames` and in {@link NON_GENERATED_WORKFLOWS_TO_RERUN}.
*/
export function updateDeflakeWorkflow(generatedWorkflowNames: string[]): void {
console.log(`Updating the list of workflows in '${DEFLAKE_WORKFLOW_FILE}'.`);
const workflow = fs.readFileSync(DEFLAKE_WORKFLOW_FILE, "utf8");
fs.writeFileSync(
DEFLAKE_WORKFLOW_FILE,
setWorkflowRunWorkflows(workflow, [
...generatedWorkflowNames,
...NON_GENERATED_WORKFLOWS_TO_RERUN,
]),
"utf8",
);
}
+1 -1
View File
@@ -6,7 +6,7 @@ to one of the files in this directory.
## Updating workflows
Run `./sync.sh` to invoke the workflow generator and re-generate the workflow files in `.github/workflows/` based on the templates in `pr-checks/checks/`.
Run `./sync.sh` to invoke the workflow generator and re-generate the workflow files in `.github/workflows/` based on the templates in `pr-checks/checks/`. This also updates the list of workflows whose failed jobs `.github/workflows/deflake.yml` reruns.
Alternatively, you can use `just`:
+6
View File
@@ -8,6 +8,7 @@ import * as yaml from "yaml";
import { BuiltInLanguage } from "../src/languages";
import { PR_CHECKS_DIR, REPO_ROOT } from "./config";
import { updateDeflakeWorkflow } from "./deflake";
/**
* Returns a `uses` value for `action` pinned to a commit SHA, with the
@@ -747,6 +748,7 @@ function main(): void {
console.log(`Found ${checkFiles.length} check specification(s).`);
const generatedWorkflowNames: string[] = [];
const collections: Record<
string,
Array<{
@@ -834,6 +836,7 @@ function main(): void {
const outputPath = path.join(OUTPUT_DIR, `__${checkName}.yml`);
writeYaml(outputPath, workflow);
generatedWorkflowNames.push(workflow.name);
}
// Write workflow files for collections.
@@ -878,8 +881,11 @@ function main(): void {
const outputPath = path.join(OUTPUT_DIR, `__${collectionName}.yml`);
writeYaml(outputPath, collectionWorkflow);
generatedWorkflowNames.push(collectionWorkflow.name);
}
updateDeflakeWorkflow(generatedWorkflowNames);
console.log(
`\nDone. Wrote ${checkFiles.length} workflow file(s) to ${OUTPUT_DIR}`,
);
+4 -4
View File
@@ -1,6 +1,6 @@
{
"bundleVersion": "codeql-bundle-v2.27.5",
"cliVersion": "2.27.5",
"priorBundleVersion": "codeql-bundle-v2.27.4",
"priorCliVersion": "2.27.4"
"bundleVersion": "codeql-bundle-v2.27.6",
"cliVersion": "2.27.6",
"priorBundleVersion": "codeql-bundle-v2.27.5",
"priorCliVersion": "2.27.5"
}
+5 -5
View File
@@ -541,7 +541,7 @@ async function recordOverlayStatus(
// 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 job " +
"Not recording an overlay analysis failure for this job because the job " +
`status (${jobStatus ?? "unset"}) does not tell us whether the analysis itself failed.`,
);
return;
@@ -576,15 +576,15 @@ async function recordOverlayStatus(
);
const blurb =
"This job attempted to run with improved incremental analysis but it did not complete successfully. " +
"One possible reason for this is disk space constraints, since improved incremental analysis can " +
"This job attempted to run with overlay analysis but it did not complete successfully. " +
"One possible reason for this is disk space constraints, since overlay analysis can " +
"require a significant amount of disk space for some repositories.";
if (saved) {
logger.error(
`${blurb} ` +
"This failure has been recorded in the Actions cache, so the next CodeQL analysis will run " +
"without improved incremental analysis. If you want to enable improved incremental analysis, " +
"without overlay analysis. If you want to enable overlay analysis, " +
"try increasing the disk space available to the runner. " +
"If that doesn't help, contact GitHub Support for further assistance.",
);
@@ -592,7 +592,7 @@ async function recordOverlayStatus(
logger.error(
`${blurb} ` +
"The attempt to save this failure status to the Actions cache failed. The Action will attempt to " +
"run with improved incremental analysis again.",
"run with overlay analysis again.",
);
}
}
+68
View File
@@ -0,0 +1,68 @@
import test from "ava";
import { EnvVar } from "./environment";
import { GitHubVariant, type GitHubVersion } from "./github";
import { getFinalJobStatus } from "./init-action-post";
import { JobStatus } from "./status-report";
import { callee, createTestConfig, setupTests } from "./testing-utils";
setupTests(test);
const dotcom: GitHubVersion = { type: GitHubVariant.DOTCOM };
test("getFinalJobStatus reports a cancelled job status when the job was cancelled after init completed", async (t) => {
await callee(getFinalJobStatus)
.withArgs(createTestConfig({}), "cancelled", dotcom)
.passes(t.is, JobStatus.CancelledStatus);
});
test("getFinalJobStatus reports a cancelled job status when the job was cancelled before init completed", async (t) => {
await callee(getFinalJobStatus)
.withArgs(undefined, "cancelled", dotcom)
.passes(t.is, JobStatus.CancelledStatus);
});
test("getFinalJobStatus reports a cancelled job status on GitHub Enterprise Cloud with data residency", async (t) => {
await callee(getFinalJobStatus)
.withArgs(createTestConfig({}), "cancelled", {
type: GitHubVariant.GHEC_DR,
})
.passes(t.is, JobStatus.CancelledStatus);
});
test("getFinalJobStatus reports success when the job was cancelled after analyze completed", async (t) => {
await callee(getFinalJobStatus)
.withEnv((env) => {
env.set(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY, "true");
})
.withArgs(createTestConfig({}), "cancelled", dotcom)
.passes(t.is, JobStatus.SuccessStatus);
});
test("getFinalJobStatus reports the error from a CodeQL Action step when the job was cancelled afterwards", async (t) => {
await callee(getFinalJobStatus)
.withEnv((env) => {
env.set(EnvVar.JOB_STATUS, JobStatus.FailureStatus);
})
.withArgs(createTestConfig({}), "cancelled", dotcom)
.passes(t.is, JobStatus.FailureStatus);
});
test("getFinalJobStatus reports a configuration error when a step outside the CodeQL Action failed", async (t) => {
await callee(getFinalJobStatus)
.withArgs(createTestConfig({}), "failure", dotcom)
.passes(t.is, JobStatus.ConfigErrorStatus);
});
test("getFinalJobStatus doesn't report a cancelled job status on GitHub Enterprise Server", async (t) => {
const ghes: GitHubVersion = {
type: GitHubVariant.GHES,
version: "3.23.0",
};
await callee(getFinalJobStatus)
.withArgs(createTestConfig({}), "cancelled", ghes)
.passes(t.is, JobStatus.ConfigErrorStatus);
await callee(getFinalJobStatus)
.withArgs(undefined, "cancelled", ghes)
.passes(t.is, JobStatus.UnknownStatus);
});
+37 -11
View File
@@ -30,6 +30,7 @@ import {
import { EnvVar, type ReadOnlyEnv } from "./environment";
import { initFeatures } from "./feature-flags";
import * as gitUtils from "./git-utils";
import type { GitHubVersion } from "./github";
import * as initActionPostHelper from "./init-action-post-helper";
import { getRepositoryNwo } from "./repository";
import {
@@ -40,6 +41,7 @@ import {
ActionName,
getJobStatusDisplayName,
JobStatus,
supportsCancelledJobStatus,
} from "./status-report";
import { checkDiskUsage, checkGitHubVersionInRange, wrapError } from "./util";
@@ -55,7 +57,9 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
// possible, and only use safe functions outside.
const logger = action.logger;
let actionsJobStatus: string | undefined;
let config: Config | AbortedInitConfig | undefined;
let gitHubVersion: GitHubVersion;
let uploadFailedSarifResult:
initActionPostHelper.UploadFailedSarifResult | undefined;
let dependencyCachingUsage: DependencyCachingUsageReport | undefined;
@@ -64,7 +68,7 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
// 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");
actionsJobStatus = getOptionalInput("job-status");
// Restore inputs from `init` Action.
restoreInputs(logger);
@@ -82,7 +86,7 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
config = getAbortedInitConfig(action, tmpDir);
}
const gitHubVersion = config?.gitHubVersion ?? (await getGitHubVersion());
gitHubVersion = config?.gitHubVersion ?? (await getGitHubVersion());
checkGitHubVersionInRange(gitHubVersion, logger);
const repositoryNwo = getRepositoryNwo();
@@ -107,7 +111,7 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
config,
repositoryNwo,
features,
jobStatus,
actionsJobStatus,
action.env,
logger,
);
@@ -146,7 +150,12 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
}
return;
}
const jobStatus = getFinalJobStatus(action, config);
const jobStatus = getFinalJobStatus(
action,
config,
actionsJobStatus,
gitHubVersion,
);
logger.info(`CodeQL job status was ${getJobStatusDisplayName(jobStatus)}.`);
const statusReportBase = await createStatusReportBase(
@@ -175,11 +184,21 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
*
* If the job status has already been set by another step, we use that.
* Otherwise, we determine the job status based on whether the analyze step
* completed successfully and whether we have a valid CodeQL config.
* completed successfully, whether the job was cancelled, and whether we have a
* valid CodeQL config.
*
* Exported for testing.
*
* @param actionsJobStatus The status of the job, as reported by the Actions
* runtime environment.
* @param gitHubVersion The version of the GitHub instance that the status
* report is sent to.
*/
function getFinalJobStatus(
export function getFinalJobStatus(
action: ActionState<["Env"]>,
config: Partial<Config> | undefined,
actionsJobStatus: string | undefined,
gitHubVersion: GitHubVersion,
): JobStatus {
const existingJobStatus = getJobStatusFromEnvironment(action.env);
if (existingJobStatus !== undefined) {
@@ -193,21 +212,28 @@ function getFinalJobStatus(
) {
action.env.export(EnvVar.JOB_STATUS, JobStatus.SuccessStatus);
jobStatus = JobStatus.SuccessStatus;
} else if (
actionsJobStatus === "cancelled" &&
supportsCancelledJobStatus(gitHubVersion)
) {
// The job was cancelled before the analysis completed, and no CodeQL
// Action step reported an error.
jobStatus = JobStatus.CancelledStatus;
} else if (config !== undefined) {
// - We have computed a CodeQL config
// - Analyze didn't complete successfully
// - The job status hasn't already been set to Failure/ConfigurationError
//
// This means that something along the way failed in a step that is not
// owned by the Action, for example a manual build step. We consider this a
// configuration error.
// owned by the Action, for example a manual build step, or that the job
// was cancelled and the GitHub instance isn't known to accept
// `JobStatus.CancelledStatus`. We consider this a configuration error.
jobStatus = JobStatus.ConfigErrorStatus;
} else {
// If we didn't manage to compute a CodeQL config, it is unclear at this
// point why the analyze Action didn't complete.
// - One possibility is that the workflow run was cancelled. We could
// consider determining workflow cancellation using the GitHub API, but
// for now we treat all these cases as unknown.
// - One possibility is that the job was cancelled and the GitHub instance
// isn't known to accept `JobStatus.CancelledStatus`.
// - Another possibility is that we're running a workflow that only runs
// `init`, for instance a workflow that was created before `setup-codeql`
// was available and uses `init` just to set up the CodeQL tools.
+8 -8
View File
@@ -84,18 +84,18 @@ export async function addOverlayDisablementDiagnostics(
config,
makeDiagnostic(
"codeql-action/overlay-disabled-due-to-cached-status",
"Skipped improved incremental analysis because it failed previously with similar hardware resources",
"Skipped overlay analysis because it failed previously with similar hardware resources",
{
attributes: {
languages: config.languages,
},
markdownMessage:
`Improved incremental analysis was skipped because it previously failed for this repository ` +
`Overlay analysis was skipped because it previously failed for this repository ` +
`with CodeQL version ${(await codeql.getVersion()).version} on a runner with similar hardware resources. ` +
"One possible reason for this is that improved incremental analysis can require a significant amount of disk space for some repositories. " +
"If you want to try re-enabling improved incremental analysis, increase the disk space available " +
"One possible reason for this is that overlay analysis can require a significant amount of disk space for some repositories. " +
"If you want to try re-enabling overlay analysis, increase the disk space available " +
"to the runner. If that doesn't help, contact GitHub Support for further assistance.\n\n" +
"Improved incremental analysis will be automatically retried when the next version of CodeQL is released. " +
"Overlay analysis will be automatically retried when the next version of CodeQL is released. " +
`You can also manually trigger a retry by [removing](${DocUrl.DELETE_ACTIONS_CACHE_ENTRIES}) \`codeql-overlay-status-*\` entries from the Actions cache.`,
severity: "note",
visibility: {
@@ -115,15 +115,15 @@ export async function addOverlayDisablementDiagnostics(
config,
makeDiagnostic(
"codeql-action/overlay-disabled-by-repository-property",
"Improved incremental analysis disabled by repository property",
"Overlay analysis disabled by repository property",
{
attributes: {
languages: config.languages,
},
markdownMessage:
"Improved incremental analysis has been disabled because the " +
"Overlay analysis has been disabled because the " +
`\`${RepositoryPropertyName.DISABLE_OVERLAY}\` repository property is set to \`true\`. ` +
"To re-enable improved incremental analysis, set this property to `false` or remove it.",
"To re-enable overlay analysis, set this property to `false` or remove it.",
severity: "note",
visibility: {
cliSummaryTable: true,
+19 -1
View File
@@ -31,7 +31,7 @@ import {
exportEnvVar,
} from "./environment";
import { getRef } from "./git-utils";
import { GITHUB_DOTCOM_URL } from "./github";
import { GITHUB_DOTCOM_URL, GitHubVariant, type GitHubVersion } from "./github";
import * as json from "./json";
import type { Logger } from "./logging";
import type { OverlayBaseDatabaseDownloadStats } from "./overlay/caching";
@@ -137,6 +137,22 @@ export enum JobStatus {
SuccessStatus = "JOB_STATUS_SUCCESS",
FailureStatus = "JOB_STATUS_FAILURE",
ConfigErrorStatus = "JOB_STATUS_CONFIGURATION_ERROR",
/** The job was cancelled before the analysis completed. */
CancelledStatus = "JOB_STATUS_CANCELLED",
}
/**
* Whether the status report API of the GitHub instance is known to accept
* `JobStatus.CancelledStatus`. The API rejects status reports with a job status
* that it doesn't recognise.
*/
export function supportsCancelledJobStatus(
gitHubVersion: GitHubVersion,
): boolean {
return (
gitHubVersion.type === GitHubVariant.DOTCOM ||
gitHubVersion.type === GitHubVariant.GHEC_DR
);
}
export interface StatusReportBase {
@@ -268,6 +284,8 @@ export function getJobStatusDisplayName(status: JobStatus): string {
return "configuration error";
case JobStatus.UnknownStatus:
return "unknown";
case JobStatus.CancelledStatus:
return "cancelled";
default:
assertNever(status);
}