mirror of
https://github.com/github/codeql-action.git
synced 2026-01-03 05:00:04 +08:00
Add feature flag for zstd bundles
This commit is contained in:
25
lib/setup-codeql.js
generated
25
lib/setup-codeql.js
generated
@@ -48,6 +48,7 @@ const api = __importStar(require("./api-client"));
|
||||
// creation scripts. Ensure that any changes to the format of this file are compatible with both of
|
||||
// these dependents.
|
||||
const defaults = __importStar(require("./defaults.json"));
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
var ToolsSource;
|
||||
@@ -59,7 +60,7 @@ var ToolsSource;
|
||||
})(ToolsSource || (exports.ToolsSource = ToolsSource = {}));
|
||||
exports.CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
|
||||
const CODEQL_BUNDLE_VERSION_ALIAS = ["linked", "latest"];
|
||||
function getCodeQLBundleName() {
|
||||
function getCodeQLBundleBaseName() {
|
||||
let platform;
|
||||
if (process.platform === "win32") {
|
||||
platform = "win64";
|
||||
@@ -71,9 +72,15 @@ function getCodeQLBundleName() {
|
||||
platform = "osx64";
|
||||
}
|
||||
else {
|
||||
return "codeql-bundle.tar.gz";
|
||||
return "codeql-bundle";
|
||||
}
|
||||
return `codeql-bundle-${platform}.tar.gz`;
|
||||
return `codeql-bundle-${platform}`;
|
||||
}
|
||||
async function getCodeQLBundleName(features) {
|
||||
if (await features.getValue(feature_flags_1.Feature.ZstdBundle)) {
|
||||
return `${getCodeQLBundleBaseName()}.tar.zst`;
|
||||
}
|
||||
return `${getCodeQLBundleBaseName()}.tar.gz`;
|
||||
}
|
||||
function getCodeQLActionRepository(logger) {
|
||||
if ((0, actions_util_1.isRunningLocalAction)()) {
|
||||
@@ -85,7 +92,7 @@ function getCodeQLActionRepository(logger) {
|
||||
}
|
||||
return util.getRequiredEnvParam("GITHUB_ACTION_REPOSITORY");
|
||||
}
|
||||
async function getCodeQLBundleDownloadURL(tagName, apiDetails, logger) {
|
||||
async function getCodeQLBundleDownloadURL(tagName, apiDetails, features, logger) {
|
||||
const codeQLActionRepository = getCodeQLActionRepository(logger);
|
||||
const potentialDownloadSources = [
|
||||
// This GitHub instance, and this Action.
|
||||
@@ -100,7 +107,7 @@ async function getCodeQLBundleDownloadURL(tagName, apiDetails, logger) {
|
||||
const uniqueDownloadSources = potentialDownloadSources.filter((source, index, self) => {
|
||||
return !self.slice(0, index).some((other) => (0, fast_deep_equal_1.default)(source, other));
|
||||
});
|
||||
const codeQLBundleName = getCodeQLBundleName();
|
||||
const codeQLBundleName = await getCodeQLBundleName(features);
|
||||
for (const downloadSource of uniqueDownloadSources) {
|
||||
const [apiURL, repository] = downloadSource;
|
||||
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
|
||||
@@ -192,7 +199,7 @@ async function findOverridingToolsInCache(humanReadableVersion, logger) {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, logger) {
|
||||
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, features, logger) {
|
||||
if (toolsInput &&
|
||||
!CODEQL_BUNDLE_VERSION_ALIAS.includes(toolsInput) &&
|
||||
!toolsInput.startsWith("http")) {
|
||||
@@ -334,7 +341,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
||||
}
|
||||
}
|
||||
if (!url) {
|
||||
url = await getCodeQLBundleDownloadURL(tagName, apiDetails, logger);
|
||||
url = await getCodeQLBundleDownloadURL(tagName, apiDetails, features, logger);
|
||||
}
|
||||
if (cliVersion) {
|
||||
logger.info(`Using CodeQL CLI version ${cliVersion} sourced from ${url}.`);
|
||||
@@ -473,8 +480,8 @@ function getCanonicalToolcacheVersion(cliVersion, bundleVersion, logger) {
|
||||
* version requirement. Must be set to true outside tests.
|
||||
* @returns the path to the extracted bundle, and the version of the tools
|
||||
*/
|
||||
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, logger) {
|
||||
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, logger);
|
||||
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger) {
|
||||
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, features, logger);
|
||||
let codeqlFolder;
|
||||
let toolsVersion = source.toolsVersion;
|
||||
let toolsDownloadStatusReport;
|
||||
|
||||
Reference in New Issue
Block a user