From fd38e3c7824bbf69a3c4fd4fd496ec737fdd7782 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 14 Mar 2025 23:25:49 -0700 Subject: [PATCH 1/7] Add support for macOS platform (default: false) --- .github/workflows/pull_request.yml | 7 +++ .github/workflows/swift_package_test.yml | 63 +++++++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ea40b328..1a4be27a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -22,6 +22,13 @@ jobs: swift package init --type library swift build enable_windows_docker: true + # macOS + enable_macos_checks: true + macos_build_command: | + mkdir MyPackage + cd MyPackage + swift package init --type library + swift build tests_without_docker: name: Test without Docker diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index b61a8f37..4d57aa46 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -1,8 +1,20 @@ -name: Swift Linux Matrix +name: Swift Matrix on: workflow_call: inputs: + macos_exclude_xcode_versions: + type: string + description: "Exclude Xcode version list (JSON)" + default: "[{\"xcode_version\": \"\"}]" + macos_versions: + type: string + description: "macOS version list (JSON)" + default: "[\"sequoia\"]" + macos_archs: + type: string + description: "macOS arch list (JSON)" + default: "[\"ARM64\"]" linux_exclude_swift_versions: type: string description: "Exclude Linux Swift version list (JSON)" @@ -27,6 +39,14 @@ on: type: string description: "Linux command to execute before building the Swift package" default: "" + macos_pre_build_command: + type: string + description: "macOS command to execute before building the Swift package" + default: "" + macos_build_command: + type: string + description: "macOS command to build and test the package" + default: "swift test" linux_build_command: type: string description: "Linux command to build and test the package" @@ -42,6 +62,9 @@ on: Note that Powershell does not automatically exit if a subcommand fails. The Invoke-Program utility is available to propagate non-zero exit codes. 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`. default: "swift test" + macos_env_vars: + description: "Newline separated list of environment variables" + type: string linux_env_vars: description: "Newline separated list of environment variables" type: string @@ -52,6 +75,10 @@ on: type: boolean description: "Boolean to enable linux testing. Defaults to true" default: true + enable_macos_checks: + type: boolean + description: "Boolean to enable linux testing. Defaults to false" + default: false enable_windows_checks: type: boolean description: "Boolean to enable windows testing. Defaults to true" @@ -66,6 +93,40 @@ on: default: false jobs: + macos-build: + name: macOS (Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) + if: ${{ inputs.enable_macos_checks }} + runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"] + strategy: + fail-fast: false + matrix: + xcode_version: ['15.4', '16.0', '16.1', '16.2'] + os_version: ${{ fromJson(inputs.macos_versions) }} + arch: ${{ fromJson(inputs.macos_archs) }} + exclude: + - ${{ fromJson(inputs.macos_exclude_xcode_versions) }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Provide token + if: ${{ inputs.needs_token }} + run: | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + - name: Set environment variables + if: ${{ inputs.macos_env_vars }} + run: | + for i in "${{ inputs.macos_env_vars }}" + do + printf "%s\n" $i >> $GITHUB_ENV + done + echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV + - name: Swift version + run: swift --version + - name: Pre-build + run: ${{ inputs.macos_pre_build_command }} + - name: Build / Test + run: ${{ inputs.macos_build_command }} + linux-build: name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }}) if: ${{ inputs.enable_linux_checks }} From 61f0b6100a5b1e9278f2651eb9c97289e9609f48 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 14 Mar 2025 23:30:53 -0700 Subject: [PATCH 2/7] Clean up the test name --- .github/workflows/pull_request.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1a4be27a..194ec34a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -22,13 +22,6 @@ jobs: swift package init --type library swift build enable_windows_docker: true - # macOS - enable_macos_checks: true - macos_build_command: | - mkdir MyPackage - cd MyPackage - swift package init --type library - swift build tests_without_docker: name: Test without Docker @@ -44,6 +37,18 @@ jobs: swift build enable_windows_docker: false + tests_macos: + name: Test + uses: ./.github/workflows/swift_package_test.yml + with: + # macOS + enable_macos_checks: true + macos_build_command: | + mkdir MyPackage + cd MyPackage + swift package init --type library + swift build + soundness: name: Soundness uses: ./.github/workflows/soundness.yml From 2209c353ad27b72c567b03a509ed3d93d006035e Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 14 Mar 2025 23:47:10 -0700 Subject: [PATCH 3/7] Disable Linux and Windows check in macOS testing --- .github/workflows/pull_request.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 194ec34a..8b8925a7 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -41,6 +41,8 @@ jobs: name: Test uses: ./.github/workflows/swift_package_test.yml with: + enable_linux_checks: false + enable_windows_checks: false # macOS enable_macos_checks: true macos_build_command: | From 482f7f0832f810e1aad086dd8588bcad7d6d4b7f Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 14 Mar 2025 23:52:59 -0700 Subject: [PATCH 4/7] Add xcrun to swift commands --- .github/workflows/pull_request.yml | 4 ++-- .github/workflows/swift_package_test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8b8925a7..b408255a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -48,8 +48,8 @@ jobs: macos_build_command: | mkdir MyPackage cd MyPackage - swift package init --type library - swift build + xcrun swift package init --type library + xcrun swift build soundness: name: Soundness diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 4d57aa46..9d127fcd 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -46,7 +46,7 @@ on: macos_build_command: type: string description: "macOS command to build and test the package" - default: "swift test" + default: "xcrun swift test" linux_build_command: type: string description: "Linux command to build and test the package" @@ -121,7 +121,7 @@ jobs: done echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV - name: Swift version - run: swift --version + run: xcrun swift --version - name: Pre-build run: ${{ inputs.macos_pre_build_command }} - name: Build / Test From f31ba17b6192e4b50649f8d91a774ee882b47d55 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Sat, 15 Mar 2025 00:00:40 -0700 Subject: [PATCH 5/7] Set DEVELOPER_DIR --- .github/workflows/swift_package_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 9d127fcd..83253df9 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -119,7 +119,8 @@ jobs: do printf "%s\n" $i >> $GITHUB_ENV done - echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV + - name: Select Xcode + run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV - name: Swift version run: xcrun swift --version - name: Pre-build From 48772665ddf75303ba2a797130efa61e2fda89b3 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 11 Apr 2025 01:16:26 -0700 Subject: [PATCH 6/7] Update .github/workflows/swift_package_test.yml --- .github/workflows/swift_package_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index a4210e82..10e9dfd3 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -6,7 +6,7 @@ on: macos_xcode_versions: type: string description: "Exclude Xcode version list (JSON)" - default: "[\"15.4\", \"16.0\", \"16.1\", \"16.2\"]" + default: "[\"16.0\", \"16.1\", \"16.2\"]" macos_exclude_xcode_versions: type: string description: "Exclude Xcode version list (JSON)" From 229a7c338d6e5255d51c466e1cf46ec144032b83 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 25 Apr 2025 12:45:57 -0700 Subject: [PATCH 7/7] Update swift_package_test.yml to include 16.3 and clean up typos --- .github/workflows/swift_package_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 10e9dfd3..68eb41b7 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -5,8 +5,8 @@ on: inputs: macos_xcode_versions: type: string - description: "Exclude Xcode version list (JSON)" - default: "[\"16.0\", \"16.1\", \"16.2\"]" + description: "Xcode version list (JSON)" + default: "[\"16.0\", \"16.1\", \"16.2\", \"16.3\"]" macos_exclude_xcode_versions: type: string description: "Exclude Xcode version list (JSON)" @@ -89,7 +89,7 @@ on: default: true enable_macos_checks: type: boolean - description: "Boolean to enable linux testing. Defaults to false" + description: "Boolean to enable macOS testing. Defaults to false" default: false enable_windows_checks: type: boolean