@@ -28,6 +28,24 @@ interface WorkflowInput {
2828/** A partial mapping from known input names to input definitions. */
2929type WorkflowInputs = Partial < Record < KnownInputName , WorkflowInput > > ;
3030
31+ /** An operating system identifier. */
32+ type OperatingSystemIdentifier = "ubuntu" | "macos" | "windows" ;
33+
34+ /**
35+ * Represents an operating system matrix entry for a generated PR check workflow.
36+ *
37+ * Either a string containing the OS identifier or an object containing the OS identifier and an
38+ * optional runner image label.
39+ */
40+ type OperatingSystem =
41+ | OperatingSystemIdentifier
42+ | {
43+ /** OS identifier. */
44+ os : OperatingSystemIdentifier ;
45+ /** Optional runner image label. */
46+ "runner-image" ?: string ;
47+ } ;
48+
3149/**
3250 * Represents PR check specifications.
3351 */
@@ -36,8 +54,8 @@ interface Specification extends JobSpecification {
3654 inputs ?: Record < string , WorkflowInput > ;
3755 /** CodeQL bundle versions to test against. Defaults to `DEFAULT_TEST_VERSIONS`. */
3856 versions ?: string [ ] ;
39- /** Operating system prefixes used to select runner images (e.g. `["ubuntu", "macos"]`) . */
40- operatingSystems ?: string [ ] ;
57+ /** Operating system prefixes, either as strings or with explicit runner image labels . */
58+ operatingSystems ?: OperatingSystem [ ] ;
4159 /** Per-OS version overrides. If specified for an OS, only those versions are tested on that OS. */
4260 osCodeQlVersions ?: Record < string , string [ ] > ;
4361 /** Whether to use the all-platform CodeQL bundle. */
@@ -311,20 +329,33 @@ function generateJobMatrix(
311329 ) ;
312330 }
313331
314- const runnerImages = [ "ubuntu-latest" , "macos-latest" , "windows-latest" ] ;
332+ const defaultRunnerImages = [
333+ "ubuntu-latest" ,
334+ "macos-latest" ,
335+ "windows-latest" ,
336+ ] ;
315337 const operatingSystems = checkSpecification . operatingSystems ?? [ "ubuntu" ] ;
316338
317- for ( const operatingSystem of operatingSystems ) {
339+ for ( const operatingSystemConfig of operatingSystems ) {
340+ const operatingSystem =
341+ typeof operatingSystemConfig === "string"
342+ ? operatingSystemConfig
343+ : operatingSystemConfig . os ;
344+
318345 // If osCodeQlVersions is set for this OS, only include the specified CodeQL versions.
319346 const allowedVersions =
320347 checkSpecification . osCodeQlVersions ?. [ operatingSystem ] ;
321348 if ( allowedVersions && ! allowedVersions . includes ( version ) ) {
322349 continue ;
323350 }
324351
325- const runnerImagesForOs = runnerImages . filter ( ( image ) =>
326- image . startsWith ( operatingSystem ) ,
327- ) ;
352+ const runnerImagesForOs =
353+ typeof operatingSystemConfig === "string" ||
354+ operatingSystemConfig [ "runner-image" ] === undefined
355+ ? defaultRunnerImages . filter ( ( image ) =>
356+ image . startsWith ( operatingSystem ) ,
357+ )
358+ : [ operatingSystemConfig [ "runner-image" ] ] ;
328359
329360 for ( const runnerImage of runnerImagesForOs ) {
330361 matrix . push ( {
0 commit comments