Skip to content

Commit 1eb066d

Browse files
committed
[CI] Change how we define the matrix
# Motivation # Modification # Result
1 parent be823e6 commit 1eb066d

File tree

3 files changed

+90
-84
lines changed

3 files changed

+90
-84
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,14 @@ on:
55
types: [opened, reopened, synchronize]
66

77
jobs:
8-
soundness:
9-
name: Soundness
10-
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
11-
with:
12-
license_header_check_project_name: "SwiftNIO"
13-
# We need to move to 6.0 here but have to fix the new warnings first
14-
docs_check_container_image: "swift:5.10-noble"
158

169
unit-tests:
1710
name: Unit tests
1811
# Workaround https://github.com/nektos/act/issues/1875
19-
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
12+
uses: ./.github/workflows/unit_tests.yml
2013
with:
2114
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
2215
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
2316
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
2417
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
2518
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
26-
27-
benchmarks:
28-
name: Benchmarks
29-
# Workaround https://github.com/nektos/act/issues/1875
30-
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
31-
with:
32-
benchmark_package_path: "Benchmarks"
33-
34-
cxx-interop:
35-
name: Cxx interop
36-
# Workaround https://github.com/nektos/act/issues/1875
37-
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
38-
39-
integration-tests:
40-
name: Integration Tests
41-
# Workaround https://github.com/nektos/act/issues/1875
42-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
43-
with:
44-
name: "Integration tests"
45-
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq && ./scripts/integration_tests.sh"
46-
47-
swift-6-language-mode:
48-
name: Swift 6 Language Mode
49-
# Workaround https://github.com/nektos/act/issues/1875
50-
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main

.github/workflows/swift_matrix.yml

Lines changed: 85 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ on:
7474
matrix_windows_6_0_enabled:
7575
type: boolean
7676
description: "Boolean to enable the 6.0 Swift version matrix job. Defaults to true."
77-
default: false
77+
default: true
7878
matrix_windows_6_0_command_override:
7979
type: string
8080
description: "The command of the 6.0 Swift version windows matrix job to execute."
8181
matrix_windows_nightly_6_0_enabled:
8282
type: boolean
8383
description: "Boolean to enable the nightly 6.0 Swift version matrix job. Defaults to true."
84-
default: false
84+
default: true
8585
matrix_windows_nightly_6_0_command_override:
8686
type: string
8787
description: "The command of the nightly 6.0 Swift version windows matrix job to execute."
8888
matrix_windows_nightly_main_enabled:
8989
type: boolean
9090
description: "Boolean to enable the nightly main Swift version matrix job. Defaults to true."
91-
default: false
91+
default: true
9292
matrix_windows_nightly_main_command_override:
9393
type: string
9494
description: "The command of the nightly main Swift version windows matrix job to execute."
@@ -99,43 +99,100 @@ concurrency:
9999
cancel-in-progress: true
100100

101101
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+
102178
linux:
103179
name: Linux (${{ matrix.swift.swift_version }})
180+
needs: generate-matrix
104181
runs-on: ubuntu-latest
105182
strategy:
106183
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)}}
125185
container:
126186
image: ${{ matrix.swift.image }}
127187
steps:
128188
- name: Checkout repository
129-
if: ${{ matrix.swift.enabled }}
130189
uses: actions/checkout@v4
131190
with:
132191
persist-credentials: false
133192
- name: Mark the workspace as safe
134-
if: ${{ matrix.swift.enabled }}
135193
# https://github.com/actions/checkout/issues/766
136194
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
137195
- name: Run matrix job
138-
if: ${{ matrix.swift.enabled }}
139196
env:
140197
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
141198
COMMAND: ${{ inputs.matrix_linux_command }}
@@ -150,59 +207,40 @@ jobs:
150207
151208
windows:
152209
name: Windows (${{ matrix.swift.swift_version }})
210+
needs: generate-matrix
153211
runs-on: windows-2022
154212
strategy:
155213
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)}}
162215
steps:
163216
- name: Pull Docker image
164-
if: ${{ matrix.swift.enabled }}
165217
run: docker pull ${{ matrix.swift.image }}
166218
- name: Checkout repository
167-
if: ${{ matrix.swift.enabled }}
168219
uses: actions/checkout@v4
169220
with:
170221
persist-credentials: false
171222
- name: Donwload matrix script
172-
if: ${{ matrix.swift.enabled }}
173223
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
174224
- name: Run matrix job
175-
if: ${{ matrix.swift.enabled }}
176225
run: |
177226
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"
178227
179228
windows-nightly:
180229
name: Windows (${{ matrix.swift.swift_version }})
230+
needs: generate-matrix
181231
runs-on: windows-2019
182232
strategy:
183233
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)}}
193235
steps:
194236
- name: Pull Docker image
195-
if: ${{ matrix.swift.enabled }}
196237
run: docker pull ${{ matrix.swift.image }}
197238
- name: Checkout repository
198-
if: ${{ matrix.swift.enabled }}
199239
uses: actions/checkout@v4
200240
with:
201241
persist-credentials: false
202242
- name: Donwload matrix script
203-
if: ${{ matrix.swift.enabled }}
204243
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
205244
- name: Run matrix job
206-
if: ${{ matrix.swift.enabled }}
207245
run: |
208246
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"

.github/workflows/unit_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,23 @@ on:
4747
windows_6_0_enabled:
4848
type: boolean
4949
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to true."
50-
default: false
50+
default: true
5151
windows_6_0_arguments_override:
5252
type: string
5353
description: "The arguments passed to swift test in the Windows 6.0 Swift version matrix job."
5454
default: ""
5555
windows_nightly_6_0_enabled:
5656
type: boolean
5757
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to true."
58-
default: false
58+
default: true
5959
windows_nightly_6_0_arguments_override:
6060
type: string
6161
description: "The arguments passed to swift test in the Windows nightly 6.0 Swift version matrix job."
6262
default: ""
6363
windows_nightly_main_enabled:
6464
type: boolean
6565
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to true."
66-
default: false
66+
default: true
6767
windows_nightly_main_arguments_override:
6868
type: string
6969
description: "The arguments passed to swift test in the Windows nightly main Swift version matrix job."
@@ -73,7 +73,7 @@ jobs:
7373
unit-tests:
7474
name: Unit tests
7575
# Workaround https://github.com/nektos/act/issues/1875
76-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
76+
uses: ./.github/workflows/swift_matrix.yml
7777
with:
7878
name: "Unit tests"
7979
matrix_linux_command: "swift test"

0 commit comments

Comments
 (0)