Skip to content

Commit 2d85855

Browse files
committed
Refactor defaultRunnerImages into DEFAULT_RUNNER_IMAGES map
1 parent 354d3a2 commit 2d85855

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎pr-checks/sync.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ type WorkflowInputs = Partial<Record<KnownInputName, WorkflowInput>>;
4343
/** An operating system identifier. */
4444
type OperatingSystemIdentifier = "ubuntu" | "macos" | "windows";
4545

46+
/** Mapping from {@link OperatingSystemIdentifier} to default runner image labels. */
47+
const DEFAULT_RUNNER_IMAGES: Record<OperatingSystemIdentifier, string> = {
48+
ubuntu: "ubuntu-latest",
49+
macos: "macos-latest",
50+
windows: "windows-latest",
51+
};
52+
4653
/**
4754
* Represents an operating system matrix entry for a generated PR check workflow.
4855
*
@@ -414,12 +421,6 @@ function generateJobMatrix(
414421
);
415422
}
416423

417-
const defaultRunnerImages = [
418-
"ubuntu-latest",
419-
"macos-latest",
420-
"windows-latest",
421-
];
422-
423424
for (const operatingSystemConfig of operatingSystems) {
424425
const operatingSystem =
425426
typeof operatingSystemConfig === "string"
@@ -449,7 +450,7 @@ function generateJobMatrix(
449450
const runnerImagesForOs =
450451
typeof operatingSystemConfig === "string" ||
451452
operatingSystemConfig["runner-image"] === undefined
452-
? defaultRunnerImages.filter((image) =>
453+
? Object.values(DEFAULT_RUNNER_IMAGES).filter((image) =>
453454
image.startsWith(operatingSystem),
454455
)
455456
: [operatingSystemConfig["runner-image"]];

0 commit comments

Comments
 (0)