Files
swift-nio/.github/workflows/swift_matrix.yml
Franz Busch 8d19278bde Wait for the docker daemon on Windows (#3520)
Sometimes the docker daemon on Windows runners isn't ready immediately.
This adds a step to wait for it to become ready.
2026-02-26 10:18:47 +01:00

264 lines
12 KiB
YAML

name: Matrix
permissions:
contents: read
on:
workflow_call:
inputs:
name:
type: string
description: "The name of the workflow used for the concurrency group."
required: true
matrix_linux_command:
type: string
description: "The command of the current Swift version linux matrix job to execute."
required: true
matrix_linux_5_9_enabled:
type: boolean
description: "Boolean to enable the 5.9 Swift version matrix job. Defaults to false."
default: false
matrix_linux_5_9_container_image:
type: string
description: "Container image for the 5.9 Swift version matrix job. Defaults to matching Swift Ubuntu image."
default: "swift:5.9-jammy"
matrix_linux_5_9_command_override:
type: string
description: "The command of the 5.9 Swift version linux matrix job to execute."
matrix_linux_5_10_enabled:
type: boolean
description: "Boolean to enable the 5.10 Swift version matrix job. Defaults to true."
default: true
matrix_linux_5_10_container_image:
type: string
description: "Container image for the 5.10 Swift version matrix job. Defaults to matching Swift Ubuntu image."
default: "swift:5.10-jammy"
matrix_linux_5_10_command_override:
type: string
description: "The command of the 5.10 Swift version linux matrix job to execute."
matrix_linux_6_0_enabled:
type: boolean
description: "Boolean to enable the 6.0 Swift version matrix job. Defaults to true."
default: true
matrix_linux_6_0_container_image:
type: string
description: "Container image for the 6.0 Swift version matrix job. Defaults to matching Swift Ubuntu image."
default: "swift:6.0-jammy"
matrix_linux_6_0_command_override:
type: string
description: "The command of the 6.0 Swift version linux matrix job to execute."
matrix_linux_nightly_6_0_enabled:
type: boolean
description: "⚠️ Deprecated, we no longer run against 6.0 nightly."
default: true
matrix_linux_nightly_6_0_container_image:
type: string
description: "⚠️ Deprecated, we no longer run against 6.0 nightly."
default: "swiftlang/swift:nightly-6.0-jammy"
matrix_linux_nightly_6_0_command_override:
type: string
description: "⚠️ Deprecated, we no longer run against 6.0 nightly."
matrix_linux_nightly_6_1_enabled:
type: boolean
description: "Boolean to enable the nightly 6.1 Swift version matrix job. Defaults to true."
default: true
matrix_linux_nightly_6_1_container_image:
type: string
description: "Container image for the nightly 6.1 Swift version matrix job. Defaults to matching Swift Ubuntu image."
default: "swiftlang/swift:nightly-6.1-jammy"
matrix_linux_nightly_6_1_command_override:
type: string
description: "The command of the nightly 6.1 Swift version linux matrix job to execute."
matrix_linux_nightly_main_enabled:
type: boolean
description: "Boolean to enable the nightly main Swift version matrix job. Defaults to true."
default: true
matrix_linux_nightly_main_container_image:
type: string
description: "Container image for the nightly main Swift version matrix job. Defaults to matching Swift Ubuntu image."
default: "swiftlang/swift:nightly-main-jammy"
matrix_linux_nightly_main_command_override:
type: string
description: "The command of the nightly main Swift version linux matrix job to execute."
matrix_windows_command:
type: string
description: "The command of the current Swift version windows matrix job to execute."
default: ""
matrix_windows_6_0_enabled:
type: boolean
description: "Boolean to enable the 6.0 Swift version matrix job. Defaults to true."
default: false
matrix_windows_6_0_command_override:
type: string
description: "The command of the 6.0 Swift version windows matrix job to execute."
matrix_windows_nightly_6_0_enabled:
type: boolean
description: "⚠️ Deprecated, we no longer run against 6.0 nightly."
default: false
matrix_windows_nightly_6_0_command_override:
type: string
description: "⚠️ Deprecated, we no longer run against 6.0 nightly."
matrix_windows_nightly_6_1_enabled:
type: boolean
description: "Boolean to enable the nightly 6.1 Swift version matrix job. Defaults to true."
default: false
matrix_windows_nightly_6_1_command_override:
type: string
description: "The command of the nightly 6.1 Swift version windows matrix job to execute."
matrix_windows_nightly_main_enabled:
type: boolean
description: "Boolean to enable the nightly main Swift version matrix job. Defaults to true."
default: false
matrix_windows_nightly_main_command_override:
type: string
description: "The command of the nightly main Swift version windows matrix job to execute."
# We are cancelling previously triggered workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
cancel-in-progress: true
jobs:
linux:
name: Linux (${{ matrix.swift.swift_version }})
runs-on: ubuntu-latest
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: ${{ inputs.matrix_linux_5_9_container_image }}
swift_version: "5.9"
enabled: ${{ inputs.matrix_linux_5_9_enabled }}
- image: ${{ inputs.matrix_linux_5_10_container_image }}
swift_version: "5.10"
enabled: ${{ inputs.matrix_linux_5_10_enabled }}
- image: ${{ inputs.matrix_linux_6_0_container_image }}
swift_version: "6.0"
enabled: ${{ inputs.matrix_linux_6_0_enabled }}
- image: ${{ inputs.matrix_linux_nightly_6_1_container_image }}
swift_version: "nightly-6.1"
enabled: ${{ inputs.matrix_linux_nightly_6_1_enabled }}
- image: ${{ inputs.matrix_linux_nightly_main_container_image }}
swift_version: "nightly-main"
enabled: ${{ inputs.matrix_linux_nightly_main_enabled }}
container:
image: ${{ matrix.swift.image }}
steps:
- name: Checkout repository
if: ${{ matrix.swift.enabled }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Mark the workspace as safe
if: ${{ matrix.swift.enabled }}
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Run matrix job
if: ${{ matrix.swift.enabled }}
env:
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
COMMAND: ${{ inputs.matrix_linux_command }}
COMMAND_OVERRIDE_5_9: ${{ inputs.matrix_linux_5_9_command_override }}
COMMAND_OVERRIDE_5_10: ${{ inputs.matrix_linux_5_10_command_override }}
COMMAND_OVERRIDE_6_0: ${{ inputs.matrix_linux_6_0_command_override }}
COMMAND_OVERRIDE_NIGHTLY_6_1: ${{ inputs.matrix_linux_nightly_6_1_command_override }}
COMMAND_OVERRIDE_NIGHTLY_MAIN: ${{ inputs.matrix_linux_nightly_main_command_override }}
run: |
apt-get -qq update && apt-get -qq -y install curl
curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash
windows:
name: Windows (${{ matrix.swift.swift_version }})
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 }}
steps:
- name: Wait for Docker daemon
if: ${{ matrix.swift.enabled }}
run: |
$maxAttempts = 30
$attempt = 0
do {
$attempt++
docker info 2>&1 | Out-Null
if ($LASTEXITCODE -eq 0) { break }
if ($attempt -ge $maxAttempts) {
Write-Error "Docker daemon did not become ready after $maxAttempts attempts"
exit 1
}
Start-Sleep -Seconds 2
} while ($true)
shell: pwsh
- name: Pull Docker image
if: ${{ matrix.swift.enabled }}
run: docker pull ${{ matrix.swift.image }}
- name: Checkout repository
if: ${{ matrix.swift.enabled }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Donwload matrix script
if: ${{ matrix.swift.enabled }}
run: curl -s --retry 3 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"
windows-nightly:
name: Windows (${{ matrix.swift.swift_version }})
runs-on: windows-2019
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: swiftlang/swift:nightly-6.1-windowsservercore-1809
swift_version: "nightly-6.1"
enabled: ${{ inputs.matrix_windows_nightly_6_1_enabled }}
- image: swiftlang/swift:nightly-main-windowsservercore-1809
swift_version: "nightly-main"
enabled: ${{ inputs.matrix_windows_nightly_main_enabled }}
steps:
- name: Wait for Docker daemon
if: ${{ matrix.swift.enabled }}
run: |
$maxAttempts = 30
$attempt = 0
do {
$attempt++
docker info 2>&1 | Out-Null
if ($LASTEXITCODE -eq 0) { break }
if ($attempt -ge $maxAttempts) {
Write-Error "Docker daemon did not become ready after $maxAttempts attempts"
exit 1
}
Start-Sleep -Seconds 2
} while ($true)
shell: pwsh
- name: Pull Docker image
if: ${{ matrix.swift.enabled }}
run: docker pull ${{ matrix.swift.image }}
- name: Checkout repository
if: ${{ matrix.swift.enabled }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Donwload matrix script
if: ${{ matrix.swift.enabled }}
run: curl -s --retry 3 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_NIGHTLY_6_1="${{ inputs.matrix_windows_nightly_6_1_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"