Merge pull request #2129 from github/henrymercer/java-buildless-rollback
Introduce a rollback mechanism for Java buildless
This commit is contained in:
commit
95d258ab1c
14 changed files with 272 additions and 23 deletions
89
.github/workflows/__build-mode-rollback.yml
generated
vendored
Normal file
89
.github/workflows/__build-mode-rollback.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# Warning: This file is generated automatically, and should not be modified.
|
||||
# Instead, please modify the template in the pr-checks directory and run:
|
||||
# (cd pr-checks; pip install ruamel.yaml@0.17.31 && python3 sync.py)
|
||||
# to regenerate this file.
|
||||
|
||||
name: PR Check - Build mode rollback
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GO111MODULE: auto
|
||||
CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN: 'true'
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- releases/v*
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
- ready_for_review
|
||||
workflow_dispatch: {}
|
||||
jobs:
|
||||
build-mode-rollback:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
version: nightly-latest
|
||||
name: Build mode rollback
|
||||
permissions:
|
||||
contents: read
|
||||
security-events: write
|
||||
timeout-minutes: 45
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Setup Python on MacOS
|
||||
uses: actions/setup-python@v5
|
||||
if: >-
|
||||
matrix.os == 'macos-latest' && (
|
||||
|
||||
matrix.version == 'stable-20221211' ||
|
||||
|
||||
matrix.version == 'stable-20230418' ||
|
||||
|
||||
matrix.version == 'stable-v2.13.5' ||
|
||||
|
||||
matrix.version == 'stable-v2.14.6')
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Prepare test
|
||||
id: prepare-test
|
||||
uses: ./.github/actions/prepare-test
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
use-all-platform-bundle: 'false'
|
||||
- name: Set environment variable for Swift enablement
|
||||
if: runner.os != 'Windows' && matrix.version == '20221211'
|
||||
shell: bash
|
||||
run: echo "CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT=true" >> $GITHUB_ENV
|
||||
- name: Set up Java test repo configuration
|
||||
run: |
|
||||
mv * .github ../action/tests/multi-language-repo/
|
||||
mv ../action/tests/multi-language-repo/.github/workflows .github
|
||||
mv ../action/tests/java-repo/* .
|
||||
|
||||
- uses: ./../action/init
|
||||
id: init
|
||||
with:
|
||||
build-mode: none
|
||||
db-location: ${{ runner.temp }}/customDbLocation
|
||||
languages: java
|
||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||
|
||||
- name: Validate database build mode
|
||||
run: |
|
||||
metadata_path="$RUNNER_TEMP/customDbLocation/java/codeql-database.yml"
|
||||
build_mode=$(yq eval '.buildMode' "$metadata_path")
|
||||
if [[ "$build_mode" != "autobuild" ]]; then
|
||||
echo "Expected build mode to be 'autobuild' but was $build_mode"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- uses: ./../action/analyze
|
||||
env:
|
||||
CODEQL_ACTION_DISABLE_JAVA_BUILDLESS: true
|
||||
CODEQL_ACTION_TEST_MODE: true
|
||||
30
lib/config-utils.js
generated
30
lib/config-utils.js
generated
|
|
@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.wrapEnvironment = exports.generateRegistries = exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.validatePackSpecification = exports.parsePacksSpecification = exports.parsePacksFromInput = exports.calculateAugmentation = exports.getDefaultConfig = exports.getRawLanguages = exports.getLanguageAliases = exports.getLanguages = exports.getLanguagesInRepo = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getPacksStrInvalid = exports.defaultAugmentationProperties = exports.BuildMode = void 0;
|
||||
exports.parseBuildModeInput = exports.wrapEnvironment = exports.generateRegistries = exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.validatePackSpecification = exports.parsePacksSpecification = exports.parsePacksFromInput = exports.calculateAugmentation = exports.getDefaultConfig = exports.getRawLanguages = exports.getLanguageAliases = exports.getLanguages = exports.getLanguagesInRepo = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getPacksStrInvalid = exports.defaultAugmentationProperties = exports.BuildMode = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const perf_hooks_1 = require("perf_hooks");
|
||||
|
|
@ -31,6 +31,7 @@ const yaml = __importStar(require("js-yaml"));
|
|||
const semver = __importStar(require("semver"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const codeql_1 = require("./codeql");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
const trap_caching_1 = require("./trap-caching");
|
||||
const util_1 = require("./util");
|
||||
|
|
@ -218,13 +219,14 @@ exports.getRawLanguages = getRawLanguages;
|
|||
/**
|
||||
* Get the default config for when the user has not supplied one.
|
||||
*/
|
||||
async function getDefaultConfig({ languagesInput, queriesInput, packsInput, buildModeInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, githubVersion, logger, }) {
|
||||
async function getDefaultConfig({ languagesInput, queriesInput, packsInput, buildModeInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, githubVersion, features, logger, }) {
|
||||
const languages = await getLanguages(codeql, languagesInput, repository, logger);
|
||||
const buildMode = await parseBuildModeInput(buildModeInput, languages, features, logger);
|
||||
const augmentationProperties = calculateAugmentation(packsInput, queriesInput, languages);
|
||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
|
||||
return {
|
||||
languages,
|
||||
buildMode: validateBuildModeInput(buildModeInput),
|
||||
buildMode,
|
||||
originalUserInput: {},
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
@ -252,7 +254,7 @@ async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logg
|
|||
/**
|
||||
* Load the config from the given file.
|
||||
*/
|
||||
async function loadConfig({ languagesInput, queriesInput, packsInput, buildModeInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, workspacePath, githubVersion, apiDetails, logger, }) {
|
||||
async function loadConfig({ languagesInput, queriesInput, packsInput, buildModeInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, workspacePath, githubVersion, apiDetails, features, logger, }) {
|
||||
let parsedYAML;
|
||||
if (isLocal(configFile)) {
|
||||
// Treat the config file as relative to the workspace
|
||||
|
|
@ -263,11 +265,12 @@ async function loadConfig({ languagesInput, queriesInput, packsInput, buildModeI
|
|||
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
||||
}
|
||||
const languages = await getLanguages(codeql, languagesInput, repository, logger);
|
||||
const buildMode = await parseBuildModeInput(buildModeInput, languages, features, logger);
|
||||
const augmentationProperties = calculateAugmentation(packsInput, queriesInput, languages);
|
||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
|
||||
return {
|
||||
languages,
|
||||
buildMode: validateBuildModeInput(buildModeInput),
|
||||
buildMode,
|
||||
originalUserInput: parsedYAML,
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
@ -664,13 +667,20 @@ async function wrapEnvironment(env, operation) {
|
|||
}
|
||||
}
|
||||
exports.wrapEnvironment = wrapEnvironment;
|
||||
function validateBuildModeInput(buildModeInput) {
|
||||
if (buildModeInput === undefined) {
|
||||
// Exported for testing
|
||||
async function parseBuildModeInput(input, languages, features, logger) {
|
||||
if (input === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (!Object.values(BuildMode).includes(buildModeInput)) {
|
||||
throw new util_1.ConfigurationError(`Invalid build mode: '${buildModeInput}'. Supported build modes are: ${Object.values(BuildMode).join(", ")}.`);
|
||||
if (!Object.values(BuildMode).includes(input)) {
|
||||
throw new util_1.ConfigurationError(`Invalid build mode: '${input}'. Supported build modes are: ${Object.values(BuildMode).join(", ")}.`);
|
||||
}
|
||||
return buildModeInput;
|
||||
if (languages.includes(languages_1.Language.java) &&
|
||||
(await features.getValue(feature_flags_1.Feature.DisableJavaBuildlessEnabled))) {
|
||||
logger.warning("Scanning Java code without a build is temporarily unavailable. Falling back to 'autobuild' build mode.");
|
||||
return BuildMode.Autobuild;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
exports.parseBuildModeInput = parseBuildModeInput;
|
||||
//# sourceMappingURL=config-utils.js.map
|
||||
File diff suppressed because one or more lines are too long
25
lib/config-utils.test.js
generated
25
lib/config-utils.test.js
generated
|
|
@ -36,6 +36,7 @@ const api = __importStar(require("./api-client"));
|
|||
const codeql_1 = require("./codeql");
|
||||
const configUtils = __importStar(require("./config-utils"));
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
|
|
@ -68,6 +69,7 @@ function createTestInitConfigInputs(overrides) {
|
|||
apiURL: undefined,
|
||||
registriesAuthTokens: undefined,
|
||||
},
|
||||
features: (0, testing_utils_1.createFeatures)([]),
|
||||
logger: (0, logging_1.getRunnerLogger)(true),
|
||||
}, overrides);
|
||||
}
|
||||
|
|
@ -763,4 +765,27 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
|
|||
t.deepEqual(mockRequest.called, args.expectedApiCall);
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("Build mode not overridden when disable Java buildless feature flag disabled", async (t) => {
|
||||
const messages = [];
|
||||
const buildMode = await configUtils.parseBuildModeInput("none", [languages_1.Language.java], (0, testing_utils_1.createFeatures)([]), (0, testing_utils_1.getRecordingLogger)(messages));
|
||||
t.is(buildMode, config_utils_1.BuildMode.None);
|
||||
t.deepEqual(messages, []);
|
||||
});
|
||||
(0, ava_1.default)("Build mode not overridden for other languages", async (t) => {
|
||||
const messages = [];
|
||||
const buildMode = await configUtils.parseBuildModeInput("none", [languages_1.Language.python], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.DisableJavaBuildlessEnabled]), (0, testing_utils_1.getRecordingLogger)(messages));
|
||||
t.is(buildMode, config_utils_1.BuildMode.None);
|
||||
t.deepEqual(messages, []);
|
||||
});
|
||||
(0, ava_1.default)("Build mode overridden when analyzing Java and disable Java buildless feature flag enabled", async (t) => {
|
||||
const messages = [];
|
||||
const buildMode = await configUtils.parseBuildModeInput("none", [languages_1.Language.java], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.DisableJavaBuildlessEnabled]), (0, testing_utils_1.getRecordingLogger)(messages));
|
||||
t.is(buildMode, config_utils_1.BuildMode.Autobuild);
|
||||
t.deepEqual(messages, [
|
||||
{
|
||||
message: "Scanning Java code without a build is temporarily unavailable. Falling back to 'autobuild' build mode.",
|
||||
type: "warning",
|
||||
},
|
||||
]);
|
||||
});
|
||||
//# sourceMappingURL=config-utils.test.js.map
|
||||
File diff suppressed because one or more lines are too long
6
lib/feature-flags.js
generated
6
lib/feature-flags.js
generated
|
|
@ -50,6 +50,7 @@ var Feature;
|
|||
(function (Feature) {
|
||||
Feature["CppDependencyInstallation"] = "cpp_dependency_installation_enabled";
|
||||
Feature["CppTrapCachingEnabled"] = "cpp_trap_caching_enabled";
|
||||
Feature["DisableJavaBuildlessEnabled"] = "disable_java_buildless_enabled";
|
||||
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
|
||||
Feature["DisablePythonDependencyInstallationEnabled"] = "disable_python_dependency_installation_enabled";
|
||||
Feature["PythonDefaultIsToSkipDependencyInstallationEnabled"] = "python_default_is_to_skip_dependency_installation_enabled";
|
||||
|
|
@ -68,6 +69,11 @@ exports.featureConfig = {
|
|||
minimumVersion: "2.16.1",
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.DisableJavaBuildlessEnabled]: {
|
||||
envVar: "CODEQL_ACTION_DISABLE_JAVA_BUILDLESS",
|
||||
minimumVersion: undefined,
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.DisableKotlinAnalysisEnabled]: {
|
||||
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
||||
minimumVersion: undefined,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
1
lib/init-action.js
generated
1
lib/init-action.js
generated
|
|
@ -157,6 +157,7 @@ async function run() {
|
|||
workspacePath: (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"),
|
||||
githubVersion: gitHubVersion,
|
||||
apiDetails,
|
||||
features,
|
||||
logger,
|
||||
});
|
||||
await (0, init_1.checkInstallPython311)(config.languages, codeql);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
31
pr-checks/checks/build-mode-rollback.yml
Normal file
31
pr-checks/checks/build-mode-rollback.yml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
name: "Build mode rollback"
|
||||
description: "The build mode is rolled back from none to autobuild when the relevant feature flag is enabled."
|
||||
operatingSystems: ["ubuntu"]
|
||||
versions: ["nightly-latest"]
|
||||
env:
|
||||
CODEQL_ACTION_DISABLE_JAVA_BUILDLESS: true
|
||||
steps:
|
||||
- name: Set up Java test repo configuration
|
||||
run: |
|
||||
mv * .github ../action/tests/multi-language-repo/
|
||||
mv ../action/tests/multi-language-repo/.github/workflows .github
|
||||
mv ../action/tests/java-repo/* .
|
||||
|
||||
- uses: ./../action/init
|
||||
id: init
|
||||
with:
|
||||
build-mode: none
|
||||
db-location: "${{ runner.temp }}/customDbLocation"
|
||||
languages: java
|
||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||
|
||||
- name: Validate database build mode
|
||||
run: |
|
||||
metadata_path="$RUNNER_TEMP/customDbLocation/java/codeql-database.yml"
|
||||
build_mode=$(yq eval '.buildMode' "$metadata_path")
|
||||
if [[ "$build_mode" != "autobuild" ]]; then
|
||||
echo "Expected build mode to be 'autobuild' but was $build_mode"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- uses: ./../action/analyze
|
||||
|
|
@ -15,12 +15,16 @@ import {
|
|||
} from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { BuildMode } from "./config-utils";
|
||||
import { Feature } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import {
|
||||
setupTests,
|
||||
mockLanguagesInRepo as mockLanguagesInRepo,
|
||||
createFeatures,
|
||||
getRecordingLogger,
|
||||
LoggedMessage,
|
||||
} from "./testing-utils";
|
||||
import {
|
||||
GitHubVariant,
|
||||
|
|
@ -63,6 +67,7 @@ function createTestInitConfigInputs(
|
|||
apiURL: undefined,
|
||||
registriesAuthTokens: undefined,
|
||||
},
|
||||
features: createFeatures([]),
|
||||
logger: getRunnerLogger(true),
|
||||
},
|
||||
overrides,
|
||||
|
|
@ -1080,3 +1085,45 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
|||
t.deepEqual(mockRequest.called, args.expectedApiCall);
|
||||
});
|
||||
});
|
||||
|
||||
test("Build mode not overridden when disable Java buildless feature flag disabled", async (t) => {
|
||||
const messages: LoggedMessage[] = [];
|
||||
const buildMode = await configUtils.parseBuildModeInput(
|
||||
"none",
|
||||
[Language.java],
|
||||
createFeatures([]),
|
||||
getRecordingLogger(messages),
|
||||
);
|
||||
t.is(buildMode, BuildMode.None);
|
||||
t.deepEqual(messages, []);
|
||||
});
|
||||
|
||||
test("Build mode not overridden for other languages", async (t) => {
|
||||
const messages: LoggedMessage[] = [];
|
||||
const buildMode = await configUtils.parseBuildModeInput(
|
||||
"none",
|
||||
[Language.python],
|
||||
createFeatures([Feature.DisableJavaBuildlessEnabled]),
|
||||
getRecordingLogger(messages),
|
||||
);
|
||||
t.is(buildMode, BuildMode.None);
|
||||
t.deepEqual(messages, []);
|
||||
});
|
||||
|
||||
test("Build mode overridden when analyzing Java and disable Java buildless feature flag enabled", async (t) => {
|
||||
const messages: LoggedMessage[] = [];
|
||||
const buildMode = await configUtils.parseBuildModeInput(
|
||||
"none",
|
||||
[Language.java],
|
||||
createFeatures([Feature.DisableJavaBuildlessEnabled]),
|
||||
getRecordingLogger(messages),
|
||||
);
|
||||
t.is(buildMode, BuildMode.Autobuild);
|
||||
t.deepEqual(messages, [
|
||||
{
|
||||
message:
|
||||
"Scanning Java code without a build is temporarily unavailable. Falling back to 'autobuild' build mode.",
|
||||
type: "warning",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import * as semver from "semver";
|
|||
|
||||
import * as api from "./api-client";
|
||||
import { CodeQL, CODEQL_VERSION_LANGUAGE_ALIASING } from "./codeql";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { Language, parseLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
|
|
@ -420,6 +421,7 @@ export interface InitConfigInputs {
|
|||
workspacePath: string;
|
||||
githubVersion: GitHubVersion;
|
||||
apiDetails: api.GitHubApiCombinedDetails;
|
||||
features: FeatureEnablement;
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
|
|
@ -449,6 +451,7 @@ export async function getDefaultConfig({
|
|||
tempDir,
|
||||
codeql,
|
||||
githubVersion,
|
||||
features,
|
||||
logger,
|
||||
}: GetDefaultConfigInputs): Promise<Config> {
|
||||
const languages = await getLanguages(
|
||||
|
|
@ -457,6 +460,14 @@ export async function getDefaultConfig({
|
|||
repository,
|
||||
logger,
|
||||
);
|
||||
|
||||
const buildMode = await parseBuildModeInput(
|
||||
buildModeInput,
|
||||
languages,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
|
||||
const augmentationProperties = calculateAugmentation(
|
||||
packsInput,
|
||||
queriesInput,
|
||||
|
|
@ -472,7 +483,7 @@ export async function getDefaultConfig({
|
|||
|
||||
return {
|
||||
languages,
|
||||
buildMode: validateBuildModeInput(buildModeInput),
|
||||
buildMode,
|
||||
originalUserInput: {},
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
@ -526,6 +537,7 @@ async function loadConfig({
|
|||
workspacePath,
|
||||
githubVersion,
|
||||
apiDetails,
|
||||
features,
|
||||
logger,
|
||||
}: LoadConfigInputs): Promise<Config> {
|
||||
let parsedYAML: UserConfig;
|
||||
|
|
@ -545,6 +557,13 @@ async function loadConfig({
|
|||
logger,
|
||||
);
|
||||
|
||||
const buildMode = await parseBuildModeInput(
|
||||
buildModeInput,
|
||||
languages,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
|
||||
const augmentationProperties = calculateAugmentation(
|
||||
packsInput,
|
||||
queriesInput,
|
||||
|
|
@ -560,7 +579,7 @@ async function loadConfig({
|
|||
|
||||
return {
|
||||
languages,
|
||||
buildMode: validateBuildModeInput(buildModeInput),
|
||||
buildMode,
|
||||
originalUserInput: parsedYAML,
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
@ -1070,19 +1089,33 @@ export async function wrapEnvironment(
|
|||
}
|
||||
}
|
||||
|
||||
function validateBuildModeInput(
|
||||
buildModeInput: string | undefined,
|
||||
): BuildMode | undefined {
|
||||
if (buildModeInput === undefined) {
|
||||
// Exported for testing
|
||||
export async function parseBuildModeInput(
|
||||
input: string | undefined,
|
||||
languages: Language[],
|
||||
features: FeatureEnablement,
|
||||
logger: Logger,
|
||||
): Promise<BuildMode | undefined> {
|
||||
if (input === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!Object.values(BuildMode).includes(buildModeInput as BuildMode)) {
|
||||
if (!Object.values(BuildMode).includes(input as BuildMode)) {
|
||||
throw new ConfigurationError(
|
||||
`Invalid build mode: '${buildModeInput}'. Supported build modes are: ${Object.values(
|
||||
`Invalid build mode: '${input}'. Supported build modes are: ${Object.values(
|
||||
BuildMode,
|
||||
).join(", ")}.`,
|
||||
);
|
||||
}
|
||||
return buildModeInput as BuildMode;
|
||||
|
||||
if (
|
||||
languages.includes(Language.java) &&
|
||||
(await features.getValue(Feature.DisableJavaBuildlessEnabled))
|
||||
) {
|
||||
logger.warning(
|
||||
"Scanning Java code without a build is temporarily unavailable. Falling back to 'autobuild' build mode.",
|
||||
);
|
||||
return BuildMode.Autobuild;
|
||||
}
|
||||
return input as BuildMode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ export interface FeatureEnablement {
|
|||
export enum Feature {
|
||||
CppDependencyInstallation = "cpp_dependency_installation_enabled",
|
||||
CppTrapCachingEnabled = "cpp_trap_caching_enabled",
|
||||
DisableJavaBuildlessEnabled = "disable_java_buildless_enabled",
|
||||
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
||||
DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled",
|
||||
PythonDefaultIsToSkipDependencyInstallationEnabled = "python_default_is_to_skip_dependency_installation_enabled",
|
||||
|
|
@ -68,6 +69,11 @@ export const featureConfig: Record<
|
|||
minimumVersion: "2.16.1",
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.DisableJavaBuildlessEnabled]: {
|
||||
envVar: "CODEQL_ACTION_DISABLE_JAVA_BUILDLESS",
|
||||
minimumVersion: undefined,
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.DisableKotlinAnalysisEnabled]: {
|
||||
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
||||
minimumVersion: undefined,
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ async function run() {
|
|||
workspacePath: getRequiredEnvParam("GITHUB_WORKSPACE"),
|
||||
githubVersion: gitHubVersion,
|
||||
apiDetails,
|
||||
features,
|
||||
logger,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue