tests: instead of false, use old feature flag with default value of false
This commit is contained in:
parent
e6dd4048e9
commit
5445a29a97
30 changed files with 118 additions and 40 deletions
|
|
@ -17,6 +17,8 @@ import * as codeql from "./codeql";
|
|||
import { AugmentationProperties, Config } from "./config-utils";
|
||||
import * as defaults from "./defaults.json";
|
||||
import { DocUrl } from "./doc-url";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { initializeFeatures } from "./feature-flags.test";
|
||||
import { Language } from "./languages";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { ToolsSource } from "./setup-codeql";
|
||||
|
|
@ -39,6 +41,15 @@ setupTests(test);
|
|||
|
||||
let stubConfig: Config;
|
||||
|
||||
// TODO: Remove when when we no longer need to pass in features
|
||||
const expectedFeatureEnablement: FeatureEnablement = initializeFeatures(
|
||||
true,
|
||||
) as FeatureEnablement;
|
||||
expectedFeatureEnablement.getValue = function (feature: Feature) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return expectedFeatureEnablement[feature];
|
||||
};
|
||||
|
||||
test.beforeEach(() => {
|
||||
initializeEnvironment("1.2.3");
|
||||
|
||||
|
|
@ -70,6 +81,7 @@ async function installIntoToolcache({
|
|||
? { cliVersion, tagName }
|
||||
: SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
|
@ -129,6 +141,7 @@ test("downloads and caches explicitly requested bundles that aren't in the toolc
|
|||
util.GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
|
||||
|
|
@ -155,6 +168,7 @@ test("caches semantically versioned bundles using their semantic version number"
|
|||
util.GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
|
||||
|
|
@ -188,6 +202,7 @@ test("downloads an explicitly requested bundle even if a different version is ca
|
|||
util.GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||
|
|
@ -232,6 +247,7 @@ for (const {
|
|||
util.GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
t.assert(toolcache.find("CodeQL", expectedToolcacheVersion));
|
||||
|
|
@ -270,6 +286,7 @@ for (const toolcacheVersion of [
|
|||
util.GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
||||
|
|
@ -302,6 +319,7 @@ test(`uses a cached bundle when no tools input is given on GHES`, async (t) => {
|
|||
tagName: defaults.bundleVersion,
|
||||
},
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
t.deepEqual(result.toolsVersion, "0.0.0-20200601");
|
||||
|
|
@ -338,6 +356,7 @@ test(`downloads bundle if only an unpinned version is cached on GHES`, async (t)
|
|||
tagName: defaults.bundleVersion,
|
||||
},
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
t.deepEqual(result.toolsVersion, defaults.cliVersion);
|
||||
|
|
@ -371,6 +390,7 @@ test('downloads bundle if "latest" tools specified but not cached', async (t) =>
|
|||
util.GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
t.deepEqual(result.toolsVersion, defaults.cliVersion);
|
||||
|
|
@ -399,7 +419,6 @@ test("bundle URL from another repo is cached as 0.0.0-bundleVersion", async (t)
|
|||
platformSpecific: false,
|
||||
tagName: "codeql-bundle-20230203",
|
||||
});
|
||||
|
||||
const result = await codeql.setupCodeQL(
|
||||
"https://github.com/codeql-testing/codeql-cli-nightlies/releases/download/codeql-bundle-20230203/codeql-bundle.tar.gz",
|
||||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
|
|
@ -407,6 +426,7 @@ test("bundle URL from another repo is cached as 0.0.0-bundleVersion", async (t)
|
|||
util.GitHubVariant.DOTCOM,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
getRunnerLogger(true),
|
||||
expectedFeatureEnablement,
|
||||
false,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ export async function setupCodeQL(
|
|||
variant: util.GitHubVariant,
|
||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||
logger: Logger,
|
||||
features: FeatureEnablement,
|
||||
checkVersion: boolean,
|
||||
): Promise<{
|
||||
codeql: CodeQL;
|
||||
|
|
@ -364,6 +365,7 @@ export async function setupCodeQL(
|
|||
apiDetails,
|
||||
tempDir,
|
||||
variant,
|
||||
features,
|
||||
defaultCliVersion,
|
||||
logger,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ function assertAllFeaturesUndefinedInApi(
|
|||
}
|
||||
}
|
||||
|
||||
function initializeFeatures(initialValue: boolean) {
|
||||
export function initializeFeatures(initialValue: boolean) {
|
||||
return Object.keys(featureConfig).reduce((features, key) => {
|
||||
features[key] = initialValue;
|
||||
return features;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ export enum Feature {
|
|||
ExportDiagnosticsEnabled = "export_diagnostics_enabled",
|
||||
PythonDefaultIsToNotExtractStdlib = "python_default_is_to_not_extract_stdlib",
|
||||
QaTelemetryEnabled = "qa_telemetry_enabled",
|
||||
ZstdBundleStreamingExtraction = "zstd_bundle_streaming_extraction",
|
||||
}
|
||||
|
||||
export const featureConfig: Record<
|
||||
|
|
@ -107,6 +108,11 @@ export const featureConfig: Record<
|
|||
envVar: "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE",
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[Feature.ZstdBundleStreamingExtraction]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_ZSTD_BUNDLE_STREAMING_EXTRACTION",
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[Feature.CppDependencyInstallation]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ async function run() {
|
|||
getTemporaryDirectory(),
|
||||
gitHubVersion.type,
|
||||
codeQLDefaultVersionInfo,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
codeql = initCodeQLResult.codeql;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { getOptionalInput, isSelfHostedRunner } from "./actions-util";
|
|||
import { GitHubApiCombinedDetails, GitHubApiDetails } from "./api-client";
|
||||
import { CodeQL, setupCodeQL } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { CodeQLDefaultVersionInfo } from "./feature-flags";
|
||||
import { CodeQLDefaultVersionInfo, FeatureEnablement } from "./feature-flags";
|
||||
import { Language, isScannedLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { ToolsSource } from "./setup-codeql";
|
||||
|
|
@ -24,6 +24,7 @@ export async function initCodeQL(
|
|||
tempDir: string,
|
||||
variant: util.GitHubVariant,
|
||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||
features: FeatureEnablement,
|
||||
logger: Logger,
|
||||
): Promise<{
|
||||
codeql: CodeQL;
|
||||
|
|
@ -46,6 +47,7 @@ export async function initCodeQL(
|
|||
variant,
|
||||
defaultCliVersion,
|
||||
logger,
|
||||
features,
|
||||
true,
|
||||
);
|
||||
await codeql.printVersion();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import test from "ava";
|
|||
import * as sinon from "sinon";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { initializeFeatures } from "./feature-flags.test";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import * as setupCodeql from "./setup-codeql";
|
||||
import {
|
||||
|
|
@ -25,6 +27,14 @@ import {
|
|||
|
||||
setupTests(test);
|
||||
|
||||
// TODO: Remove when when we no longer need to pass in features
|
||||
const expectedFeatureEnablement: FeatureEnablement = initializeFeatures(
|
||||
true,
|
||||
) as FeatureEnablement;
|
||||
expectedFeatureEnablement.getValue = function (feature: Feature) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return expectedFeatureEnablement[feature];
|
||||
};
|
||||
test.beforeEach(() => {
|
||||
initializeEnvironment("1.2.3");
|
||||
});
|
||||
|
|
@ -174,6 +184,7 @@ test("setupCodeQLBundle logs the CodeQL CLI version being used when asked to use
|
|||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
"tmp/codeql_action_test/",
|
||||
GitHubVariant.DOTCOM,
|
||||
expectedFeatureEnablement,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
logger,
|
||||
);
|
||||
|
|
@ -224,6 +235,7 @@ test("setupCodeQLBundle logs the CodeQL CLI version being used when asked to dow
|
|||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
"tmp/codeql_action_test/",
|
||||
GitHubVariant.DOTCOM,
|
||||
expectedFeatureEnablement,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
logger,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import * as defaults from "./defaults.json";
|
|||
import {
|
||||
CODEQL_VERSION_ZSTD_BUNDLE,
|
||||
CodeQLDefaultVersionInfo,
|
||||
FeatureEnablement,
|
||||
} from "./feature-flags";
|
||||
import { formatDuration, Logger } from "./logging";
|
||||
import * as tar from "./tar";
|
||||
|
|
@ -504,6 +505,7 @@ export const downloadCodeQL = async function (
|
|||
apiDetails: api.GitHubApiDetails,
|
||||
tarVersion: tar.TarVersion | undefined,
|
||||
tempDir: string,
|
||||
features: FeatureEnablement,
|
||||
logger: Logger,
|
||||
): Promise<{
|
||||
codeqlFolder: string;
|
||||
|
|
@ -538,6 +540,7 @@ export const downloadCodeQL = async function (
|
|||
{ "User-Agent": "CodeQL Action", ...headers },
|
||||
tarVersion,
|
||||
tempDir,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
|
||||
|
|
@ -646,6 +649,7 @@ export async function setupCodeQLBundle(
|
|||
apiDetails: api.GitHubApiDetails,
|
||||
tempDir: string,
|
||||
variant: util.GitHubVariant,
|
||||
features: FeatureEnablement,
|
||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||
logger: Logger,
|
||||
) {
|
||||
|
|
@ -691,6 +695,7 @@ export async function setupCodeQLBundle(
|
|||
apiDetails,
|
||||
zstdAvailability.version,
|
||||
tempDir,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
toolsVersion = result.toolsVersion;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import * as toolcache from "@actions/tool-cache";
|
|||
import { https } from "follow-redirects";
|
||||
import { v4 as uuidV4 } from "uuid";
|
||||
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { formatDuration, Logger } from "./logging";
|
||||
import * as tar from "./tar";
|
||||
import { cleanUpGlob } from "./util";
|
||||
|
|
@ -76,6 +77,7 @@ export async function downloadAndExtract(
|
|||
headers: OutgoingHttpHeaders,
|
||||
tarVersion: tar.TarVersion | undefined,
|
||||
tempDir: string,
|
||||
features: FeatureEnablement,
|
||||
logger: Logger,
|
||||
): Promise<{
|
||||
extractedBundlePath: string;
|
||||
|
|
@ -88,8 +90,12 @@ export async function downloadAndExtract(
|
|||
const compressionMethod = tar.inferCompressionMethod(codeqlURL);
|
||||
|
||||
// TODO: Re-enable streaming when we have a more reliable way to respect proxy settings.
|
||||
// eslint-disable-next-line no-constant-condition, no-constant-binary-expression
|
||||
if (false && compressionMethod === "zstd" && process.platform === "linux") {
|
||||
|
||||
if (
|
||||
(await features.getValue(Feature.ZstdBundleStreamingExtraction)) &&
|
||||
compressionMethod === "zstd" &&
|
||||
process.platform === "linux"
|
||||
) {
|
||||
logger.info(`Streaming the extraction of the CodeQL bundle.`);
|
||||
|
||||
const toolsInstallStart = performance.now();
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ async function combineSarifFilesUsingCLI(
|
|||
tempDir,
|
||||
gitHubVersion.type,
|
||||
codeQLDefaultVersionInfo,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue