Skip to content

Commit

Permalink
[CI] Change how we define the matrix
Browse files Browse the repository at this point in the history
# Motivation

# Modification

# Result
  • Loading branch information
FranzBusch committed Oct 24, 2024
1 parent be823e6 commit 7dc951e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 44 deletions.
34 changes: 1 addition & 33 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,14 @@ on:
types: [opened, reopened, synchronize]

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

unit-tests:
name: Unit tests
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
uses: ./.github/workflows/unit_tests.yml
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

benchmarks:
name: Benchmarks
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
with:
benchmark_package_path: "Benchmarks"

cxx-interop:
name: Cxx interop
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main

integration-tests:
name: Integration Tests
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Integration tests"
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"

swift-6-language-mode:
name: Swift 6 Language Mode
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
55 changes: 45 additions & 10 deletions .github/workflows/swift_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,31 +148,66 @@ jobs:
apt-get -qq update && apt-get -qq -y install curl
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash
generate-matrix:
runs-on: ubuntu-latest
outputs:
linux-matrix: ${{ steps.set-matrix.outputs.linux-matrix }}
windows-matrix: ${{ steps.set-matrix.outputs.windows-matrix }}
windows-nightly-matrix: ${{ steps.set-matrix.outputs.windows-nightly-matrix }}
steps:
- id: set-matrix
env:
LINUX_5_9_ENABLED: ${{ inputs.matrix_linux_5_9_enabled }}
LINUX_5_10_ENABLED: ${{ inputs.matrix_linux_5_10_enabled }}
LINUX_6_0_ENABLED: ${{ inputs.matrix_linux_6_0_enabled }}
LINUX_NIGHTLY_6_0_ENABLED: ${{ inputs.matrix_linux_nightly_6_0_enabled }}
LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.matrix_linux_nightly_main_enabled }}
WINDOWS_6_0_ENABLED: ${{ inputs.matrix_windows_6_0_enabled }}
WINDOWS_NIGHTLY_6_0_ENABLED: ${{ inputs.matrix_windows_nightly_6_0_enabled }}
WINDOWS_NIGHTLY_MAIN_ENABLED: ${{ inputs.matrix_windows_nightly_main_enabled }}
run: |
linux_matrix='{"swift": []}'
if [[ "${LINUX_5_9_ENABLED}" == "true" ]]; then
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_5_9_container_image }}", "swift_version": "5.9" }')
elif [[ "${LINUX_5_10_ENABLED}" == "true" ]]; then
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_5_10_container_image }}", "swift_version": "5.10" }')
elif [[ "${LINUX_6_0_ENABLED}" == "true" ]]; then
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_6_0_container_image }}", "swift_version": "6.0" }')
elif [[ "${LINUX_NIGHTLY_6_0_ENABLED}" == "true" ]]; then
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_nightly_6_0_container_image }}", "swift_version": "nightly-6.0" }')
elif [[ "${LINUX_NIGHTLY_MAIN_ENABLED}" == "true" ]]; then
linux_matrix=$(echo "$linux_matrix" | jq '.swift[.swift| length] |= . + { "image": "${{ inputs.matrix_linux_nightly_main_container_image }}", "swift_version": "nightly-main" }')
fi
{
echo 'linx-matrix<<EOF'
echo $linux_matrix
echo EOF
} >> "$GITHUB_OUTPUT"
echo "$GITHUB_OUTPUT"
- run: |
echo "${{ steps.set-matrix.outputs.linux-matrix }}"
echo "${{ steps.set-matrix.outputs.windows-matrix }}"
echo "${{ steps.set-matrix.outputs.windows-nightly-matrix }}"
windows:
name: Windows (${{ matrix.swift.swift_version }})
needs: generate-matrix
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
# We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
swift:
- image: swift:6.0-windowsservercore-ltsc2022
swift_version: "6.0"
enabled: ${{ inputs.matrix_windows_6_0_enabled }}
matrix: ${{fromJson(needs.generate-matrix.outputs.windows-matrix)}}
steps:
- name: Pull Docker image
if: ${{ matrix.swift.enabled }}
run: docker pull ${{ matrix.swift.image }}
- name: Checkout repository
if: ${{ matrix.swift.enabled }}
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Donwload matrix script
if: ${{ matrix.swift.enabled }}
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
- name: Run matrix job
if: ${{ matrix.swift.enabled }}
run: |
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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
unit-tests:
name: Unit tests
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
uses: ./.github/workflows/swift_matrix.yml
with:
name: "Unit tests"
matrix_linux_command: "swift test"
Expand Down

0 comments on commit 7dc951e

Please sign in to comment.