Skip to content

Commit

Permalink
Add packs to init complete status report
Browse files Browse the repository at this point in the history
To support both the single language and multi language case we turn
the single language case into a multi language case using the
configured language.
The entire packs record is then stored as a stringified JSON object.
  • Loading branch information
Remco Vermeulen committed Jul 26, 2024
1 parent aa96d09 commit a6c4760
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ 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. */
Expand Down Expand Up @@ -174,13 +176,32 @@ 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, that single language analysis we 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),
Expand Down

0 comments on commit a6c4760

Please sign in to comment.