@@ -99,43 +99,101 @@ concurrency:
99
99
cancel-in-progress : true
100
100
101
101
jobs :
102
+ generate-matrix :
103
+ name : Generate Matrix
104
+ runs-on : ubuntu-latest
105
+ outputs :
106
+ linux-matrix : ${{ steps.set-matrix.outputs.linux-matrix }}
107
+ windows-matrix : ${{ steps.set-matrix.outputs.windows-matrix }}
108
+ windows-nightly-matrix : ${{ steps.set-matrix.outputs.windows-nightly-matrix }}
109
+ steps :
110
+ - id : set-matrix
111
+ env :
112
+ LINUX_5_9_ENABLED : ${{ inputs.matrix_linux_5_9_enabled }}
113
+ LINUX_5_10_ENABLED : ${{ inputs.matrix_linux_5_10_enabled }}
114
+ LINUX_6_0_ENABLED : ${{ inputs.matrix_linux_6_0_enabled }}
115
+ LINUX_NIGHTLY_6_0_ENABLED : ${{ inputs.matrix_linux_nightly_6_0_enabled }}
116
+ LINUX_NIGHTLY_MAIN_ENABLED : ${{ inputs.matrix_linux_nightly_main_enabled }}
117
+ WINDOWS_6_0_ENABLED : ${{ inputs.matrix_windows_6_0_enabled }}
118
+ WINDOWS_NIGHTLY_6_0_ENABLED : ${{ inputs.matrix_windows_nightly_6_0_enabled }}
119
+ WINDOWS_NIGHTLY_MAIN_ENABLED : ${{ inputs.matrix_windows_nightly_main_enabled }}
120
+ run : |
121
+ linux_matrix='{"swift": []}'
122
+ if [[ "${LINUX_5_9_ENABLED}" == "true" ]]; then
123
+ linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_5_9_container_image }}", "swift_version": "5.9" }')
124
+ fi
125
+
126
+ if [[ "${LINUX_5_10_ENABLED}" == "true" ]]; then
127
+ linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_5_10_container_image }}", "swift_version": "5.10" }')
128
+ fi
129
+
130
+ if [[ "${LINUX_6_0_ENABLED}" == "true" ]]; then
131
+ linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_6_0_container_image }}", "swift_version": "6.0" }')
132
+ fi
133
+
134
+ if [[ "${LINUX_NIGHTLY_6_0_ENABLED}" == "true" ]]; then
135
+ linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_nightly_6_0_container_image }}", "swift_version": "nightly-6.0" }')
136
+ fi
137
+
138
+ if [[ "${LINUX_NIGHTLY_MAIN_ENABLED}" == "true" ]]; then
139
+ linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_nightly_main_container_image }}", "swift_version": "nightly-main" }')
140
+ fi
141
+
142
+ {
143
+ echo 'linux-matrix<<EOF'
144
+ echo $linux_matrix
145
+ echo EOF
146
+ } >> "$GITHUB_OUTPUT"
147
+
148
+ windows_matrix='{"swift": []}'
149
+ if [[ "${WINDOWS_6_0_ENABLED}" == "true" ]]; then
150
+ windows_matrix=$(echo "$windows_matrix" | jq '.swift[.swift| length] |= . + { "image": "swift:6.0-windowsservercore-ltsc2022", "swift_version": "6.0" }')
151
+ fi
152
+
153
+ {
154
+ echo 'windows-matrix<<EOF'
155
+ echo $windows_matrix
156
+ echo EOF
157
+ } >> "$GITHUB_OUTPUT"
158
+
159
+ windows_nightly_matrix='{"swift": []}'
160
+ if [[ "${WINDOWS_NIGHTLY_6_0_ENABLED}" == "true" ]]; then
161
+ windows_nightly_matrix=$(echo "$windows_nightly_matrix" | jq '.swift[.swift| length] |= . + { "image": "swiftlang/swift:nightly-6.0-windowsservercore-1809", "swift_version": "nightly-6.0" }')
162
+ fi
163
+
164
+ if [[ "${WINDOWS_NIGHTLY_MAIN_ENABLED}" == "true" ]]; then
165
+ windows_nightly_matrix=$(echo "$windows_nightly_matrix" | jq '.swift[.swift| length] |= . + { "image": "swiftlang/swift:nightly-main-windowsservercore-1809", "swift_version": "nightly-main" }')
166
+ fi
167
+
168
+ {
169
+ echo 'windows-nightly-matrix<<EOF'
170
+ echo $windows_nightly_matrix
171
+ echo EOF
172
+ } >> "$GITHUB_OUTPUT"
173
+ - name : Echo matrix configuration
174
+ run : |
175
+ echo "${{ steps.set-matrix.outputs.linux-matrix }}"
176
+ echo "${{ steps.set-matrix.outputs.windows-matrix }}"
177
+ echo "${{ steps.set-matrix.outputs.windows-nightly-matrix }}"
178
+
102
179
linux :
103
180
name : Linux (${{ matrix.swift.swift_version }})
181
+ needs : generate-matrix
104
182
runs-on : ubuntu-latest
105
183
strategy :
106
184
fail-fast : false
107
- matrix :
108
- # We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
109
- swift :
110
- - image : ${{ inputs.matrix_linux_5_9_container_image }}
111
- swift_version : " 5.9"
112
- enabled : ${{ inputs.matrix_linux_5_9_enabled }}
113
- - image : ${{ inputs.matrix_linux_5_10_container_image }}
114
- swift_version : " 5.10"
115
- enabled : ${{ inputs.matrix_linux_5_10_enabled }}
116
- - image : ${{ inputs.matrix_linux_6_0_container_image }}
117
- swift_version : " 6.0"
118
- enabled : ${{ inputs.matrix_linux_6_0_enabled }}
119
- - image : ${{ inputs.matrix_linux_nightly_6_0_container_image }}
120
- swift_version : " nightly-6.0"
121
- enabled : ${{ inputs.matrix_linux_nightly_6_0_enabled }}
122
- - image : ${{ inputs.matrix_linux_nightly_main_container_image }}
123
- swift_version : " nightly-main"
124
- enabled : ${{ inputs.matrix_linux_nightly_main_enabled }}
185
+ matrix : ${{fromJson(needs.generate-matrix.outputs.linux-matrix)}}
125
186
container :
126
187
image : ${{ matrix.swift.image }}
127
188
steps :
128
189
- name : Checkout repository
129
- if : ${{ matrix.swift.enabled }}
130
190
uses : actions/checkout@v4
131
191
with :
132
192
persist-credentials : false
133
193
- name : Mark the workspace as safe
134
- if : ${{ matrix.swift.enabled }}
135
194
# https://github.com/actions/checkout/issues/766
136
195
run : git config --global --add safe.directory ${GITHUB_WORKSPACE}
137
196
- name : Run matrix job
138
- if : ${{ matrix.swift.enabled }}
139
197
env :
140
198
SWIFT_VERSION : ${{ matrix.swift.swift_version }}
141
199
COMMAND : ${{ inputs.matrix_linux_command }}
@@ -150,59 +208,40 @@ jobs:
150
208
151
209
windows :
152
210
name : Windows (${{ matrix.swift.swift_version }})
211
+ needs : generate-matrix
153
212
runs-on : windows-2022
154
213
strategy :
155
214
fail-fast : false
156
- matrix :
157
- # We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
158
- swift :
159
- - image : swift:6.0-windowsservercore-ltsc2022
160
- swift_version : " 6.0"
161
- enabled : ${{ inputs.matrix_windows_6_0_enabled }}
215
+ matrix : ${{fromJson(needs.generate-matrix.outputs.windows-matrix)}}
162
216
steps :
163
217
- name : Pull Docker image
164
- if : ${{ matrix.swift.enabled }}
165
218
run : docker pull ${{ matrix.swift.image }}
166
219
- name : Checkout repository
167
- if : ${{ matrix.swift.enabled }}
168
220
uses : actions/checkout@v4
169
221
with :
170
222
persist-credentials : false
171
223
- name : Donwload matrix script
172
- if : ${{ matrix.swift.enabled }}
173
224
run : curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
174
225
- name : Run matrix job
175
- if : ${{ matrix.swift.enabled }}
176
226
run : |
177
227
docker run --env SWIFT_VERSION="${{ matrix.swift.swift_version }}" --env COMMAND="${{ inputs.matrix_windows_command }}" --env COMMAND_OVERRIDE_6_0="${{ inputs.matrix_windows_6_0_command_override }}" -v ${{ github.workspace }}:C:\source ${{ matrix.swift.image }} cmd /s /c "swift --version & cd C:\source\ & powershell -File __check-matrix-job.ps1"
178
228
179
229
windows-nightly :
180
230
name : Windows (${{ matrix.swift.swift_version }})
231
+ needs : generate-matrix
181
232
runs-on : windows-2019
182
233
strategy :
183
234
fail-fast : false
184
- matrix :
185
- # We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
186
- swift :
187
- - image : swiftlang/swift:nightly-6.0-windowsservercore-1809
188
- swift_version : " nightly-6.0"
189
- enabled : ${{ inputs.matrix_windows_nightly_6_0_enabled }}
190
- - image : swiftlang/swift:nightly-main-windowsservercore-1809
191
- swift_version : " nightly-main"
192
- enabled : ${{ inputs.matrix_windows_nightly_main_enabled }}
235
+ matrix : ${{fromJson(needs.generate-matrix.outputs.windows-nightly-matrix)}}
193
236
steps :
194
237
- name : Pull Docker image
195
- if : ${{ matrix.swift.enabled }}
196
238
run : docker pull ${{ matrix.swift.image }}
197
239
- name : Checkout repository
198
- if : ${{ matrix.swift.enabled }}
199
240
uses : actions/checkout@v4
200
241
with :
201
242
persist-credentials : false
202
243
- name : Donwload matrix script
203
- if : ${{ matrix.swift.enabled }}
204
244
run : curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
205
245
- name : Run matrix job
206
- if : ${{ matrix.swift.enabled }}
207
246
run : |
208
247
docker run --env SWIFT_VERSION="${{ matrix.swift.swift_version }}" --env COMMAND="${{ inputs.matrix_windows_command }}" --env COMMAND_OVERRIDE_NIGHTLY_6_0="${{ inputs.matrix_windows_nightly_6_0_command_override }}" --env COMMAND_OVERRIDE_NIGHTLY_MAIN="${{ inputs.matrix_windows_nightly_main_command_override }}" -v ${{ github.workspace }}:C:\source ${{ matrix.swift.image }} cmd /s /c "swift --version & cd C:\source\ & powershell -File __check-matrix-job.ps1"
0 commit comments