Merge pull request #2394 from rvermeulen/rvermeulen/extend-init-complete-status-report
Extend init complete status report
This commit is contained in:
commit
5c02493ebf
12 changed files with 94 additions and 13 deletions
5
lib/codeql.js
generated
5
lib/codeql.js
generated
|
|
@ -788,7 +788,7 @@ async function runTool(cmd, args = [], opts = {}) {
|
||||||
async function generateCodeScanningConfig(config, logger) {
|
async function generateCodeScanningConfig(config, logger) {
|
||||||
const codeScanningConfigFile = getGeneratedCodeScanningConfigPath(config);
|
const codeScanningConfigFile = getGeneratedCodeScanningConfigPath(config);
|
||||||
// make a copy so we can modify it
|
// make a copy so we can modify it
|
||||||
const augmentedConfig = cloneObject(config.originalUserInput);
|
const augmentedConfig = (0, util_1.cloneObject)(config.originalUserInput);
|
||||||
// Inject the queries from the input
|
// Inject the queries from the input
|
||||||
if (config.augmentationProperties.queriesInput) {
|
if (config.augmentationProperties.queriesInput) {
|
||||||
if (config.augmentationProperties.queriesInputCombines) {
|
if (config.augmentationProperties.queriesInputCombines) {
|
||||||
|
|
@ -832,9 +832,6 @@ async function generateCodeScanningConfig(config, logger) {
|
||||||
fs.writeFileSync(codeScanningConfigFile, yaml.dump(augmentedConfig));
|
fs.writeFileSync(codeScanningConfigFile, yaml.dump(augmentedConfig));
|
||||||
return codeScanningConfigFile;
|
return codeScanningConfigFile;
|
||||||
}
|
}
|
||||||
function cloneObject(obj) {
|
|
||||||
return JSON.parse(JSON.stringify(obj));
|
|
||||||
}
|
|
||||||
// This constant sets the size of each TRAP cache in megabytes.
|
// This constant sets the size of each TRAP cache in megabytes.
|
||||||
const TRAP_CACHE_SIZE_MB = 1024;
|
const TRAP_CACHE_SIZE_MB = 1024;
|
||||||
async function getTrapCachingExtractorConfigArgs(config) {
|
async function getTrapCachingExtractorConfigArgs(config) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
7
lib/config-utils.js
generated
7
lib/config-utils.js
generated
|
|
@ -42,6 +42,7 @@ exports.parsePacksFromInput = parsePacksFromInput;
|
||||||
exports.parsePacksSpecification = parsePacksSpecification;
|
exports.parsePacksSpecification = parsePacksSpecification;
|
||||||
exports.validatePackSpecification = validatePackSpecification;
|
exports.validatePackSpecification = validatePackSpecification;
|
||||||
exports.initConfig = initConfig;
|
exports.initConfig = initConfig;
|
||||||
|
exports.parseRegistriesWithoutCredentials = parseRegistriesWithoutCredentials;
|
||||||
exports.getPathToParsedConfigFile = getPathToParsedConfigFile;
|
exports.getPathToParsedConfigFile = getPathToParsedConfigFile;
|
||||||
exports.getConfig = getConfig;
|
exports.getConfig = getConfig;
|
||||||
exports.generateRegistries = generateRegistries;
|
exports.generateRegistries = generateRegistries;
|
||||||
|
|
@ -507,6 +508,12 @@ function parseRegistries(registriesInput) {
|
||||||
throw new util_1.ConfigurationError("Invalid registries input. Must be a YAML string.");
|
throw new util_1.ConfigurationError("Invalid registries input. Must be a YAML string.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function parseRegistriesWithoutCredentials(registriesInput) {
|
||||||
|
return parseRegistries(registriesInput)?.map((r) => {
|
||||||
|
const { url, packages } = r;
|
||||||
|
return { url, packages };
|
||||||
|
});
|
||||||
|
}
|
||||||
function isLocal(configPath) {
|
function isLocal(configPath) {
|
||||||
// If the path starts with ./, look locally
|
// If the path starts with ./, look locally
|
||||||
if (configPath.indexOf("./") === 0) {
|
if (configPath.indexOf("./") === 0) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
22
lib/init-action.js
generated
22
lib/init-action.js
generated
|
|
@ -30,6 +30,7 @@ const safe_which_1 = require("@chrisgavin/safe-which");
|
||||||
const uuid_1 = require("uuid");
|
const uuid_1 = require("uuid");
|
||||||
const actions_util_1 = require("./actions-util");
|
const actions_util_1 = require("./actions-util");
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
const diagnostics_1 = require("./diagnostics");
|
const diagnostics_1 = require("./diagnostics");
|
||||||
const environment_1 = require("./environment");
|
const environment_1 = require("./environment");
|
||||||
const feature_flags_1 = require("./feature-flags");
|
const feature_flags_1 = require("./feature-flags");
|
||||||
|
|
@ -82,6 +83,24 @@ async function sendCompletedStatusReport(startedAt, config, toolsDownloadDuratio
|
||||||
: queriesInput;
|
: queriesInput;
|
||||||
queries.push(...queriesInput.split(","));
|
queries.push(...queriesInput.split(","));
|
||||||
}
|
}
|
||||||
|
let packs = {};
|
||||||
|
if ((config.augmentationProperties.packsInputCombines ||
|
||||||
|
!config.augmentationProperties.packsInput) &&
|
||||||
|
config.originalUserInput.packs) {
|
||||||
|
// Make a copy, because we might modify `packs`.
|
||||||
|
const copyPacksFromOriginalUserInput = (0, util_1.cloneObject)(config.originalUserInput.packs);
|
||||||
|
// If it is an array, then assume there is only a single language being analyzed.
|
||||||
|
if (Array.isArray(copyPacksFromOriginalUserInput)) {
|
||||||
|
packs[config.languages[0]] = copyPacksFromOriginalUserInput;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
packs = copyPacksFromOriginalUserInput;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (config.augmentationProperties.packsInput) {
|
||||||
|
packs[config.languages[0]] ??= [];
|
||||||
|
packs[config.languages[0]].push(...config.augmentationProperties.packsInput);
|
||||||
|
}
|
||||||
// Append fields that are dependent on `config`
|
// Append fields that are dependent on `config`
|
||||||
const initWithConfigStatusReport = {
|
const initWithConfigStatusReport = {
|
||||||
...initStatusReport,
|
...initStatusReport,
|
||||||
|
|
@ -89,9 +108,12 @@ async function sendCompletedStatusReport(startedAt, config, toolsDownloadDuratio
|
||||||
paths,
|
paths,
|
||||||
paths_ignore: pathsIgnore,
|
paths_ignore: pathsIgnore,
|
||||||
queries: queries.join(","),
|
queries: queries.join(","),
|
||||||
|
packs: JSON.stringify(packs),
|
||||||
trap_cache_languages: Object.keys(config.trapCaches).join(","),
|
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_size_bytes: Math.round(await (0, trap_caching_1.getTotalCacheSize)(config.trapCaches, logger)),
|
||||||
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
||||||
|
query_filters: JSON.stringify(config.originalUserInput["query-filters"] ?? []),
|
||||||
|
registries: JSON.stringify(configUtils.parseRegistriesWithoutCredentials((0, actions_util_1.getOptionalInput)("registries")) ?? []),
|
||||||
};
|
};
|
||||||
await (0, status_report_1.sendStatusReport)({
|
await (0, status_report_1.sendStatusReport)({
|
||||||
...initWithConfigStatusReport,
|
...initWithConfigStatusReport,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
4
lib/util.js
generated
4
lib/util.js
generated
|
|
@ -66,6 +66,7 @@ exports.getErrorMessage = getErrorMessage;
|
||||||
exports.prettyPrintPack = prettyPrintPack;
|
exports.prettyPrintPack = prettyPrintPack;
|
||||||
exports.checkDiskUsage = checkDiskUsage;
|
exports.checkDiskUsage = checkDiskUsage;
|
||||||
exports.checkActionVersion = checkActionVersion;
|
exports.checkActionVersion = checkActionVersion;
|
||||||
|
exports.cloneObject = cloneObject;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
|
|
@ -858,4 +859,7 @@ var BuildMode;
|
||||||
/** The database will be created by building the source root using manually specified build steps. */
|
/** The database will be created by building the source root using manually specified build steps. */
|
||||||
BuildMode["Manual"] = "manual";
|
BuildMode["Manual"] = "manual";
|
||||||
})(BuildMode || (exports.BuildMode = BuildMode = {}));
|
})(BuildMode || (exports.BuildMode = BuildMode = {}));
|
||||||
|
function cloneObject(obj) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
}
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -31,7 +31,7 @@ import * as setupCodeql from "./setup-codeql";
|
||||||
import { ToolsFeature, isSupportedToolsFeature } from "./tools-features";
|
import { ToolsFeature, isSupportedToolsFeature } from "./tools-features";
|
||||||
import { shouldEnableIndirectTracing } from "./tracer-config";
|
import { shouldEnableIndirectTracing } from "./tracer-config";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
import { BuildMode, wrapError } from "./util";
|
import { BuildMode, wrapError, cloneObject } from "./util";
|
||||||
|
|
||||||
type Options = Array<string | number | boolean>;
|
type Options = Array<string | number | boolean>;
|
||||||
|
|
||||||
|
|
@ -1306,10 +1306,6 @@ async function generateCodeScanningConfig(
|
||||||
return codeScanningConfigFile;
|
return codeScanningConfigFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneObject<T>(obj: T): T {
|
|
||||||
return JSON.parse(JSON.stringify(obj)) as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This constant sets the size of each TRAP cache in megabytes.
|
// This constant sets the size of each TRAP cache in megabytes.
|
||||||
const TRAP_CACHE_SIZE_MB = 1024;
|
const TRAP_CACHE_SIZE_MB = 1024;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -881,6 +881,15 @@ function parseRegistries(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parseRegistriesWithoutCredentials(
|
||||||
|
registriesInput?: string,
|
||||||
|
): RegistryConfigNoCredentials[] | undefined {
|
||||||
|
return parseRegistries(registriesInput)?.map((r) => {
|
||||||
|
const { url, packages } = r;
|
||||||
|
return { url, packages };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function isLocal(configPath: string): boolean {
|
function isLocal(configPath: string): boolean {
|
||||||
// If the path starts with ./, look locally
|
// If the path starts with ./, look locally
|
||||||
if (configPath.indexOf("./") === 0) {
|
if (configPath.indexOf("./") === 0) {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ import {
|
||||||
ConfigurationError,
|
ConfigurationError,
|
||||||
wrapError,
|
wrapError,
|
||||||
checkActionVersion,
|
checkActionVersion,
|
||||||
|
cloneObject,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
import { validateWorkflow } from "./workflow";
|
import { validateWorkflow } from "./workflow";
|
||||||
|
|
||||||
|
|
@ -85,12 +86,19 @@ interface InitWithConfigStatusReport extends InitStatusReport {
|
||||||
paths_ignore: string;
|
paths_ignore: string;
|
||||||
/** Comma-separated list of queries sources, from the 'queries' config field or workflow input. */
|
/** Comma-separated list of queries sources, from the 'queries' config field or workflow input. */
|
||||||
queries: string;
|
queries: string;
|
||||||
|
/** Stringified JSON object of packs, from the 'packs' config field or workflow input. */
|
||||||
|
packs: string;
|
||||||
/** Comma-separated list of languages for which we are using TRAP caching. */
|
/** Comma-separated list of languages for which we are using TRAP caching. */
|
||||||
trap_cache_languages: string;
|
trap_cache_languages: string;
|
||||||
/** Size of TRAP caches that we downloaded, in bytes. */
|
/** Size of TRAP caches that we downloaded, in bytes. */
|
||||||
trap_cache_download_size_bytes: number;
|
trap_cache_download_size_bytes: number;
|
||||||
/** Time taken to download TRAP caches, in milliseconds. */
|
/** Time taken to download TRAP caches, in milliseconds. */
|
||||||
trap_cache_download_duration_ms: number;
|
trap_cache_download_duration_ms: number;
|
||||||
|
/** Stringified JSON array of registry configuration objects, from the 'registries' config field
|
||||||
|
or workflow input. **/
|
||||||
|
registries: string;
|
||||||
|
/** Stringified JSON object representing a query-filters, from the 'query-filters' config field. **/
|
||||||
|
query_filters: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fields of the init status report populated when the tools source is `download`. */
|
/** Fields of the init status report populated when the tools source is `download`. */
|
||||||
|
|
@ -174,6 +182,31 @@ async function sendCompletedStatusReport(
|
||||||
queries.push(...queriesInput.split(","));
|
queries.push(...queriesInput.split(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let packs: Record<string, string[]> = {};
|
||||||
|
if (
|
||||||
|
(config.augmentationProperties.packsInputCombines ||
|
||||||
|
!config.augmentationProperties.packsInput) &&
|
||||||
|
config.originalUserInput.packs
|
||||||
|
) {
|
||||||
|
// Make a copy, because we might modify `packs`.
|
||||||
|
const copyPacksFromOriginalUserInput = cloneObject(
|
||||||
|
config.originalUserInput.packs,
|
||||||
|
);
|
||||||
|
// If it is an array, then assume there is only a single language being analyzed.
|
||||||
|
if (Array.isArray(copyPacksFromOriginalUserInput)) {
|
||||||
|
packs[config.languages[0]] = copyPacksFromOriginalUserInput;
|
||||||
|
} else {
|
||||||
|
packs = copyPacksFromOriginalUserInput;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.augmentationProperties.packsInput) {
|
||||||
|
packs[config.languages[0]] ??= [];
|
||||||
|
packs[config.languages[0]].push(
|
||||||
|
...config.augmentationProperties.packsInput,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Append fields that are dependent on `config`
|
// Append fields that are dependent on `config`
|
||||||
const initWithConfigStatusReport: InitWithConfigStatusReport = {
|
const initWithConfigStatusReport: InitWithConfigStatusReport = {
|
||||||
...initStatusReport,
|
...initStatusReport,
|
||||||
|
|
@ -181,11 +214,20 @@ async function sendCompletedStatusReport(
|
||||||
paths,
|
paths,
|
||||||
paths_ignore: pathsIgnore,
|
paths_ignore: pathsIgnore,
|
||||||
queries: queries.join(","),
|
queries: queries.join(","),
|
||||||
|
packs: JSON.stringify(packs),
|
||||||
trap_cache_languages: Object.keys(config.trapCaches).join(","),
|
trap_cache_languages: Object.keys(config.trapCaches).join(","),
|
||||||
trap_cache_download_size_bytes: Math.round(
|
trap_cache_download_size_bytes: Math.round(
|
||||||
await getTotalCacheSize(config.trapCaches, logger),
|
await getTotalCacheSize(config.trapCaches, logger),
|
||||||
),
|
),
|
||||||
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
||||||
|
query_filters: JSON.stringify(
|
||||||
|
config.originalUserInput["query-filters"] ?? [],
|
||||||
|
),
|
||||||
|
registries: JSON.stringify(
|
||||||
|
configUtils.parseRegistriesWithoutCredentials(
|
||||||
|
getOptionalInput("registries"),
|
||||||
|
) ?? [],
|
||||||
|
),
|
||||||
};
|
};
|
||||||
await sendStatusReport({
|
await sendStatusReport({
|
||||||
...initWithConfigStatusReport,
|
...initWithConfigStatusReport,
|
||||||
|
|
|
||||||
|
|
@ -1100,3 +1100,7 @@ export enum BuildMode {
|
||||||
/** The database will be created by building the source root using manually specified build steps. */
|
/** The database will be created by building the source root using manually specified build steps. */
|
||||||
Manual = "manual",
|
Manual = "manual",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function cloneObject<T>(obj: T): T {
|
||||||
|
return JSON.parse(JSON.stringify(obj)) as T;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue