mirror of
https://github.com/github/codeql-action.git
synced 2026-11-05 04:29:40 +00:00
Use per-language bundles by default
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d9f196d4-6d15-44ca-bd01-cd022d57d2cc
This commit is contained in:
32
lib/entry-points.js
generated
32
lib/entry-points.js
generated
@@ -175692,11 +175692,7 @@ function getOtherLanguagePacksReason(inputs) {
|
||||
function findNonBuiltInQuery(queries) {
|
||||
return queries?.find((query) => !defaultSuites.has(query.uses))?.uses;
|
||||
}
|
||||
async function getPerLanguageBundleLanguage({
|
||||
env,
|
||||
features,
|
||||
logger: logger2
|
||||
}, options) {
|
||||
function getPerLanguageBundleLanguage({ env, logger: logger2 }, options) {
|
||||
const {
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
@@ -175710,9 +175706,6 @@ async function getPerLanguageBundleLanguage({
|
||||
logger2.debug(`Not using a per-language CodeQL bundle since ${reason}.`);
|
||||
return void 0;
|
||||
};
|
||||
if (!await features.getValue("per_language_bundles_v2" /* PerLanguageBundles */)) {
|
||||
return explain("the feature is disabled");
|
||||
}
|
||||
if (otherLanguagePacksReason !== void 0) {
|
||||
return explain(otherLanguagePacksReason);
|
||||
}
|
||||
@@ -176417,7 +176410,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, othe
|
||||
);
|
||||
}
|
||||
bundle = await getLatestNightlyBundle(
|
||||
{ env: getEnv(), features, logger: logger2 },
|
||||
{ env: getEnv(), logger: logger2 },
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
variant
|
||||
@@ -176584,17 +176577,14 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, othe
|
||||
compressionMethod = cliVersion2 !== void 0 && await useZstdBundle(cliVersion2, tarSupportsZstd) ? "zstd" : "gzip";
|
||||
const action = { env: getEnv(), logger: logger2 };
|
||||
const platform2 = getBundlePlatform();
|
||||
const perLanguageBundleLanguage = await getPerLanguageBundleLanguage(
|
||||
{ ...action, features },
|
||||
{
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
cliVersion: cliVersion2,
|
||||
compressionMethod,
|
||||
platform: platform2,
|
||||
variant
|
||||
}
|
||||
);
|
||||
const perLanguageBundleLanguage = getPerLanguageBundleLanguage(action, {
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
cliVersion: cliVersion2,
|
||||
compressionMethod,
|
||||
platform: platform2,
|
||||
variant
|
||||
});
|
||||
const resolveBundleURL = (language) => getCodeQLAssetDownloadURL(
|
||||
action,
|
||||
apiDetails,
|
||||
@@ -176869,7 +176859,7 @@ async function getLatestNightlyBundle(action, rawLanguages, otherLanguagePacksRe
|
||||
zstdAvailability.available
|
||||
) ? "zstd" : "gzip";
|
||||
const platform2 = getBundlePlatform();
|
||||
const language = await getPerLanguageBundleLanguage(action, {
|
||||
const language = getPerLanguageBundleLanguage(action, {
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
cliVersion: void 0,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import test from "ava";
|
||||
|
||||
import { ActionsEnvVars } from "./environment";
|
||||
import { Feature } from "./feature-flags";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import {
|
||||
getOtherLanguagePacksReason,
|
||||
@@ -12,7 +11,6 @@ import {
|
||||
} from "./per-language-bundles";
|
||||
import { BundlePlatform } from "./platform";
|
||||
import {
|
||||
createFeatures,
|
||||
getRecordingLogger,
|
||||
getTestEnv,
|
||||
initAllState,
|
||||
@@ -40,7 +38,6 @@ async function checkEligibility(
|
||||
env: getTestEnv({
|
||||
[ActionsEnvVars.RUNNER_ENVIRONMENT]: "github-hosted",
|
||||
}),
|
||||
features: createFeatures([Feature.PerLanguageBundles]),
|
||||
...stateOverrides,
|
||||
}),
|
||||
{ ...ELIGIBLE_OPTIONS, ...overrides },
|
||||
@@ -145,27 +142,6 @@ test("getPerLanguageBundleLanguage requires a supported release version", async
|
||||
t.is(await checkEligibility({ cliVersion: "2.27.1" }), BuiltInLanguage.java);
|
||||
});
|
||||
|
||||
test("getPerLanguageBundleLanguage requires the feature flag", async (t) => {
|
||||
t.is(await checkEligibility({}, { features: createFeatures([]) }), undefined);
|
||||
});
|
||||
|
||||
test("getPerLanguageBundleLanguage explains a disabled feature before checking eligibility", async (t) => {
|
||||
const messages: LoggedMessage[] = [];
|
||||
const language = await getPerLanguageBundleLanguage(
|
||||
initAllState({
|
||||
features: createFeatures([]),
|
||||
logger: getRecordingLogger(messages, { logToConsole: false }),
|
||||
}),
|
||||
{ ...ELIGIBLE_OPTIONS, rawLanguages: undefined, cliVersion: undefined },
|
||||
);
|
||||
|
||||
t.is(language, undefined);
|
||||
t.deepEqual(
|
||||
messages.map((message) => message.message),
|
||||
["Not using a per-language CodeQL bundle since the feature is disabled."],
|
||||
);
|
||||
});
|
||||
|
||||
test("getPerLanguageBundleLanguage skips only the release version check for the latest nightly", async (t) => {
|
||||
const nightly = { isLatestNightly: true, cliVersion: undefined };
|
||||
t.is(await checkEligibility(nightly), BuiltInLanguage.java);
|
||||
@@ -181,10 +157,6 @@ test("getPerLanguageBundleLanguage skips only the release version check for the
|
||||
]) {
|
||||
t.is(await checkEligibility({ ...nightly, ...overrides }), undefined);
|
||||
}
|
||||
t.is(
|
||||
await checkEligibility(nightly, { features: createFeatures([]) }),
|
||||
undefined,
|
||||
);
|
||||
t.is(
|
||||
await checkEligibility(nightly, {
|
||||
env: getTestEnv({ [ActionsEnvVars.RUNNER_ENVIRONMENT]: "self-hosted" }),
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
QuerySpec,
|
||||
UserConfig,
|
||||
} from "./config/db-config";
|
||||
import { Feature } from "./feature-flags";
|
||||
import { RepositoryPropertyName } from "./feature-flags/properties";
|
||||
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages";
|
||||
import { BundlePlatform } from "./platform";
|
||||
@@ -139,14 +138,10 @@ export interface PerLanguageBundleOptions {
|
||||
}
|
||||
|
||||
/** Returns the eligible bundle language, or undefined for the combined bundle. */
|
||||
export async function getPerLanguageBundleLanguage(
|
||||
{
|
||||
env,
|
||||
features,
|
||||
logger,
|
||||
}: ActionState<["Logger", "ReadOnlyEnv", "FeatureFlags"]>,
|
||||
export function getPerLanguageBundleLanguage(
|
||||
{ env, logger }: ActionState<["Logger", "ReadOnlyEnv"]>,
|
||||
options: PerLanguageBundleOptions,
|
||||
): Promise<BuiltInLanguage | undefined> {
|
||||
): BuiltInLanguage | undefined {
|
||||
const {
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
@@ -162,10 +157,6 @@ export async function getPerLanguageBundleLanguage(
|
||||
return undefined;
|
||||
};
|
||||
|
||||
if (!(await features.getValue(Feature.PerLanguageBundles))) {
|
||||
return explain("the feature is disabled");
|
||||
}
|
||||
|
||||
// A defined reason means the CodeQL CLI may need packs for other languages, for example because
|
||||
// of the configured queries. That applies whichever languages were requested, so check it first
|
||||
// to avoid suggesting that requesting a single language would be enough.
|
||||
|
||||
@@ -439,7 +439,7 @@ test.serial(
|
||||
tmpDir,
|
||||
GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
["javascript"],
|
||||
undefined, // rawLanguages
|
||||
undefined, // otherLanguagePacksReason
|
||||
false, // useOverlayAwareDefaultCliVersion
|
||||
features,
|
||||
@@ -633,7 +633,7 @@ for (const toolsInput of ["nightly", "nightly-latest"]) {
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
GitHubVariant.DOTCOM,
|
||||
true, // tarSupportsZstd
|
||||
createFeatures([Feature.PerLanguageBundles]),
|
||||
createFeatures([]),
|
||||
getRunnerLogger(true),
|
||||
);
|
||||
|
||||
@@ -664,24 +664,16 @@ test.serial(
|
||||
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
for (const { languages, otherLanguagePacksReason, features } of [
|
||||
// The per-language feature is disabled.
|
||||
{
|
||||
languages: ["java"],
|
||||
otherLanguagePacksReason: undefined,
|
||||
features: createFeatures([]),
|
||||
},
|
||||
for (const { languages, otherLanguagePacksReason } of [
|
||||
// More than one language requires a combined bundle.
|
||||
{
|
||||
languages: ["java", "python"],
|
||||
otherLanguagePacksReason: undefined,
|
||||
features: createFeatures([Feature.PerLanguageBundles]),
|
||||
},
|
||||
// The configured queries may need library packs for other languages.
|
||||
{
|
||||
languages: ["java"],
|
||||
otherLanguagePacksReason: "an example reason",
|
||||
features: createFeatures([Feature.PerLanguageBundles]),
|
||||
},
|
||||
]) {
|
||||
const source = await setupCodeql.getCodeQLSource(
|
||||
@@ -693,7 +685,7 @@ test.serial(
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
GitHubVariant.DOTCOM,
|
||||
true, // tarSupportsZstd
|
||||
features,
|
||||
createFeatures([]),
|
||||
getRunnerLogger(true),
|
||||
);
|
||||
|
||||
@@ -709,58 +701,48 @@ test.serial(
|
||||
},
|
||||
);
|
||||
|
||||
for (const perLanguageBundles of [false, true]) {
|
||||
test.serial(
|
||||
`getCodeQLSource uses the latest ${perLanguageBundles ? "per-language" : "combined"} bundle for a forced nightly`,
|
||||
async (t) => {
|
||||
const expectedTag = "codeql-bundle-30260213";
|
||||
const baseURL = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/${expectedTag}`;
|
||||
const latestNightlyRequest = stubHostedNightly(expectedTag);
|
||||
test.serial(
|
||||
"getCodeQLSource uses the latest per-language bundle for a forced nightly",
|
||||
async (t) => {
|
||||
const expectedTag = "codeql-bundle-30260213";
|
||||
const baseURL = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/${expectedTag}`;
|
||||
const latestNightlyRequest = stubHostedNightly(expectedTag);
|
||||
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
setupActionsVars(tmpDir, tmpDir, { GITHUB_EVENT_NAME: "dynamic" });
|
||||
const source = await setupCodeql.getCodeQLSource(
|
||||
undefined, // toolsInput: the nightly is selected by ForceNightly
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
["java"],
|
||||
undefined, // otherLanguagePacksReason
|
||||
false, // useOverlayAwareDefaultCliVersion
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
GitHubVariant.DOTCOM,
|
||||
true, // tarSupportsZstd
|
||||
createFeatures(
|
||||
perLanguageBundles
|
||||
? [Feature.ForceNightly, Feature.PerLanguageBundles]
|
||||
: [Feature.ForceNightly],
|
||||
),
|
||||
getRunnerLogger(true),
|
||||
);
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
setupActionsVars(tmpDir, tmpDir, { GITHUB_EVENT_NAME: "dynamic" });
|
||||
const source = await setupCodeql.getCodeQLSource(
|
||||
undefined, // toolsInput: the nightly is selected by ForceNightly
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
["java"],
|
||||
undefined, // otherLanguagePacksReason
|
||||
false, // useOverlayAwareDefaultCliVersion
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
GitHubVariant.DOTCOM,
|
||||
true, // tarSupportsZstd
|
||||
createFeatures([Feature.ForceNightly]),
|
||||
getRunnerLogger(true),
|
||||
);
|
||||
|
||||
t.is(source.sourceType, "download");
|
||||
t.true(latestNightlyRequest.calledOnce);
|
||||
if (source.sourceType === "download") {
|
||||
const combinedURL = `${baseURL}/codeql-bundle-linux64.tar.zst`;
|
||||
t.deepEqual(
|
||||
source.bundle,
|
||||
perLanguageBundles
|
||||
? {
|
||||
kind: "per-language",
|
||||
language: BuiltInLanguage.java,
|
||||
url: `${baseURL}/codeql-bundle-java-linux64.tar.zst`,
|
||||
combinedBundleURL: combinedURL,
|
||||
}
|
||||
: { kind: "combined", url: combinedURL },
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
t.is(source.sourceType, "download");
|
||||
t.true(latestNightlyRequest.calledOnce);
|
||||
if (source.sourceType === "download") {
|
||||
t.deepEqual(source.bundle, {
|
||||
kind: "per-language",
|
||||
language: BuiltInLanguage.java,
|
||||
url: `${baseURL}/codeql-bundle-java-linux64.tar.zst`,
|
||||
combinedBundleURL: `${baseURL}/codeql-bundle-linux64.tar.zst`,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
for (const date of ["20200101", "30260213"]) {
|
||||
for (const bundle of ["combined", "per-language"] as const) {
|
||||
test.serial(
|
||||
`getCodeQLSource preserves an explicit ${bundle} nightly URL for ${date}`,
|
||||
`getCodeQLSource preserves an explicit ${bundle} nightly URL for ${date}${
|
||||
bundle === "per-language" ? " on GHES" : ""
|
||||
}`,
|
||||
async (t) => {
|
||||
const latestNightlyRequest = stubHostedNightly(
|
||||
"codeql-bundle-30260213",
|
||||
@@ -770,7 +752,9 @@ for (const date of ["20200101", "30260213"]) {
|
||||
? "codeql-bundle-linux64.tar.zst"
|
||||
: "codeql-bundle-java-linux64.tar.zst";
|
||||
const url = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/codeql-bundle-${date}/${asset}`;
|
||||
const features = createFeatures([Feature.PerLanguageBundles]);
|
||||
const features = createFeatures([]);
|
||||
const variant =
|
||||
bundle === "per-language" ? GitHubVariant.GHES : GitHubVariant.DOTCOM;
|
||||
const logger = getRecordingLogger([], { logToConsole: false });
|
||||
const error = new HTTPError("Not Found", 404);
|
||||
const extractStub = sinon
|
||||
@@ -786,7 +770,7 @@ for (const date of ["20200101", "30260213"]) {
|
||||
undefined, // otherLanguagePacksReason
|
||||
false,
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
GitHubVariant.DOTCOM,
|
||||
variant,
|
||||
true,
|
||||
features,
|
||||
logger,
|
||||
@@ -808,7 +792,7 @@ for (const date of ["20200101", "30260213"]) {
|
||||
url,
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
tmpDir,
|
||||
GitHubVariant.DOTCOM,
|
||||
variant,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
["java"],
|
||||
undefined, // otherLanguagePacksReason
|
||||
@@ -1174,7 +1158,7 @@ test.serial(
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
GitHubVariant.DOTCOM,
|
||||
true, // tarSupportsZstd
|
||||
createFeatures([Feature.PerLanguageBundles]),
|
||||
createFeatures([]),
|
||||
getRunnerLogger(true),
|
||||
);
|
||||
|
||||
@@ -1207,13 +1191,16 @@ test.serial(
|
||||
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
for (const { otherLanguagePacksReason, features } of [
|
||||
// The per-language feature is disabled.
|
||||
{ otherLanguagePacksReason: undefined, features: createFeatures([]) },
|
||||
for (const { otherLanguagePacksReason, variant } of [
|
||||
// Automatic per-language selection is limited to GitHub.com.
|
||||
{
|
||||
otherLanguagePacksReason: undefined,
|
||||
variant: GitHubVariant.GHES,
|
||||
},
|
||||
// The configured queries may need library packs for other languages.
|
||||
{
|
||||
otherLanguagePacksReason: "an example reason",
|
||||
features: createFeatures([Feature.PerLanguageBundles]),
|
||||
variant: GitHubVariant.DOTCOM,
|
||||
},
|
||||
]) {
|
||||
const source = await setupCodeql.getCodeQLSource(
|
||||
@@ -1223,9 +1210,9 @@ test.serial(
|
||||
otherLanguagePacksReason,
|
||||
false, // useOverlayAwareDefaultCliVersion
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
GitHubVariant.DOTCOM,
|
||||
variant,
|
||||
true, // tarSupportsZstd
|
||||
features,
|
||||
createFeatures([]),
|
||||
getRunnerLogger(true),
|
||||
);
|
||||
|
||||
@@ -1295,7 +1282,7 @@ for (const fallback of [false, true]) {
|
||||
["java"],
|
||||
undefined, // otherLanguagePacksReason
|
||||
false, // useOverlayAwareDefaultCliVersion
|
||||
createFeatures([Feature.PerLanguageBundles]),
|
||||
createFeatures([]),
|
||||
getRunnerLogger(true),
|
||||
);
|
||||
|
||||
@@ -1375,7 +1362,7 @@ for (const bundle of ["per-language", "combined", "fallback"] as const) {
|
||||
};
|
||||
});
|
||||
const addDiagnostic = sinon.stub(diagnostics, "addNoLanguageDiagnostic");
|
||||
const features = createFeatures([Feature.PerLanguageBundles]);
|
||||
const features = createFeatures([]);
|
||||
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
@@ -1560,7 +1547,7 @@ for (const error of [
|
||||
["java"],
|
||||
undefined, // otherLanguagePacksReason
|
||||
false, // useOverlayAwareDefaultCliVersion
|
||||
createFeatures([Feature.PerLanguageBundles]),
|
||||
createFeatures([]),
|
||||
getRunnerLogger(true),
|
||||
),
|
||||
{ is: error },
|
||||
|
||||
@@ -408,7 +408,7 @@ export async function getCodeQLSource(
|
||||
);
|
||||
}
|
||||
bundle = await getLatestNightlyBundle(
|
||||
{ env: getEnv(), features, logger },
|
||||
{ env: getEnv(), logger },
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
variant,
|
||||
@@ -651,17 +651,14 @@ export async function getCodeQLSource(
|
||||
|
||||
const action = { env: getEnv(), logger };
|
||||
const platform = getBundlePlatform();
|
||||
const perLanguageBundleLanguage = await getPerLanguageBundleLanguage(
|
||||
{ ...action, features },
|
||||
{
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
cliVersion,
|
||||
compressionMethod,
|
||||
platform,
|
||||
variant,
|
||||
},
|
||||
);
|
||||
const perLanguageBundleLanguage = getPerLanguageBundleLanguage(action, {
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
cliVersion,
|
||||
compressionMethod,
|
||||
platform,
|
||||
variant,
|
||||
});
|
||||
|
||||
// Resolves the combined or per-language bundle URL for the requested release.
|
||||
const resolveBundleURL = (language?: BuiltInLanguage) =>
|
||||
@@ -1089,7 +1086,7 @@ function getTempExtractionDir(tempDir: string) {
|
||||
* Records the combined bundle URL from that release for use if the selected asset is missing.
|
||||
*/
|
||||
async function getLatestNightlyBundle(
|
||||
action: ActionState<["Logger", "ReadOnlyEnv", "FeatureFlags"]>,
|
||||
action: ActionState<["Logger", "ReadOnlyEnv"]>,
|
||||
rawLanguages: string[] | undefined,
|
||||
otherLanguagePacksReason: string | undefined,
|
||||
variant: util.GitHubVariant,
|
||||
@@ -1105,7 +1102,7 @@ async function getLatestNightlyBundle(
|
||||
: "gzip";
|
||||
|
||||
const platform = getBundlePlatform();
|
||||
const language = await getPerLanguageBundleLanguage(action, {
|
||||
const language = getPerLanguageBundleLanguage(action, {
|
||||
rawLanguages,
|
||||
otherLanguagePacksReason,
|
||||
cliVersion: undefined,
|
||||
|
||||
Reference in New Issue
Block a user