Compare commits

...

7 Commits

Author SHA1 Message Date
Michael B. Gale c175619770 Regenerate JS files 2026-02-04 19:27:56 +00:00
Michael B. Gale 796f1f4bd8 Tolerate NoSourceCodeSeen errors in CCR 2026-02-04 19:25:43 +00:00
Michael B. Gale 90379d9b6f Add files to copy to empty-ish test project 2026-02-04 19:25:41 +00:00
Michael B. Gale c9149684ff Add empty project to CCR test, and limit CLI versions 2026-02-04 19:25:41 +00:00
Michael B. Gale 8ddcd326f1 Support customising test directories in PR check specs 2026-02-04 19:25:41 +00:00
Michael B. Gale 32c67450a1 Add test-directory input to prepare-test action 2026-02-04 19:25:41 +00:00
Michael B. Gale 0437a6d257 Add an empty test folder 2026-02-04 19:25:41 +00:00
20 changed files with 227 additions and 30 deletions
+7 -1
View File
@@ -12,6 +12,10 @@ inputs:
description: "If true, we setup kotlin"
default: 'true'
required: true
test-directory:
description: "The directory containing the test project that should be moved to the workspace root"
required: false
default: "tests/multi-language-repo"
outputs:
tools-url:
description: "The value that should be passed as the 'tools' input of the 'init' step."
@@ -21,10 +25,12 @@ runs:
steps:
- name: Move codeql-action
shell: bash
env:
TEST_DIR: ${{ inputs.test-directory }}
run: |
mkdir ../action
mv * .github ../action/
mv ../action/tests/multi-language-repo/{*,.github} .
mv ../action/$TEST_DIR/{*,.github} .
mv ../action/.github/workflows .github
- id: get-url
name: Determine URL
+4 -15
View File
@@ -37,23 +37,11 @@ jobs:
matrix:
include:
- os: ubuntu-latest
version: stable-v2.17.6
- os: ubuntu-latest
version: stable-v2.18.4
- os: ubuntu-latest
version: stable-v2.19.4
- os: ubuntu-latest
version: stable-v2.20.7
- os: ubuntu-latest
version: stable-v2.21.4
- os: ubuntu-latest
version: stable-v2.22.4
- os: ubuntu-latest
version: default
version: linked
test-directory: tests/multi-language-repo
- os: ubuntu-latest
version: linked
- os: ubuntu-latest
version: nightly-latest
test-directory: tests/empty-repo
name: CCR
if: github.triggering_actor != 'dependabot[bot]'
permissions:
@@ -71,6 +59,7 @@ jobs:
version: ${{ matrix.version }}
use-all-platform-bundle: 'false'
setup-kotlin: 'true'
test-directory: ${{ matrix.test-directory }}
- uses: ./../action/init
id: init
with:
+17
View File
@@ -142861,6 +142861,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -142949,6 +142950,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -142962,6 +142973,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+19 -1
View File
@@ -105443,6 +105443,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -105531,6 +105532,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -105544,6 +105555,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
@@ -111530,7 +111547,8 @@ async function run(startedAt2) {
core14.exportVariable("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */, "true");
} catch (unwrappedError) {
const error3 = wrapError(unwrappedError);
if (getOptionalInput("expect-error") !== "true" || hasBadExpectErrorInput()) {
const tolerateErrorForCCR = isCCR() && error3 instanceof ToleratedConfigurationError;
if (!tolerateErrorForCCR && (getOptionalInput("expect-error") !== "true" || hasBadExpectErrorInput())) {
core14.setFailed(error3.message);
}
await sendStatusReport2(
+17
View File
@@ -102023,6 +102023,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -102111,6 +102112,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -102124,6 +102135,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+17
View File
@@ -146182,6 +146182,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -146270,6 +146271,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -146283,6 +146294,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+17
View File
@@ -105276,6 +105276,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -105364,6 +105365,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -105377,6 +105388,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+17
View File
@@ -102022,6 +102022,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -102110,6 +102111,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -102123,6 +102134,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+17
View File
@@ -102946,6 +102946,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -103034,6 +103035,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -103047,6 +103058,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+1
View File
@@ -143012,6 +143012,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
+17
View File
@@ -105056,6 +105056,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -105144,6 +105145,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -105157,6 +105168,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+1
View File
@@ -142696,6 +142696,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
+17
View File
@@ -106224,6 +106224,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -106312,6 +106313,16 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
category;
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -106325,6 +106336,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+2
View File
@@ -1,5 +1,7 @@
name: "CCR"
description: "A standard analysis in CCR mode"
testDirectories: ["tests/multi-language-repo", "tests/empty-repo"]
versions: ["linked"]
env:
CODEQL_ACTION_ANALYSIS_KEY: "dynamic/copilot-pull-request-reviewer/codeql-action-test"
steps:
+24 -11
View File
@@ -83,10 +83,18 @@ for file in sorted((this_dir / 'checks').glob('*.yml')):
runnerImagesForOs = [image for image in runnerImages if image.startswith(operatingSystem)]
for runnerImage in runnerImagesForOs:
matrix.append({
'os': runnerImage,
'version': version
})
if 'testDirectories' in checkSpecification:
for testDirectory in checkSpecification.get('testDirectories'):
matrix.append({
'os': runnerImage,
'version': version,
'test-directory': testDirectory
})
else:
matrix.append({
'os': runnerImage,
'version': version
})
useAllPlatformBundle = "false" # Default to false
if checkSpecification.get('useAllPlatformBundle'):
@@ -129,17 +137,22 @@ for file in sorted((this_dir / 'checks').glob('*.yml')):
},
])
prepareWith = {
'version': '${{ matrix.version }}',
'use-all-platform-bundle': useAllPlatformBundle,
# If the action is being run from a container, then do not setup kotlin.
# This is because the kotlin binaries cannot be downloaded from the container.
'setup-kotlin': str(not 'container' in checkSpecification).lower(),
}
if 'testDirectories' in checkSpecification:
prepareWith['test-directory'] = '${{ matrix.test-directory }}'
steps.append({
'name': 'Prepare test',
'id': 'prepare-test',
'uses': './.github/actions/prepare-test',
'with': {
'version': '${{ matrix.version }}',
'use-all-platform-bundle': useAllPlatformBundle,
# If the action is being run from a container, then do not setup kotlin.
# This is because the kotlin binaries cannot be downloaded from the container.
'setup-kotlin': str(not 'container' in checkSpecification).lower(),
}
'with': prepareWith,
})
installGo = is_truthy(checkSpecification.get('installGo', ''))
+10 -2
View File
@@ -18,6 +18,7 @@ import {
import { getApiDetails, getGitHubVersion } from "./api-client";
import { runAutobuild } from "./autobuild";
import { getTotalCacheSize, shouldStoreCache } from "./caching-utils";
import { ToleratedConfigurationError } from "./cli-errors";
import { getCodeQL } from "./codeql";
import { Config, getConfig } from "./config-utils";
import {
@@ -450,9 +451,16 @@ async function run(startedAt: Date) {
core.exportVariable(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY, "true");
} catch (unwrappedError) {
const error = util.wrapError(unwrappedError);
const tolerateErrorForCCR =
actionsUtil.isCCR() && error instanceof ToleratedConfigurationError;
// Set the outcome of the action as failed if we are not expecting an error,
// or the `expect-error` value is invalid.
if (
actionsUtil.getOptionalInput("expect-error") !== "true" ||
hasBadExpectErrorInput()
!tolerateErrorForCCR &&
(actionsUtil.getOptionalInput("expect-error") !== "true" ||
hasBadExpectErrorInput())
) {
core.setFailed(error.message);
}
+22
View File
@@ -153,6 +153,7 @@ type CliErrorConfiguration = {
cliErrorMessageCandidates: RegExp[];
exitCode?: number;
additionalErrorMessageToAppend?: string;
toleratedByCCR?: boolean;
};
/**
@@ -228,6 +229,7 @@ const cliErrorsConfig: Record<CliConfigErrorCategory, CliErrorConfiguration> = {
// was unintended to have CodeQL analysis run on it.
[CliConfigErrorCategory.NoSourceCodeSeen]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it",
@@ -345,6 +347,20 @@ function getUnsupportedPlatformError(cliError: CliError): ConfigurationError {
);
}
export class ToleratedConfigurationError extends ConfigurationError {
private category: CliConfigErrorCategory;
constructor(category: CliConfigErrorCategory, message: string) {
super(message);
this.category = category;
}
public getCategory(): CliConfigErrorCategory {
return this.category;
}
}
/**
* Changes an error received from the CLI to a ConfigurationError with the message
* optionally being transformed, if it is a known configuration error. Otherwise,
@@ -368,5 +384,11 @@ export function wrapCliConfigurationError(cliError: CliError): Error {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder,
);
}
return new ConfigurationError(errorMessageBuilder);
}
View File
View File
+1
View File
@@ -0,0 +1 @@
This test folder is intentionally left (almost) empty.