From f46217d83fec62b96b1cfb9c49d79a18954aeb41 Mon Sep 17 00:00:00 2001
From: Rick Newton-Rogers <rnro@apple.com>
Date: Tue, 19 Nov 2024 09:41:40 +0000
Subject: [PATCH] Configurable unit tests workflow container images

Motivation:

Allow configuration of the container images to allow more versatile
testing, e.g. on amazonlinux images.

Modifications:

Expose the `matrix_linux_5_9_container_image` input from the matrix
command and similar.

Result:

More flexible unit tests
---
 .github/workflows/unit_tests.yml | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml
index 8a70518bb6..5ddacbc9ca 100644
--- a/.github/workflows/unit_tests.yml
+++ b/.github/workflows/unit_tests.yml
@@ -7,6 +7,10 @@ on:
         type: boolean
         description: "Boolean to enable the Linux 5.9 Swift version matrix job. Defaults to true."
         default: true
+      linux_5_9_container_image:
+        type: string
+        description: "Container image for the 5.9 Swift version matrix job. Defaults to matching Swift Ubuntu image."
+        default: "swift:5.9-jammy"
       linux_5_9_arguments_override:
         type: string
         description: "The arguments passed to swift test in the Linux 5.9 Swift version matrix job."
@@ -15,6 +19,10 @@ on:
         type: boolean
         description: "Boolean to enable the Linux 5.10 Swift version matrix job. Defaults to true."
         default: true
+      linux_5_10_container_image:
+        type: string
+        description: "Container image for the 5.10 Swift version matrix job. Defaults to matching Swift Ubuntu image."
+        default: "swift:5.10-jammy"
       linux_5_10_arguments_override:
         type: string
         description: "The arguments passed to swift test in the Linux 5.10 Swift version matrix job."
@@ -23,6 +31,10 @@ on:
         type: boolean
         description: "Boolean to enable the Linux 6.0 Swift version matrix job. Defaults to true."
         default: true
+      linux_6_0_container_image:
+        type: string
+        description: "Container image for the 6.0 Swift version matrix job. Defaults to matching Swift Ubuntu image."
+        default: "swift:6.0-jammy"
       linux_6_0_arguments_override:
         type: string
         description: "The arguments passed to swift test in the Linux 6.0 Swift version matrix job."
@@ -31,6 +43,10 @@ on:
         type: boolean
         description: "Boolean to enable the Linux nightly 6.0 Swift version matrix job. Defaults to true."
         default: true
+      linux_nightly_6_0_container_image:
+        type: string
+        description: "Container image for the nightly 6.0 Swift version matrix job. Defaults to matching Swift Ubuntu image."
+        default: "swiftlang/swift:nightly-6.0-jammy"
       linux_nightly_6_0_arguments_override:
         type: string
         description: "The arguments passed to swift test in the Linux nightly 6.0 Swift version matrix job."
@@ -39,6 +55,10 @@ on:
         type: boolean
         description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
         default: true
+      linux_nightly_main_container_image:
+        type: string
+        description: "Container image for the Linux nightly main Swift version matrix job. Defaults to matching Swift Ubuntu image."
+        default: "swiftlang/swift:nightly-main-jammy"
       linux_nightly_main_arguments_override:
         type: string
         description: "The arguments passed to swift test in the Linux nightly main Swift version matrix job."
@@ -78,14 +98,19 @@ jobs:
       name: "Unit tests"
       matrix_linux_command: "swift test"
       matrix_linux_5_9_enabled: ${{ inputs.linux_5_9_enabled }}
+      matrix_linux_5_9_container_image: ${{ inputs.linux_5_9_container_image }}
       matrix_linux_5_9_command_override: "swift test ${{ inputs.linux_5_9_arguments_override }}"
       matrix_linux_5_10_enabled: ${{ inputs.linux_5_10_enabled }}
+      matrix_linux_5_10_container_image: ${{ inputs.linux_5_10_container_image }}
       matrix_linux_5_10_command_override: "swift test ${{ inputs.linux_5_10_arguments_override }}"
       matrix_linux_6_0_enabled: ${{ inputs.linux_6_0_enabled }}
+      matrix_linux_6_0_container_image: ${{ inputs.linux_6_0_container_image }}
       matrix_linux_6_0_command_override: "swift test ${{ inputs.linux_6_0_arguments_override }}"
       matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
+      matrix_linux_nightly_6_0_container_image: ${{ inputs.linux_nightly_6_0_container_image }}
       matrix_linux_nightly_6_0_command_override: "swift test ${{ inputs.linux_nightly_6_0_arguments_override }}"
       matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
+      matrix_linux_nightly_main_container_image: ${{ inputs.linux_nightly_main_container_image }}
       matrix_linux_nightly_main_command_override: "swift test ${{ inputs.linux_nightly_main_arguments_override }}"
       matrix_windows_command: "swift test"
       matrix_windows_6_0_enabled: ${{ inputs.windows_6_0_enabled }}