Skip to content

Commit df9e44e

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

File tree

3 files changed

+85
-78
lines changed

3 files changed

+85
-78
lines changed

.github/workflows/pull_request.yml

+1-33
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

+83-44
Original file line numberDiff line numberDiff line change
@@ -99,43 +99,101 @@ concurrency:
9999
cancel-in-progress: true
100100

101101
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+
102179
linux:
103180
name: Linux (${{ matrix.swift.swift_version }})
181+
needs: generate-matrix
104182
runs-on: ubuntu-latest
105183
strategy:
106184
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)}}
125186
container:
126187
image: ${{ matrix.swift.image }}
127188
steps:
128189
- name: Checkout repository
129-
if: ${{ matrix.swift.enabled }}
130190
uses: actions/checkout@v4
131191
with:
132192
persist-credentials: false
133193
- name: Mark the workspace as safe
134-
if: ${{ matrix.swift.enabled }}
135194
# https://github.com/actions/checkout/issues/766
136195
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
137196
- name: Run matrix job
138-
if: ${{ matrix.swift.enabled }}
139197
env:
140198
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
141199
COMMAND: ${{ inputs.matrix_linux_command }}
@@ -150,59 +208,40 @@ jobs:
150208
151209
windows:
152210
name: Windows (${{ matrix.swift.swift_version }})
211+
needs: generate-matrix
153212
runs-on: windows-2022
154213
strategy:
155214
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)}}
162216
steps:
163217
- name: Pull Docker image
164-
if: ${{ matrix.swift.enabled }}
165218
run: docker pull ${{ matrix.swift.image }}
166219
- name: Checkout repository
167-
if: ${{ matrix.swift.enabled }}
168220
uses: actions/checkout@v4
169221
with:
170222
persist-credentials: false
171223
- name: Donwload matrix script
172-
if: ${{ matrix.swift.enabled }}
173224
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
174225
- name: Run matrix job
175-
if: ${{ matrix.swift.enabled }}
176226
run: |
177227
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"
178228
179229
windows-nightly:
180230
name: Windows (${{ matrix.swift.swift_version }})
231+
needs: generate-matrix
181232
runs-on: windows-2019
182233
strategy:
183234
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)}}
193236
steps:
194237
- name: Pull Docker image
195-
if: ${{ matrix.swift.enabled }}
196238
run: docker pull ${{ matrix.swift.image }}
197239
- name: Checkout repository
198-
if: ${{ matrix.swift.enabled }}
199240
uses: actions/checkout@v4
200241
with:
201242
persist-credentials: false
202243
- name: Donwload matrix script
203-
if: ${{ matrix.swift.enabled }}
204244
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
205245
- name: Run matrix job
206-
if: ${{ matrix.swift.enabled }}
207246
run: |
208247
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -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)