Skip to content

Commit 843c8cf

Browse files
authored
Don't generate matrix jobs for Swift versions which aren't supported by the package. (#3415)
Don't generate matrix jobs for Swift versions which aren't supported by the package. ### Motivation: Matrix workflows should not generate jobs for Swift versions < tools version, doing so wastes compute and adds noise. This means that: - New repos don’t need to manually opt-out of old Swift versions - Repos which have dropped an old Swift version (during a migration window) won’t have failing tests until it’s turned off centrally. ### Modifications: - The generate script now looks for `Package.swift` and `Package@swift-*.swift` files and uses the lowest tools version in any found file to determine the minimum supported Swift version - Any Swift version lower than the minimum is disregarded and no jobs are generated for it - A new parameter is added to the workflows which allows the minimum Swift version to be set manually (`minimum_swift_version`) ### Result: By default in this and downstream packages we don't generate matrix jobs for Swift versions which aren't supported by the package. An example of this working: https://github.com/apple/swift-nio/actions/runs/18711362977/job/53360387720?pr=3415
1 parent 0469372 commit 843c8cf

File tree

5 files changed

+233
-153
lines changed

5 files changed

+233
-153
lines changed

.github/workflows/benchmarks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ on:
7676
description: "Environment variables for Linux jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
7777
default: "{}"
7878

79+
minimum_swift_version:
80+
type: string
81+
description: "Minimum Swift version to include in the matrix. Leave empty for auto-detection from Package.swift, specify a version like '6.0' to override, or set to 'none' to disable filtering."
82+
default: ""
83+
7984
jobs:
8085
construct-matrix:
8186
name: Construct Benchmarks matrix
@@ -101,6 +106,7 @@ jobs:
101106
env:
102107
MATRIX_LINUX_COMMAND: "curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check_benchmark_thresholds.sh | BENCHMARK_PACKAGE_PATH=${{ inputs.benchmark_package_path }} bash"
103108
MATRIX_LINUX_SETUP_COMMAND: "swift --version && apt-get update -y -q && apt-get install -y -q curl libjemalloc-dev && git config --global --add safe.directory /$(basename ${{ github.workspace }})"
109+
MATRIX_MIN_SWIFT_VERSION: ${{ inputs.minimum_swift_version }}
104110
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
105111
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
106112
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}

.github/workflows/cxx_interop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ on:
7373
description: "Environment variables for Windows jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
7474
default: "{}"
7575

76+
minimum_swift_version:
77+
type: string
78+
description: "Minimum Swift version to include in the matrix. Leave empty for auto-detection from Package.swift, specify a version like '6.0' to override, or set to 'none' to disable filtering."
79+
default: ""
80+
7681
jobs:
7782
construct-matrix:
7883
name: Construct Cxx interop matrix
@@ -104,6 +109,7 @@ jobs:
104109
env:
105110
MATRIX_LINUX_COMMAND: "curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash"
106111
MATRIX_LINUX_SETUP_COMMAND: "swift --version && apt-get update -y -q && apt-get install -y -q curl jq"
112+
MATRIX_MIN_SWIFT_VERSION: ${{ inputs.minimum_swift_version }}
107113
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
108114
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
109115
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}

.github/workflows/release_builds.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ on:
105105
description: "Environment variables for Windows jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
106106
default: "{}"
107107

108+
minimum_swift_version:
109+
type: string
110+
description: "Minimum Swift version to include in the matrix. Leave empty for auto-detection from Package.swift, specify a version like '6.0' to override, or set to 'none' to disable filtering."
111+
default: ""
112+
108113
jobs:
109114
construct-matrix:
110115
name: Construct release build matrix
@@ -136,6 +141,7 @@ jobs:
136141
env:
137142
MATRIX_LINUX_SETUP_COMMAND: "swift --version"
138143
MATRIX_LINUX_COMMAND: "swift build -c release"
144+
MATRIX_MIN_SWIFT_VERSION: ${{ inputs.minimum_swift_version }}
139145
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
140146
MATRIX_LINUX_5_10_COMMAND_ARGUMENTS: ${{ inputs.linux_5_10_arguments_override }}
141147
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}

.github/workflows/unit_tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ on:
145145
description: "Environment variables for Windows jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
146146
default: "{}"
147147

148+
minimum_swift_version:
149+
type: string
150+
description: "Minimum Swift version to include in the matrix. Leave empty for auto-detection from Package.swift, specify a version like '6.0' to override, or set to 'none' to disable filtering."
151+
default: ""
152+
148153
jobs:
149154
construct-matrix:
150155
name: Construct unit test matrix
@@ -178,6 +183,7 @@ jobs:
178183
env:
179184
MATRIX_LINUX_SETUP_COMMAND: "swift --version"
180185
MATRIX_LINUX_COMMAND: "swift test"
186+
MATRIX_MIN_SWIFT_VERSION: ${{ inputs.minimum_swift_version }}
181187
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
182188
MATRIX_LINUX_5_9_COMMAND_ARGUMENTS: ${{ inputs.linux_5_9_arguments_override }}
183189
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}

0 commit comments

Comments
 (0)