Skip to content

Commit a6c4760

Browse files
committed
Add packs to init complete status report
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.
1 parent aa96d09 commit a6c4760

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/init-action.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ interface InitWithConfigStatusReport extends InitStatusReport {
8585
paths_ignore: string;
8686
/** Comma-separated list of queries sources, from the 'queries' config field or workflow input. */
8787
queries: string;
88+
/** Stringified JSON object of packs, from the 'packs' config field or workflow input. */
89+
packs: string;
8890
/** Comma-separated list of languages for which we are using TRAP caching. */
8991
trap_cache_languages: string;
9092
/** Size of TRAP caches that we downloaded, in bytes. */
@@ -174,13 +176,32 @@ async function sendCompletedStatusReport(
174176
queries.push(...queriesInput.split(","));
175177
}
176178

179+
let packs: Record<string, string[]> = {};
180+
if ((config.augmentationProperties.packsInputCombines || !config.augmentationProperties.packsInput)
181+
&& config.originalUserInput.packs
182+
) {
183+
// If it is an array, that single language analysis we assume
184+
// there is only a single language being analyzed.
185+
if (Array.isArray(config.originalUserInput.packs)) {
186+
packs[config.languages[0]] = config.originalUserInput.packs;
187+
} else {
188+
packs = config.originalUserInput.packs;
189+
}
190+
}
191+
192+
if (config.augmentationProperties.packsInput) {
193+
packs[config.languages[0]] ??= [];
194+
packs[config.languages[0]].push(...config.augmentationProperties.packsInput);
195+
}
196+
177197
// Append fields that are dependent on `config`
178198
const initWithConfigStatusReport: InitWithConfigStatusReport = {
179199
...initStatusReport,
180200
disable_default_queries: disableDefaultQueries,
181201
paths,
182202
paths_ignore: pathsIgnore,
183203
queries: queries.join(","),
204+
packs: JSON.stringify(packs),
184205
trap_cache_languages: Object.keys(config.trapCaches).join(","),
185206
trap_cache_download_size_bytes: Math.round(
186207
await getTotalCacheSize(config.trapCaches, logger),

0 commit comments

Comments
 (0)