Send tools telemetry to `init` status report (#1497)
Co-authored-by: Henry Mercer <henry.mercer@me.com>
This commit is contained in:
Родитель
ebf6415a7d
Коммит
24ca6b0400
|
@ -110,7 +110,7 @@ exports.CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES = "2.10.3";
|
|||
*/
|
||||
async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger, checkVersion) {
|
||||
try {
|
||||
const { codeqlFolder, toolsVersion } = await setupCodeql.setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger);
|
||||
const { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion } = await setupCodeql.setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger);
|
||||
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
||||
if (process.platform === "win32") {
|
||||
codeqlCmd += ".exe";
|
||||
|
@ -119,7 +119,12 @@ async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, bypassToolc
|
|||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
cachedCodeQL = await getCodeQLForCmd(codeqlCmd, checkVersion);
|
||||
return { codeql: cachedCodeQL, toolsVersion };
|
||||
return {
|
||||
codeql: cachedCodeQL,
|
||||
toolsDownloadDurationMs,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
logger.error(e instanceof Error ? e : new Error(String(e)));
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -42,6 +42,7 @@ const api = __importStar(require("./api-client"));
|
|||
const codeql = __importStar(require("./codeql"));
|
||||
const defaults = __importStar(require("./defaults.json"));
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const init_1 = require("./init");
|
||||
const languages_1 = require("./languages");
|
||||
const logging_1 = require("./logging");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
|
@ -155,6 +156,8 @@ function mockApiDetails(apiDetails) {
|
|||
const result = await codeql.setupCodeQL(url, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||
t.is(result.toolsVersion, `0.0.0-${version}`);
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
}
|
||||
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
||||
});
|
||||
|
@ -173,6 +176,8 @@ function mockApiDetails(apiDetails) {
|
|||
const result = await codeql.setupCodeQL(url, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
||||
t.not(result.toolsDownloadDurationMs, undefined);
|
||||
});
|
||||
});
|
||||
const EXPLICITLY_REQUESTED_BUNDLE_TEST_CASES = [
|
||||
|
@ -206,6 +211,8 @@ for (const { cliVersion, expectedToolcacheVersion, } of EXPLICITLY_REQUESTED_BUN
|
|||
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
|
||||
t.assert(toolcache.find("CodeQL", expectedToolcacheVersion));
|
||||
t.deepEqual(result.toolsVersion, cliVersion);
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
||||
t.not(result.toolsDownloadDurationMs, undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -261,6 +268,14 @@ for (const { isCached, tagName, toolcacheCliVersion } of [
|
|||
}
|
||||
const result = await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
||||
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
||||
if (isCached) {
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Toolcache);
|
||||
t.is(result.toolsDownloadDurationMs, undefined);
|
||||
}
|
||||
else {
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -279,6 +294,8 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
|||
variant,
|
||||
}, (0, logging_1.getRunnerLogger)(true), false);
|
||||
t.deepEqual(result.toolsVersion, "0.0.0-20200601");
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Toolcache);
|
||||
t.is(result.toolsDownloadDurationMs, undefined);
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
|
@ -300,6 +317,8 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
|||
variant,
|
||||
}, (0, logging_1.getRunnerLogger)(true), false);
|
||||
t.deepEqual(result.toolsVersion, defaults.cliVersion);
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 2);
|
||||
});
|
||||
|
@ -318,6 +337,8 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
|||
});
|
||||
const result = await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
||||
t.deepEqual(result.toolsVersion, defaults.cliVersion);
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 2);
|
||||
});
|
||||
|
@ -348,11 +369,13 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
|||
mockApiDetails(sampleGHAEApiDetails);
|
||||
sinon.stub(actionsUtil, "isRunningLocalAction").returns(false);
|
||||
process.env["GITHUB_ACTION_REPOSITORY"] = "github/codeql-action";
|
||||
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, util.GitHubVariant.GHAE, false, {
|
||||
const result = await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, util.GitHubVariant.GHAE, false, {
|
||||
cliVersion: defaults.cliVersion,
|
||||
tagName: defaults.bundleVersion,
|
||||
variant: util.GitHubVariant.GHAE,
|
||||
}, (0, logging_1.getRunnerLogger)(true), false);
|
||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -154,8 +154,10 @@ class GitHubFeatureFlags {
|
|||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === util.GitHubVariant.DOTCOM) {
|
||||
const defaultDotComCliVersion = await this.getDefaultDotcomCliVersion();
|
||||
return {
|
||||
cliVersion: await this.getDefaultDotcomCliVersion(),
|
||||
cliVersion: defaultDotComCliVersion.version,
|
||||
toolsFeatureFlagsValid: defaultDotComCliVersion.toolsFeatureFlagsValid,
|
||||
variant,
|
||||
};
|
||||
}
|
||||
|
@ -184,11 +186,14 @@ class GitHubFeatureFlags {
|
|||
// version that would have been specified by the feature flags before they were misconfigured.
|
||||
this.logger.warning("Feature flags do not specify a default CLI version. Falling back to the CLI version " +
|
||||
`shipped with the Action. This is ${defaults.cliVersion}.`);
|
||||
return defaults.cliVersion;
|
||||
return {
|
||||
version: defaults.cliVersion,
|
||||
toolsFeatureFlagsValid: false,
|
||||
};
|
||||
}
|
||||
const maxCliVersion = enabledFeatureFlagCliVersions.reduce((maxVersion, currentVersion) => currentVersion > maxVersion ? currentVersion : maxVersion, enabledFeatureFlagCliVersions[0]);
|
||||
this.logger.debug(`Derived default CLI version of ${maxCliVersion} from feature flags.`);
|
||||
return maxCliVersion;
|
||||
return { version: maxCliVersion, toolsFeatureFlagsValid: true };
|
||||
}
|
||||
async getValue(feature) {
|
||||
const response = await this.getAllFeatures();
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -217,7 +217,8 @@ for (const variant of [util_1.GitHubVariant.GHAE, util_1.GitHubVariant.GHES]) {
|
|||
(0, ava_1.default)(`selects CLI from defaults.json on ${util_1.GitHubVariant[variant]}`, async (t) => {
|
||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
t.deepEqual(await features.getDefaultCliVersion(variant), {
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: defaults.cliVersion,
|
||||
tagName: defaults.bundleVersion,
|
||||
variant,
|
||||
|
@ -236,8 +237,10 @@ for (const variant of [util_1.GitHubVariant.GHAE, util_1.GitHubVariant.GHES]) {
|
|||
expectedFeatureEnablement["default_codeql_version_2_12_4_enabled"] = false;
|
||||
expectedFeatureEnablement["default_codeql_version_2_12_5_enabled"] = false;
|
||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
|
||||
t.deepEqual(await featureEnablement.getDefaultCliVersion(util_1.GitHubVariant.DOTCOM), {
|
||||
const defaultCliVersion = await featureEnablement.getDefaultCliVersion(util_1.GitHubVariant.DOTCOM);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.12.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
variant: util_1.GitHubVariant.DOTCOM,
|
||||
});
|
||||
});
|
||||
|
@ -247,8 +250,10 @@ for (const variant of [util_1.GitHubVariant.GHAE, util_1.GitHubVariant.GHES]) {
|
|||
const featureEnablement = setUpFeatureFlagTests(tmpDir);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
|
||||
t.deepEqual(await featureEnablement.getDefaultCliVersion(util_1.GitHubVariant.DOTCOM), {
|
||||
const defaultCliVersion = await featureEnablement.getDefaultCliVersion(util_1.GitHubVariant.DOTCOM);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: defaults.cliVersion,
|
||||
toolsFeatureFlagsValid: false,
|
||||
variant: util_1.GitHubVariant.DOTCOM,
|
||||
});
|
||||
});
|
||||
|
@ -263,8 +268,10 @@ for (const variant of [util_1.GitHubVariant.GHAE, util_1.GitHubVariant.GHES]) {
|
|||
expectedFeatureEnablement["default_codeql_version_2_12_invalid_enabled"] =
|
||||
true;
|
||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
|
||||
t.deepEqual(await featureEnablement.getDefaultCliVersion(util_1.GitHubVariant.DOTCOM), {
|
||||
const defaultCliVersion = await featureEnablement.getDefaultCliVersion(util_1.GitHubVariant.DOTCOM);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.12.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
variant: util_1.GitHubVariant.DOTCOM,
|
||||
});
|
||||
t.assert(loggedMessages.find((v) => v.type === "warning" &&
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -36,10 +36,25 @@ const repository_1 = require("./repository");
|
|||
const trap_caching_1 = require("./trap-caching");
|
||||
const util_1 = require("./util");
|
||||
const workflow_1 = require("./workflow");
|
||||
async function sendSuccessStatusReport(startedAt, config, toolsVersion, logger) {
|
||||
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("init", "success", startedAt);
|
||||
const languages = config.languages.join(",");
|
||||
async function sendInitStatusReport(actionStatus, startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger) {
|
||||
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("init", actionStatus, startedAt);
|
||||
const workflowLanguages = (0, actions_util_1.getOptionalInput)("languages");
|
||||
const initStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: (0, actions_util_1.getOptionalInput)("tools") || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || init_1.ToolsSource.Unknown,
|
||||
workflow_languages: workflowLanguages || "",
|
||||
};
|
||||
let initToolsDownloadFields = {};
|
||||
if (toolsSource === init_1.ToolsSource.Download) {
|
||||
initToolsDownloadFields = {
|
||||
tools_download_duration_ms: toolsDownloadDurationMs,
|
||||
tools_feature_flags_valid: toolsFeatureFlagsValid,
|
||||
};
|
||||
}
|
||||
if (config !== undefined) {
|
||||
const languages = config.languages.join(",");
|
||||
const paths = (config.originalUserInput.paths || []).join(",");
|
||||
const pathsIgnore = (config.originalUserInput["paths-ignore"] || []).join(",");
|
||||
const disableDefaultQueries = config.originalUserInput["disable-default-queries"]
|
||||
|
@ -56,22 +71,27 @@ async function sendSuccessStatusReport(startedAt, config, toolsVersion, logger)
|
|||
: queriesInput;
|
||||
queries.push(...queriesInput.split(","));
|
||||
}
|
||||
const statusReport = {
|
||||
...statusReportBase,
|
||||
// Append fields that are dependent on `config`
|
||||
const initWithConfigStatusReport = {
|
||||
...initStatusReport,
|
||||
disable_default_queries: disableDefaultQueries,
|
||||
languages,
|
||||
ml_powered_javascript_queries: (0, util_1.getMlPoweredJsQueriesStatus)(config),
|
||||
paths,
|
||||
paths_ignore: pathsIgnore,
|
||||
queries: queries.join(","),
|
||||
tools_input: (0, actions_util_1.getOptionalInput)("tools") || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
workflow_languages: workflowLanguages || "",
|
||||
trap_cache_languages: Object.keys(config.trapCaches).join(","),
|
||||
trap_cache_download_size_bytes: Math.round(await (0, trap_caching_1.getTotalCacheSize)(config.trapCaches, logger)),
|
||||
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
||||
};
|
||||
await (0, actions_util_1.sendStatusReport)(statusReport);
|
||||
await (0, actions_util_1.sendStatusReport)({
|
||||
...initWithConfigStatusReport,
|
||||
...initToolsDownloadFields,
|
||||
});
|
||||
}
|
||||
else {
|
||||
await (0, actions_util_1.sendStatusReport)({ ...initStatusReport, ...initToolsDownloadFields });
|
||||
}
|
||||
}
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
|
@ -79,6 +99,9 @@ async function run() {
|
|||
(0, util_1.initializeEnvironment)((0, actions_util_1.getActionVersion)());
|
||||
let config;
|
||||
let codeql;
|
||||
let toolsDownloadDurationMs;
|
||||
let toolsFeatureFlagsValid;
|
||||
let toolsSource;
|
||||
let toolsVersion;
|
||||
const apiDetails = {
|
||||
auth: (0, actions_util_1.getRequiredInput)("token"),
|
||||
|
@ -95,10 +118,15 @@ async function run() {
|
|||
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) {
|
||||
return;
|
||||
}
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(gitHubVersion.type);
|
||||
const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), gitHubVersion.type, await (0, util_1.shouldBypassToolcache)(features, (0, actions_util_1.getOptionalInput)("tools"), (0, actions_util_1.getOptionalInput)("languages"), repositoryNwo, logger), defaultCliVersion, logger);
|
||||
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(gitHubVersion.type);
|
||||
if (codeQLDefaultVersionInfo.variant === util_1.GitHubVariant.DOTCOM) {
|
||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||
}
|
||||
const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), gitHubVersion.type, await (0, util_1.shouldBypassToolcache)(features, (0, actions_util_1.getOptionalInput)("tools"), (0, actions_util_1.getOptionalInput)("languages"), repositoryNwo, logger), codeQLDefaultVersionInfo, logger);
|
||||
codeql = initCodeQLResult.codeql;
|
||||
toolsDownloadDurationMs = initCodeQLResult.toolsDownloadDurationMs;
|
||||
toolsVersion = initCodeQLResult.toolsVersion;
|
||||
toolsSource = initCodeQLResult.toolsSource;
|
||||
await (0, util_1.enrichEnvironment)(codeql);
|
||||
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("registries"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), await getTrapCachingEnabled(features),
|
||||
// Debug mode is enabled if:
|
||||
|
@ -159,10 +187,10 @@ async function run() {
|
|||
catch (error) {
|
||||
core.setFailed(String(error));
|
||||
console.log(error);
|
||||
await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", (0, actions_util_1.getActionsStatus)(error), startedAt, String(error), error instanceof Error ? error.stack : undefined));
|
||||
await sendInitStatusReport((0, actions_util_1.getActionsStatus)(error), startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
|
||||
return;
|
||||
}
|
||||
await sendSuccessStatusReport(startedAt, config, toolsVersion, logger);
|
||||
await sendInitStatusReport("success", startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
|
||||
}
|
||||
async function getTrapCachingEnabled(featureEnablement) {
|
||||
// If the workflow specified something always respect that
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.installPythonDeps = exports.injectWindowsTracer = exports.runInit = exports.initConfig = exports.initCodeQL = void 0;
|
||||
exports.installPythonDeps = exports.injectWindowsTracer = exports.runInit = exports.initConfig = exports.initCodeQL = exports.ToolsSource = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||
|
@ -34,12 +34,19 @@ const configUtils = __importStar(require("./config-utils"));
|
|||
const tracer_config_1 = require("./tracer-config");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
var ToolsSource;
|
||||
(function (ToolsSource) {
|
||||
ToolsSource["Unknown"] = "UNKNOWN";
|
||||
ToolsSource["Local"] = "LOCAL";
|
||||
ToolsSource["Toolcache"] = "TOOLCACHE";
|
||||
ToolsSource["Download"] = "DOWNLOAD";
|
||||
})(ToolsSource = exports.ToolsSource || (exports.ToolsSource = {}));
|
||||
async function initCodeQL(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger) {
|
||||
logger.startGroup("Setup CodeQL tools");
|
||||
const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger, true);
|
||||
const { codeql, toolsDownloadDurationMs, toolsSource, toolsVersion } = await (0, codeql_1.setupCodeQL)(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger, true);
|
||||
await codeql.printVersion();
|
||||
logger.endGroup();
|
||||
return { codeql, toolsVersion };
|
||||
return { codeql, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||
}
|
||||
exports.initCodeQL = initCodeQL;
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, registriesInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAI9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,UAA8B,EAC9B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,eAAwB,EACxB,iBAA2C,EAC3C,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AAvBD,gCAuBC;AAEM,KAAK,UAAU,UAAU,CAC9B,cAAkC,EAClC,YAAgC,EAChC,UAA8B,EAC9B,eAAmC,EACnC,UAA8B,EAC9B,UAA8B,EAC9B,kBAA2B,EAC3B,SAAkB,EAClB,iBAAyB,EACzB,iBAAyB,EACzB,UAAyB,EACzB,OAAe,EACf,MAAc,EACd,aAAqB,EACrB,aAAiC,EACjC,UAAoC,EACpC,iBAAoC,EACpC,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CACzC,cAAc,EACd,YAAY,EACZ,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,kBAAkB,E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rG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"}
|
|
@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.setupCodeQLBundle = exports.getCodeQLURLVersion = exports.downloadCodeQL = exports.getCodeQLSource = exports.convertToSemVer = exports.getBundleVersionFromUrl = exports.tryFindCliVersionDotcomOnly = exports.findCodeQLBundleTagDotcomOnly = exports.getCodeQLActionRepository = exports.CODEQL_DEFAULT_ACTION_REPOSITORY = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const perf_hooks_1 = require("perf_hooks");
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
||||
const semver = __importStar(require("semver"));
|
||||
|
@ -39,6 +40,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 init_1 = require("./init");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
exports.CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
|
||||
|
@ -415,7 +417,9 @@ async function downloadCodeQL(codeqlURL, maybeCliVersion, apiDetails, variant, t
|
|||
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
|
||||
const dest = path.join(tempDir, (0, uuid_1.v4)());
|
||||
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
|
||||
const toolsDownloadStart = perf_hooks_1.performance.now();
|
||||
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, undefined, finalHeaders);
|
||||
const toolsDownloadDurationMs = perf_hooks_1.performance.now() - toolsDownloadStart;
|
||||
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
const bundleVersion = getBundleVersionFromUrl(codeqlURL);
|
||||
|
@ -439,6 +443,7 @@ async function downloadCodeQL(codeqlURL, maybeCliVersion, apiDetails, variant, t
|
|||
return {
|
||||
toolsVersion: cliVersion || toolcacheVersion,
|
||||
codeqlFolder: await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion),
|
||||
toolsDownloadDurationMs,
|
||||
};
|
||||
}
|
||||
exports.downloadCodeQL = downloadCodeQL;
|
||||
|
@ -468,24 +473,30 @@ async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, bypas
|
|||
const source = await getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, apiDetails, variant, logger);
|
||||
let codeqlFolder;
|
||||
let toolsVersion = source.toolsVersion;
|
||||
let toolsDownloadDurationMs;
|
||||
let toolsSource;
|
||||
switch (source.sourceType) {
|
||||
case "local":
|
||||
codeqlFolder = await toolcache.extractTar(source.codeqlTarPath);
|
||||
toolsSource = init_1.ToolsSource.Local;
|
||||
break;
|
||||
case "toolcache":
|
||||
codeqlFolder = source.codeqlFolder;
|
||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||
toolsSource = init_1.ToolsSource.Toolcache;
|
||||
break;
|
||||
case "download": {
|
||||
const result = await downloadCodeQL(source.codeqlURL, source.cliVersion, apiDetails, variant, tempDir, logger);
|
||||
toolsVersion = result.toolsVersion;
|
||||
codeqlFolder = result.codeqlFolder;
|
||||
toolsDownloadDurationMs = result.toolsDownloadDurationMs;
|
||||
toolsSource = init_1.ToolsSource.Download;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
util.assertNever(source);
|
||||
}
|
||||
return { codeqlFolder, toolsVersion };
|
||||
return { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||
}
|
||||
exports.setupCodeQLBundle = setupCodeQLBundle;
|
||||
//# sourceMappingURL=setup-codeql.js.map
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -303,7 +303,7 @@ type ActionName =
|
|||
| "finish"
|
||||
| "upload-sarif"
|
||||
| "init-post";
|
||||
type ActionStatus =
|
||||
export type ActionStatus =
|
||||
| "starting"
|
||||
| "aborted"
|
||||
| "success"
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
Feature,
|
||||
featureConfig,
|
||||
} from "./feature-flags";
|
||||
import { ToolsSource } from "./init";
|
||||
import { Language } from "./languages";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { setupTests, createFeatures, setupActionsVars } from "./testing-utils";
|
||||
|
@ -203,8 +204,11 @@ test("downloads and caches explicitly requested bundles that aren't in the toolc
|
|||
getRunnerLogger(true),
|
||||
false
|
||||
);
|
||||
|
||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||
t.is(result.toolsVersion, `0.0.0-${version}`);
|
||||
t.is(result.toolsSource, ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
}
|
||||
|
||||
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
||||
|
@ -236,6 +240,8 @@ test("downloads an explicitly requested bundle even if a different version is ca
|
|||
);
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
|
||||
t.is(result.toolsSource, ToolsSource.Download);
|
||||
t.not(result.toolsDownloadDurationMs, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -286,6 +292,8 @@ for (const {
|
|||
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
|
||||
t.assert(toolcache.find("CodeQL", expectedToolcacheVersion));
|
||||
t.deepEqual(result.toolsVersion, cliVersion);
|
||||
t.is(result.toolsSource, ToolsSource.Download);
|
||||
t.not(result.toolsDownloadDurationMs, undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -354,6 +362,14 @@ for (const { isCached, tagName, toolcacheCliVersion } of [
|
|||
false
|
||||
);
|
||||
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
||||
|
||||
if (isCached) {
|
||||
t.is(result.toolsSource, ToolsSource.Toolcache);
|
||||
t.is(result.toolsDownloadDurationMs, undefined);
|
||||
} else {
|
||||
t.is(result.toolsSource, ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -384,6 +400,8 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
|||
false
|
||||
);
|
||||
t.deepEqual(result.toolsVersion, "0.0.0-20200601");
|
||||
t.is(result.toolsSource, ToolsSource.Toolcache);
|
||||
t.is(result.toolsDownloadDurationMs, undefined);
|
||||
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 1);
|
||||
|
@ -418,6 +436,8 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
|||
false
|
||||
);
|
||||
t.deepEqual(result.toolsVersion, defaults.cliVersion);
|
||||
t.is(result.toolsSource, ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 2);
|
||||
|
@ -449,6 +469,8 @@ test('downloads bundle if "latest" tools specified but not cached', async (t) =>
|
|||
false
|
||||
);
|
||||
t.deepEqual(result.toolsVersion, defaults.cliVersion);
|
||||
t.is(result.toolsSource, ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 2);
|
||||
|
@ -498,7 +520,7 @@ test("download codeql bundle from github ae endpoint", async (t) => {
|
|||
sinon.stub(actionsUtil, "isRunningLocalAction").returns(false);
|
||||
process.env["GITHUB_ACTION_REPOSITORY"] = "github/codeql-action";
|
||||
|
||||
await codeql.setupCodeQL(
|
||||
const result = await codeql.setupCodeQL(
|
||||
undefined,
|
||||
sampleGHAEApiDetails,
|
||||
tmpDir,
|
||||
|
@ -513,6 +535,9 @@ test("download codeql bundle from github ae endpoint", async (t) => {
|
|||
false
|
||||
);
|
||||
|
||||
t.is(result.toolsSource, ToolsSource.Download);
|
||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
||||
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ import * as api from "./api-client";
|
|||
import { Config } from "./config-utils";
|
||||
import { errorMatchers } from "./error-matcher";
|
||||
import { CodeQLDefaultVersionInfo, FeatureEnablement } from "./feature-flags";
|
||||
import { ToolsSource } from "./init";
|
||||
import { isTracedLanguage, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import * as setupCodeql from "./setup-codeql";
|
||||
|
@ -300,9 +301,15 @@ export async function setupCodeQL(
|
|||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||
logger: Logger,
|
||||
checkVersion: boolean
|
||||
): Promise<{ codeql: CodeQL; toolsVersion: string }> {
|
||||
): Promise<{
|
||||
codeql: CodeQL;
|
||||
toolsDownloadDurationMs?: number;
|
||||
toolsSource: ToolsSource;
|
||||
toolsVersion: string;
|
||||
}> {
|
||||
try {
|
||||
const { codeqlFolder, toolsVersion } = await setupCodeql.setupCodeQLBundle(
|
||||
const { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion } =
|
||||
await setupCodeql.setupCodeQLBundle(
|
||||
toolsInput,
|
||||
apiDetails,
|
||||
tempDir,
|
||||
|
@ -319,7 +326,12 @@ export async function setupCodeQL(
|
|||
}
|
||||
|
||||
cachedCodeQL = await getCodeQLForCmd(codeqlCmd, checkVersion);
|
||||
return { codeql: cachedCodeQL, toolsVersion };
|
||||
return {
|
||||
codeql: cachedCodeQL,
|
||||
toolsDownloadDurationMs,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
};
|
||||
} catch (e) {
|
||||
logger.error(e instanceof Error ? e : new Error(String(e)));
|
||||
throw new Error("Unable to download and extract CodeQL CLI");
|
||||
|
|
|
@ -376,7 +376,9 @@ for (const variant of [GitHubVariant.GHAE, GitHubVariant.GHES]) {
|
|||
test(`selects CLI from defaults.json on ${GitHubVariant[variant]}`, async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
t.deepEqual(await features.getDefaultCliVersion(variant), {
|
||||
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: defaults.cliVersion,
|
||||
tagName: defaults.bundleVersion,
|
||||
variant,
|
||||
|
@ -397,13 +399,14 @@ test("selects CLI v2.12.1 on Dotcom when feature flags enable v2.12.0 and v2.12.
|
|||
expectedFeatureEnablement["default_codeql_version_2_12_5_enabled"] = false;
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
t.deepEqual(
|
||||
await featureEnablement.getDefaultCliVersion(GitHubVariant.DOTCOM),
|
||||
{
|
||||
cliVersion: "2.12.1",
|
||||
variant: GitHubVariant.DOTCOM,
|
||||
}
|
||||
const defaultCliVersion = await featureEnablement.getDefaultCliVersion(
|
||||
GitHubVariant.DOTCOM
|
||||
);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.12.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
variant: GitHubVariant.DOTCOM,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -413,13 +416,14 @@ test(`selects CLI from defaults.json on Dotcom when no default version feature f
|
|||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
t.deepEqual(
|
||||
await featureEnablement.getDefaultCliVersion(GitHubVariant.DOTCOM),
|
||||
{
|
||||
cliVersion: defaults.cliVersion,
|
||||
variant: GitHubVariant.DOTCOM,
|
||||
}
|
||||
const defaultCliVersion = await featureEnablement.getDefaultCliVersion(
|
||||
GitHubVariant.DOTCOM
|
||||
);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: defaults.cliVersion,
|
||||
toolsFeatureFlagsValid: false,
|
||||
variant: GitHubVariant.DOTCOM,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -437,13 +441,15 @@ test("ignores invalid version numbers in default version feature flags", async (
|
|||
true;
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
t.deepEqual(
|
||||
await featureEnablement.getDefaultCliVersion(GitHubVariant.DOTCOM),
|
||||
{
|
||||
cliVersion: "2.12.1",
|
||||
variant: GitHubVariant.DOTCOM,
|
||||
}
|
||||
const defaultCliVersion = await featureEnablement.getDefaultCliVersion(
|
||||
GitHubVariant.DOTCOM
|
||||
);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.12.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
variant: GitHubVariant.DOTCOM,
|
||||
});
|
||||
|
||||
t.assert(
|
||||
loggedMessages.find(
|
||||
(v: LoggedMessage) =>
|
||||
|
|
|
@ -16,6 +16,7 @@ const DEFAULT_VERSION_FEATURE_FLAG_SUFFIX = "_enabled";
|
|||
export type CodeQLDefaultVersionInfo =
|
||||
| {
|
||||
cliVersion: string;
|
||||
toolsFeatureFlagsValid?: boolean;
|
||||
variant: util.GitHubVariant.DOTCOM;
|
||||
}
|
||||
| {
|
||||
|
@ -207,8 +208,10 @@ class GitHubFeatureFlags implements FeatureEnablement {
|
|||
variant: util.GitHubVariant
|
||||
): Promise<CodeQLDefaultVersionInfo> {
|
||||
if (variant === util.GitHubVariant.DOTCOM) {
|
||||
const defaultDotComCliVersion = await this.getDefaultDotcomCliVersion();
|
||||
return {
|
||||
cliVersion: await this.getDefaultDotcomCliVersion(),
|
||||
cliVersion: defaultDotComCliVersion.version,
|
||||
toolsFeatureFlagsValid: defaultDotComCliVersion.toolsFeatureFlagsValid,
|
||||
variant,
|
||||
};
|
||||
}
|
||||
|
@ -219,7 +222,10 @@ class GitHubFeatureFlags implements FeatureEnablement {
|
|||
};
|
||||
}
|
||||
|
||||
async getDefaultDotcomCliVersion(): Promise<string> {
|
||||
async getDefaultDotcomCliVersion(): Promise<{
|
||||
version: string;
|
||||
toolsFeatureFlagsValid: boolean;
|
||||
}> {
|
||||
const response = await this.getAllFeatures();
|
||||
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response)
|
||||
|
@ -244,7 +250,10 @@ class GitHubFeatureFlags implements FeatureEnablement {
|
|||
"Feature flags do not specify a default CLI version. Falling back to the CLI version " +
|
||||
`shipped with the Action. This is ${defaults.cliVersion}.`
|
||||
);
|
||||
return defaults.cliVersion;
|
||||
return {
|
||||
version: defaults.cliVersion,
|
||||
toolsFeatureFlagsValid: false,
|
||||
};
|
||||
}
|
||||
|
||||
const maxCliVersion = enabledFeatureFlagCliVersions.reduce(
|
||||
|
@ -255,7 +264,7 @@ class GitHubFeatureFlags implements FeatureEnablement {
|
|||
this.logger.debug(
|
||||
`Derived default CLI version of ${maxCliVersion} from feature flags.`
|
||||
);
|
||||
return maxCliVersion;
|
||||
return { version: maxCliVersion, toolsFeatureFlagsValid: true };
|
||||
}
|
||||
|
||||
async getValue(feature: Feature): Promise<boolean> {
|
||||
|
|
|
@ -3,6 +3,7 @@ import * as path from "path";
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import {
|
||||
ActionStatus,
|
||||
createStatusReportBase,
|
||||
getActionsStatus,
|
||||
getActionVersion,
|
||||
|
@ -22,6 +23,7 @@ import {
|
|||
injectWindowsTracer,
|
||||
installPythonDeps,
|
||||
runInit,
|
||||
ToolsSource,
|
||||
} from "./init";
|
||||
import { Language } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
|
@ -38,13 +40,27 @@ import {
|
|||
getMlPoweredJsQueriesStatus,
|
||||
getRequiredEnvParam,
|
||||
getThreadsFlagValue,
|
||||
GitHubVariant,
|
||||
initializeEnvironment,
|
||||
isHostedRunner,
|
||||
shouldBypassToolcache,
|
||||
} from "./util";
|
||||
import { validateWorkflow } from "./workflow";
|
||||
|
||||
interface InitSuccessStatusReport extends StatusReportBase {
|
||||
/** Fields of the init status report that can be sent before `config` is populated. */
|
||||
interface InitStatusReport extends StatusReportBase {
|
||||
/** Value given by the user as the "tools" input. */
|
||||
tools_input: string;
|
||||
/** Version of the bundle used. */
|
||||
tools_resolved_version: string;
|
||||
/** Where the bundle originated from. */
|
||||
tools_source: ToolsSource;
|
||||
/** Comma-separated list of languages specified explicitly in the workflow file. */
|
||||
workflow_languages: string;
|
||||
}
|
||||
|
||||
/** Fields of the init status report that are populated using values from `config`. */
|
||||
interface InitWithConfigStatusReport extends InitStatusReport {
|
||||
/** Comma-separated list of languages where the default queries are disabled. */
|
||||
disable_default_queries: string;
|
||||
/**
|
||||
|
@ -59,12 +75,6 @@ interface InitSuccessStatusReport extends StatusReportBase {
|
|||
paths_ignore: string;
|
||||
/** Comma-separated list of queries sources, from the 'queries' config field or workflow input. */
|
||||
queries: string;
|
||||
/** Value given by the user as the "tools" input. */
|
||||
tools_input: string;
|
||||
/** Version of the bundle used. */
|
||||
tools_resolved_version: string;
|
||||
/** Comma-separated list of languages specified explicitly in the workflow file. */
|
||||
workflow_languages: string;
|
||||
/** Comma-separated list of languages for which we are using TRAP caching. */
|
||||
trap_cache_languages: string;
|
||||
/** Size of TRAP caches that we downloaded, in bytes. */
|
||||
|
@ -73,20 +83,51 @@ interface InitSuccessStatusReport extends StatusReportBase {
|
|||
trap_cache_download_duration_ms: number;
|
||||
}
|
||||
|
||||
async function sendSuccessStatusReport(
|
||||
/** Fields of the init status report populated when the tools source is `download`. */
|
||||
interface InitToolsDownloadFields {
|
||||
/** Time taken to download the bundle, in milliseconds. */
|
||||
tools_download_duration_ms?: number;
|
||||
/** Whether the relevant tools dotcom feature flags have been misconfigured. Only populated if we attempt to determine the default version based on the dotcom feature flags. */
|
||||
tools_feature_flags_valid?: boolean;
|
||||
}
|
||||
|
||||
async function sendInitStatusReport(
|
||||
actionStatus: ActionStatus,
|
||||
startedAt: Date,
|
||||
config: configUtils.Config,
|
||||
config: configUtils.Config | undefined,
|
||||
toolsDownloadDurationMs: number | undefined,
|
||||
toolsFeatureFlagsValid: boolean | undefined,
|
||||
toolsSource: ToolsSource,
|
||||
toolsVersion: string,
|
||||
logger: Logger
|
||||
) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"init",
|
||||
"success",
|
||||
actionStatus,
|
||||
startedAt
|
||||
);
|
||||
|
||||
const languages = config.languages.join(",");
|
||||
const workflowLanguages = getOptionalInput("languages");
|
||||
|
||||
const initStatusReport: InitStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || ToolsSource.Unknown,
|
||||
workflow_languages: workflowLanguages || "",
|
||||
};
|
||||
|
||||
let initToolsDownloadFields: InitToolsDownloadFields = {};
|
||||
|
||||
if (toolsSource === ToolsSource.Download) {
|
||||
initToolsDownloadFields = {
|
||||
tools_download_duration_ms: toolsDownloadDurationMs,
|
||||
tools_feature_flags_valid: toolsFeatureFlagsValid,
|
||||
};
|
||||
}
|
||||
|
||||
if (config !== undefined) {
|
||||
const languages = config.languages.join(",");
|
||||
const paths = (config.originalUserInput.paths || []).join(",");
|
||||
const pathsIgnore = (config.originalUserInput["paths-ignore"] || []).join(
|
||||
","
|
||||
|
@ -111,25 +152,28 @@ async function sendSuccessStatusReport(
|
|||
queries.push(...queriesInput.split(","));
|
||||
}
|
||||
|
||||
const statusReport: InitSuccessStatusReport = {
|
||||
...statusReportBase,
|
||||
// Append fields that are dependent on `config`
|
||||
const initWithConfigStatusReport: InitWithConfigStatusReport = {
|
||||
...initStatusReport,
|
||||
disable_default_queries: disableDefaultQueries,
|
||||
languages,
|
||||
ml_powered_javascript_queries: getMlPoweredJsQueriesStatus(config),
|
||||
paths,
|
||||
paths_ignore: pathsIgnore,
|
||||
queries: queries.join(","),
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
workflow_languages: workflowLanguages || "",
|
||||
trap_cache_languages: Object.keys(config.trapCaches).join(","),
|
||||
trap_cache_download_size_bytes: Math.round(
|
||||
await getTotalCacheSize(config.trapCaches, logger)
|
||||
),
|
||||
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
||||
};
|
||||
|
||||
await sendStatusReport(statusReport);
|
||||
await sendStatusReport({
|
||||
...initWithConfigStatusReport,
|
||||
...initToolsDownloadFields,
|
||||
});
|
||||
} else {
|
||||
await sendStatusReport({ ...initStatusReport, ...initToolsDownloadFields });
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
|
@ -139,6 +183,9 @@ async function run() {
|
|||
|
||||
let config: configUtils.Config;
|
||||
let codeql: CodeQL;
|
||||
let toolsDownloadDurationMs: number | undefined;
|
||||
let toolsFeatureFlagsValid: boolean | undefined;
|
||||
let toolsSource: ToolsSource;
|
||||
let toolsVersion: string;
|
||||
|
||||
const apiDetails = {
|
||||
|
@ -178,9 +225,12 @@ async function run() {
|
|||
return;
|
||||
}
|
||||
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
||||
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(
|
||||
gitHubVersion.type
|
||||
);
|
||||
if (codeQLDefaultVersionInfo.variant === GitHubVariant.DOTCOM) {
|
||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||
}
|
||||
const initCodeQLResult = await initCodeQL(
|
||||
getOptionalInput("tools"),
|
||||
apiDetails,
|
||||
|
@ -193,11 +243,13 @@ async function run() {
|
|||
repositoryNwo,
|
||||
logger
|
||||
),
|
||||
defaultCliVersion,
|
||||
codeQLDefaultVersionInfo,
|
||||
logger
|
||||
);
|
||||
codeql = initCodeQLResult.codeql;
|
||||
toolsDownloadDurationMs = initCodeQLResult.toolsDownloadDurationMs;
|
||||
toolsVersion = initCodeQLResult.toolsVersion;
|
||||
toolsSource = initCodeQLResult.toolsSource;
|
||||
await enrichEnvironment(codeql);
|
||||
|
||||
config = await initConfig(
|
||||
|
@ -315,18 +367,28 @@ async function run() {
|
|||
core.setFailed(String(error));
|
||||
|
||||
console.log(error);
|
||||
await sendStatusReport(
|
||||
await createStatusReportBase(
|
||||
"init",
|
||||
await sendInitStatusReport(
|
||||
getActionsStatus(error),
|
||||
startedAt,
|
||||
String(error),
|
||||
error instanceof Error ? error.stack : undefined
|
||||
)
|
||||
config,
|
||||
toolsDownloadDurationMs,
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
logger
|
||||
);
|
||||
return;
|
||||
}
|
||||
await sendSuccessStatusReport(startedAt, config, toolsVersion, logger);
|
||||
await sendInitStatusReport(
|
||||
"success",
|
||||
startedAt,
|
||||
config,
|
||||
toolsDownloadDurationMs,
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
async function getTrapCachingEnabled(
|
||||
|
|
19
src/init.ts
19
src/init.ts
|
@ -15,6 +15,13 @@ import { TracerConfig, getCombinedTracerConfig } from "./tracer-config";
|
|||
import * as util from "./util";
|
||||
import { codeQlVersionAbove } from "./util";
|
||||
|
||||
export enum ToolsSource {
|
||||
Unknown = "UNKNOWN",
|
||||
Local = "LOCAL",
|
||||
Toolcache = "TOOLCACHE",
|
||||
Download = "DOWNLOAD",
|
||||
}
|
||||
|
||||
export async function initCodeQL(
|
||||
toolsInput: string | undefined,
|
||||
apiDetails: GitHubApiDetails,
|
||||
|
@ -23,9 +30,15 @@ export async function initCodeQL(
|
|||
bypassToolcache: boolean,
|
||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||
logger: Logger
|
||||
): Promise<{ codeql: CodeQL; toolsVersion: string }> {
|
||||
): Promise<{
|
||||
codeql: CodeQL;
|
||||
toolsDownloadDurationMs?: number;
|
||||
toolsSource: ToolsSource;
|
||||
toolsVersion: string;
|
||||
}> {
|
||||
logger.startGroup("Setup CodeQL tools");
|
||||
const { codeql, toolsVersion } = await setupCodeQL(
|
||||
const { codeql, toolsDownloadDurationMs, toolsSource, toolsVersion } =
|
||||
await setupCodeQL(
|
||||
toolsInput,
|
||||
apiDetails,
|
||||
tempDir,
|
||||
|
@ -37,7 +50,7 @@ export async function initCodeQL(
|
|||
);
|
||||
await codeql.printVersion();
|
||||
logger.endGroup();
|
||||
return { codeql, toolsVersion };
|
||||
return { codeql, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||
}
|
||||
|
||||
export async function initConfig(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as fs from "fs";
|
||||
import { OutgoingHttpHeaders } from "http";
|
||||
import * as path from "path";
|
||||
import { performance } from "perf_hooks";
|
||||
|
||||
import * as toolcache from "@actions/tool-cache";
|
||||
import { default as deepEqual } from "fast-deep-equal";
|
||||
|
@ -14,6 +15,7 @@ import * as api from "./api-client";
|
|||
// these dependents.
|
||||
import * as defaults from "./defaults.json";
|
||||
import { CodeQLDefaultVersionInfo } from "./feature-flags";
|
||||
import { ToolsSource } from "./init";
|
||||
import { Logger } from "./logging";
|
||||
import * as util from "./util";
|
||||
import { isGoodVersion } from "./util";
|
||||
|
@ -514,7 +516,11 @@ export async function downloadCodeQL(
|
|||
variant: util.GitHubVariant,
|
||||
tempDir: string,
|
||||
logger: Logger
|
||||
): Promise<{ toolsVersion: string; codeqlFolder: string }> {
|
||||
): Promise<{
|
||||
toolsVersion: string;
|
||||
codeqlFolder: string;
|
||||
toolsDownloadDurationMs: number;
|
||||
}> {
|
||||
const parsedCodeQLURL = new URL(codeqlURL);
|
||||
const searchParams = new URLSearchParams(parsedCodeQLURL.search);
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
|
@ -541,12 +547,16 @@ export async function downloadCodeQL(
|
|||
{ "User-Agent": "CodeQL Action" },
|
||||
headers
|
||||
);
|
||||
|
||||
const toolsDownloadStart = performance.now();
|
||||
const codeqlPath = await toolcache.downloadTool(
|
||||
codeqlURL,
|
||||
dest,
|
||||
undefined,
|
||||
finalHeaders
|
||||
);
|
||||
const toolsDownloadDurationMs = performance.now() - toolsDownloadStart;
|
||||
|
||||
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
||||
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
|
@ -581,6 +591,7 @@ export async function downloadCodeQL(
|
|||
"CodeQL",
|
||||
toolcacheVersion
|
||||
),
|
||||
toolsDownloadDurationMs,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -616,7 +627,12 @@ export async function setupCodeQLBundle(
|
|||
bypassToolcache: boolean,
|
||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||
logger: Logger
|
||||
): Promise<{ codeqlFolder: string; toolsVersion: string }> {
|
||||
): Promise<{
|
||||
codeqlFolder: string;
|
||||
toolsDownloadDurationMs?: number;
|
||||
toolsSource: ToolsSource;
|
||||
toolsVersion: string;
|
||||
}> {
|
||||
const source = await getCodeQLSource(
|
||||
toolsInput,
|
||||
bypassToolcache,
|
||||
|
@ -628,13 +644,17 @@ export async function setupCodeQLBundle(
|
|||
|
||||
let codeqlFolder: string;
|
||||
let toolsVersion = source.toolsVersion;
|
||||
let toolsDownloadDurationMs: number | undefined;
|
||||
let toolsSource: ToolsSource;
|
||||
switch (source.sourceType) {
|
||||
case "local":
|
||||
codeqlFolder = await toolcache.extractTar(source.codeqlTarPath);
|
||||
toolsSource = ToolsSource.Local;
|
||||
break;
|
||||
case "toolcache":
|
||||
codeqlFolder = source.codeqlFolder;
|
||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||
toolsSource = ToolsSource.Toolcache;
|
||||
break;
|
||||
case "download": {
|
||||
const result = await downloadCodeQL(
|
||||
|
@ -647,10 +667,12 @@ export async function setupCodeQLBundle(
|
|||
);
|
||||
toolsVersion = result.toolsVersion;
|
||||
codeqlFolder = result.codeqlFolder;
|
||||
toolsDownloadDurationMs = result.toolsDownloadDurationMs;
|
||||
toolsSource = ToolsSource.Download;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
util.assertNever(source);
|
||||
}
|
||||
return { codeqlFolder, toolsVersion };
|
||||
return { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче