Skip to content

Extend init complete status report #2394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,13 @@ function parseRegistries(
}
}

export function parseRegistriesWithoutCredentials(registriesInput?: string) : RegistryConfigNoCredentials[] | undefined {
return parseRegistries(registriesInput)?.map((r) => {
const {token:_, ...registryWithoutCredentials} = r;
return registryWithoutCredentials;
})
}

function isLocal(configPath: string): boolean {
// If the path starts with ./, look locally
if (configPath.indexOf("./") === 0) {
Expand Down
26 changes: 26 additions & 0 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,18 @@ interface InitWithConfigStatusReport extends InitStatusReport {
paths_ignore: string;
/** Comma-separated list of queries sources, from the 'queries' config field or workflow input. */
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. */
trap_cache_languages: string;
/** Size of TRAP caches that we downloaded, in bytes. */
trap_cache_download_size_bytes: number;
/** Time taken to download TRAP caches, in milliseconds. */
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`. */
Expand Down Expand Up @@ -174,18 +180,38 @@ async function sendCompletedStatusReport(
queries.push(...queriesInput.split(","));
}

let packs: Record<string, string[]> = {};
if ((config.augmentationProperties.packsInputCombines || !config.augmentationProperties.packsInput)
&& config.originalUserInput.packs
) {
// If it is an array, then assume there is only a single language being analyzed.
if (Array.isArray(config.originalUserInput.packs)) {
packs[config.languages[0]] = config.originalUserInput.packs;
} else {
packs = config.originalUserInput.packs;
}
}

if (config.augmentationProperties.packsInput) {
packs[config.languages[0]] ??= [];
packs[config.languages[0]].push(...config.augmentationProperties.packsInput);
}

// Append fields that are dependent on `config`
const initWithConfigStatusReport: InitWithConfigStatusReport = {
...initStatusReport,
disable_default_queries: disableDefaultQueries,
paths,
paths_ignore: pathsIgnore,
queries: queries.join(","),
packs: JSON.stringify(packs),
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),
query_filters: JSON.stringify(config.originalUserInput["query-filters"]),
registries: JSON.stringify(configUtils.parseRegistriesWithoutCredentials(getOptionalInput("registries"))),
};
await sendStatusReport({
...initWithConfigStatusReport,
Expand Down
Loading