|
1 |
| -name: Swift Linux Matrix |
| 1 | +name: Swift Matrix |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | workflow_call:
|
5 | 5 | inputs:
|
| 6 | + macos_xcode_versions: |
| 7 | + type: string |
| 8 | + description: "Xcode version list (JSON)" |
| 9 | + default: "[\"16.0\", \"16.1\", \"16.2\", \"16.3\"]" |
| 10 | + macos_exclude_xcode_versions: |
| 11 | + type: string |
| 12 | + description: "Exclude Xcode version list (JSON)" |
| 13 | + default: "[{\"xcode_version\": \"\"}]" |
| 14 | + macos_versions: |
| 15 | + type: string |
| 16 | + description: "macOS version list (JSON)" |
| 17 | + default: "[\"sequoia\"]" |
| 18 | + macos_archs: |
| 19 | + type: string |
| 20 | + description: "macOS arch list (JSON)" |
| 21 | + default: "[\"ARM64\"]" |
6 | 22 | linux_swift_versions:
|
7 | 23 | type: string
|
8 | 24 | description: "Include Linux Swift version list (JSON)"
|
|
35 | 51 | type: string
|
36 | 52 | description: "Linux command to execute before building the Swift package"
|
37 | 53 | default: ""
|
| 54 | + macos_pre_build_command: |
| 55 | + type: string |
| 56 | + description: "macOS command to execute before building the Swift package" |
| 57 | + default: "" |
| 58 | + macos_build_command: |
| 59 | + type: string |
| 60 | + description: "macOS command to build and test the package" |
| 61 | + default: "xcrun swift test" |
38 | 62 | linux_build_command:
|
39 | 63 | type: string
|
40 | 64 | description: "Linux command to build and test the package"
|
|
50 | 74 | Note that Powershell does not automatically exit if a subcommand fails. The Invoke-Program utility is available to propagate non-zero exit codes.
|
51 | 75 | It is strongly encouraged to run all command using `Invoke-Program` unless you want to continue on error eg. `Invoke-Program git apply patch.diff` instead of `git apply patch.diff`.
|
52 | 76 | default: "swift test"
|
| 77 | + macos_env_vars: |
| 78 | + description: "Newline separated list of environment variables" |
| 79 | + type: string |
53 | 80 | linux_env_vars:
|
54 | 81 | description: "Newline separated list of environment variables"
|
55 | 82 | type: string
|
|
60 | 87 | type: boolean
|
61 | 88 | description: "Boolean to enable linux testing. Defaults to true"
|
62 | 89 | default: true
|
| 90 | + enable_macos_checks: |
| 91 | + type: boolean |
| 92 | + description: "Boolean to enable macOS testing. Defaults to false" |
| 93 | + default: false |
63 | 94 | enable_windows_checks:
|
64 | 95 | type: boolean
|
65 | 96 | description: "Boolean to enable windows testing. Defaults to true"
|
|
74 | 105 | default: false
|
75 | 106 |
|
76 | 107 | jobs:
|
| 108 | + macos-build: |
| 109 | + name: macOS (Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) |
| 110 | + if: ${{ inputs.enable_macos_checks }} |
| 111 | + runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"] |
| 112 | + strategy: |
| 113 | + fail-fast: false |
| 114 | + matrix: |
| 115 | + xcode_version: ${{ fromJson(inputs.macos_xcode_versions) }} |
| 116 | + os_version: ${{ fromJson(inputs.macos_versions) }} |
| 117 | + arch: ${{ fromJson(inputs.macos_archs) }} |
| 118 | + exclude: |
| 119 | + - ${{ fromJson(inputs.macos_exclude_xcode_versions) }} |
| 120 | + steps: |
| 121 | + - name: Checkout repository |
| 122 | + uses: actions/checkout@v4 |
| 123 | + - name: Provide token |
| 124 | + if: ${{ inputs.needs_token }} |
| 125 | + run: | |
| 126 | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV |
| 127 | + - name: Set environment variables |
| 128 | + if: ${{ inputs.macos_env_vars }} |
| 129 | + run: | |
| 130 | + for i in "${{ inputs.macos_env_vars }}" |
| 131 | + do |
| 132 | + printf "%s\n" $i >> $GITHUB_ENV |
| 133 | + done |
| 134 | + - name: Select Xcode |
| 135 | + run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV |
| 136 | + - name: Swift version |
| 137 | + run: xcrun swift --version |
| 138 | + - name: Pre-build |
| 139 | + run: ${{ inputs.macos_pre_build_command }} |
| 140 | + - name: Build / Test |
| 141 | + run: ${{ inputs.macos_build_command }} |
| 142 | + |
77 | 143 | linux-build:
|
78 | 144 | name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
|
79 | 145 | if: ${{ inputs.enable_linux_checks }}
|
|
0 commit comments