Support Windows platform for Swift package testing #15
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Swift Linux Matrix | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| linux_exclude_swift_versions: | ||
| type: string | ||
| description: "Exclude Linux Swift version list (JSON)" | ||
| default: "[{\"swift_version\": \"\"}]" | ||
| linux_os_versions: | ||
| type: string | ||
| description: "Linux OS version list (JSON)" | ||
| default: "[\"jammy\"]" | ||
| windows_exclude_swift_versions: | ||
| type: string | ||
| description: "Exclude Windows Swift version list (JSON)" | ||
| default: "[{\"swift_version\": \"\"}]" | ||
| swift_flags: | ||
| type: string | ||
| description: "Swift flags for release version" | ||
| default: "" | ||
| swift_nightly_flags: | ||
| type: string | ||
| description: "Swift flags for nightly version" | ||
| default: "" | ||
| linux_pre_build_command: | ||
| type: string | ||
| description: "Linux command to execute before building the Swift package" | ||
| default: "" | ||
| linux_build_command: | ||
| type: string | ||
| description: "Linux Build command default is swift test" | ||
| default: "swift test" | ||
| windows_build_command: | ||
| type: string | ||
| description: "Linux Build command default is swift test" | ||
| default: "swift test" | ||
| env_vars: | ||
| description: "List of environment variables" | ||
| type: string | ||
| enable_windows: | ||
| type: boolean | ||
| description: "Boolean to enable the acceptable language check job. Defaults to true." | ||
| default: true | ||
| jobs: | ||
| linux-build: | ||
| name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }}) | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| swift_version: ['5.8', '5.9', '5.10', '6.0', 'nightly-main', 'nightly-6.0'] | ||
| os_version: ${{ fromJson(inputs.linux_os_versions) }} | ||
| exclude: | ||
| - ${{ fromJson(inputs.linux_exclude_swift_versions) }} | ||
| container: | ||
| image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }} | ||
| steps: | ||
| - name: Swift version | ||
| run: swift --version | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Set environment variables | ||
| if: ${{ inputs.env_vars }} | ||
| run: | | ||
| for i in "${{ inputs.env_vars }}" | ||
| do | ||
| printf "%s\n" $i >> $GITHUB_ENV | ||
| done | ||
| - name: Pre-build | ||
| run: ${{ inputs.linux_pre_build_command }} | ||
| - name: Build / Test | ||
| run: ${{ inputs.linux_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} | ||
| windows-build: | ||
| name: Windows (${{ matrix.swift_version }} - ${{ matrix.os_version }}) | ||
| if: ${{ inputs.enable_windows }} | ||
| runs-on: windows-2022 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| swift_version: ['5.9', '5.10', '6.0'] | ||
| exclude: | ||
| - ${{ fromJson(inputs.windows_exclude_swift_versions) }} | ||
| steps: | ||
| - name: Pull Docker image | ||
| run: docker pull swift:${{ matrix.swift_version }}-windowsservercore-ltsc2022 | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Build / Test | ||
| run: docker run -v ${{ github.workspace }}:C:\source swift:${{ matrix.swift_version }}-windowsservercore-ltsc2022 cmd /s /c "swift --version & swift test --version & cd C:\source\ ${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}" | ||