@@ -275,6 +275,52 @@ function stripTrailingWhitespace(content: string): string {
275275 . join ( "\n" ) ;
276276}
277277
278+ /** Generates the matrix for a job. */
279+ function generateJobMatrix (
280+ checkSpecification : Specification ,
281+ ) : Array < Record < string , any > > {
282+ let matrix : Array < Record < string , any > > = [ ] ;
283+
284+ for ( const version of checkSpecification . versions ?? defaultTestVersions ) {
285+ if ( version === "latest" ) {
286+ throw new Error (
287+ 'Did not recognise "version: latest". Did you mean "version: linked"?' ,
288+ ) ;
289+ }
290+
291+ const runnerImages = [ "ubuntu-latest" , "macos-latest" , "windows-latest" ] ;
292+ const operatingSystems = checkSpecification . operatingSystems ?? [ "ubuntu" ] ;
293+
294+ for ( const operatingSystem of operatingSystems ) {
295+ const runnerImagesForOs = runnerImages . filter ( ( image ) =>
296+ image . startsWith ( operatingSystem ) ,
297+ ) ;
298+
299+ for ( const runnerImage of runnerImagesForOs ) {
300+ matrix . push ( {
301+ os : runnerImage ,
302+ version,
303+ } ) ;
304+ }
305+ }
306+ }
307+
308+ if ( checkSpecification . analysisKinds ) {
309+ const newMatrix : Array < Record < string , any > > = [ ] ;
310+ for ( const matrixInclude of matrix ) {
311+ for ( const analysisKind of checkSpecification . analysisKinds ) {
312+ newMatrix . push ( {
313+ ...matrixInclude ,
314+ "analysis-kinds" : analysisKind ,
315+ } ) ;
316+ }
317+ }
318+ matrix = newMatrix ;
319+ }
320+
321+ return matrix ;
322+ }
323+
278324/**
279325 * Retrieves setup steps and additional input definitions based on specific languages or frameworks
280326 * that are requested by the `checkSpecification`.
@@ -337,51 +383,11 @@ function main(): void {
337383
338384 console . log ( `Processing: ${ checkName } — "${ checkSpecification . name } "` ) ;
339385
340- let matrix : Array < Record < string , any > > = [ ] ;
341-
342- for ( const version of checkSpecification . versions ?? defaultTestVersions ) {
343- if ( version === "latest" ) {
344- throw new Error (
345- 'Did not recognise "version: latest". Did you mean "version: linked"?' ,
346- ) ;
347- }
348-
349- const runnerImages = [ "ubuntu-latest" , "macos-latest" , "windows-latest" ] ;
350- const operatingSystems = checkSpecification . operatingSystems ?? [
351- "ubuntu" ,
352- ] ;
353-
354- for ( const operatingSystem of operatingSystems ) {
355- const runnerImagesForOs = runnerImages . filter ( ( image ) =>
356- image . startsWith ( operatingSystem ) ,
357- ) ;
358-
359- for ( const runnerImage of runnerImagesForOs ) {
360- matrix . push ( {
361- os : runnerImage ,
362- version,
363- } ) ;
364- }
365- }
366- }
367-
386+ const matrix : Array < Record < string , any > > = generateJobMatrix ( checkSpecification ) ;
368387 const useAllPlatformBundle = checkSpecification . useAllPlatformBundle
369388 ? checkSpecification . useAllPlatformBundle
370389 : "false" ;
371390
372- if ( checkSpecification . analysisKinds ) {
373- const newMatrix : Array < Record < string , any > > = [ ] ;
374- for ( const matrixInclude of matrix ) {
375- for ( const analysisKind of checkSpecification . analysisKinds ) {
376- newMatrix . push ( {
377- ...matrixInclude ,
378- "analysis-kinds" : analysisKind ,
379- } ) ;
380- }
381- }
382- matrix = newMatrix ;
383- }
384-
385391 // Determine which languages or frameworks have to be installed.
386392 const setupInfo = getSetupSteps ( checkSpecification ) ;
387393 const workflowInputs = setupInfo . inputs ;
0 commit comments