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