Skip to content

Commit 7dc951e

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

File tree

3 files changed

+47
-44
lines changed

3 files changed

+47
-44
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: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,31 +148,66 @@ jobs:
148148
apt-get -qq update && apt-get -qq -y install curl
149149
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash
150150
151+
generate-matrix:
152+
runs-on: ubuntu-latest
153+
outputs:
154+
linux-matrix: ${{ steps.set-matrix.outputs.linux-matrix }}
155+
windows-matrix: ${{ steps.set-matrix.outputs.windows-matrix }}
156+
windows-nightly-matrix: ${{ steps.set-matrix.outputs.windows-nightly-matrix }}
157+
steps:
158+
- id: set-matrix
159+
env:
160+
LINUX_5_9_ENABLED: ${{ inputs.matrix_linux_5_9_enabled }}
161+
LINUX_5_10_ENABLED: ${{ inputs.matrix_linux_5_10_enabled }}
162+
LINUX_6_0_ENABLED: ${{ inputs.matrix_linux_6_0_enabled }}
163+
LINUX_NIGHTLY_6_0_ENABLED: ${{ inputs.matrix_linux_nightly_6_0_enabled }}
164+
LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.matrix_linux_nightly_main_enabled }}
165+
WINDOWS_6_0_ENABLED: ${{ inputs.matrix_windows_6_0_enabled }}
166+
WINDOWS_NIGHTLY_6_0_ENABLED: ${{ inputs.matrix_windows_nightly_6_0_enabled }}
167+
WINDOWS_NIGHTLY_MAIN_ENABLED: ${{ inputs.matrix_windows_nightly_main_enabled }}
168+
run: |
169+
linux_matrix='{"swift": []}'
170+
if [[ "${LINUX_5_9_ENABLED}" == "true" ]]; then
171+
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_5_9_container_image }}", "swift_version": "5.9" }')
172+
elif [[ "${LINUX_5_10_ENABLED}" == "true" ]]; then
173+
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_5_10_container_image }}", "swift_version": "5.10" }')
174+
elif [[ "${LINUX_6_0_ENABLED}" == "true" ]]; then
175+
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_6_0_container_image }}", "swift_version": "6.0" }')
176+
elif [[ "${LINUX_NIGHTLY_6_0_ENABLED}" == "true" ]]; then
177+
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_nightly_6_0_container_image }}", "swift_version": "nightly-6.0" }')
178+
elif [[ "${LINUX_NIGHTLY_MAIN_ENABLED}" == "true" ]]; then
179+
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_nightly_main_container_image }}", "swift_version": "nightly-main" }')
180+
fi
181+
182+
{
183+
echo 'linx-matrix<<EOF'
184+
echo $linux_matrix
185+
echo EOF
186+
} >> "$GITHUB_OUTPUT"
187+
188+
echo "$GITHUB_OUTPUT"
189+
- run: |
190+
echo "${{ steps.set-matrix.outputs.linux-matrix }}"
191+
echo "${{ steps.set-matrix.outputs.windows-matrix }}"
192+
echo "${{ steps.set-matrix.outputs.windows-nightly-matrix }}"
193+
151194
windows:
152195
name: Windows (${{ matrix.swift.swift_version }})
196+
needs: generate-matrix
153197
runs-on: windows-2022
154198
strategy:
155199
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 }}
200+
matrix: ${{fromJson(needs.generate-matrix.outputs.windows-matrix)}}
162201
steps:
163202
- name: Pull Docker image
164-
if: ${{ matrix.swift.enabled }}
165203
run: docker pull ${{ matrix.swift.image }}
166204
- name: Checkout repository
167-
if: ${{ matrix.swift.enabled }}
168205
uses: actions/checkout@v4
169206
with:
170207
persist-credentials: false
171208
- name: Donwload matrix script
172-
if: ${{ matrix.swift.enabled }}
173209
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
174210
- name: Run matrix job
175-
if: ${{ matrix.swift.enabled }}
176211
run: |
177212
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"
178213

.github/workflows/unit_tests.yml

Lines changed: 1 addition & 1 deletion
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)