Skip to content

Commit 7e71d77

Browse files
authored
Merge pull request #108 from swiftlang/macos-support
Add support for macOS platform (default: false)
2 parents c1cfd45 + 229a7c3 commit 7e71d77

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

.github/workflows/pull_request.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ jobs:
3737
swift build
3838
enable_windows_docker: false
3939

40+
tests_macos:
41+
name: Test
42+
uses: ./.github/workflows/swift_package_test.yml
43+
with:
44+
enable_linux_checks: false
45+
enable_windows_checks: false
46+
# macOS
47+
enable_macos_checks: true
48+
macos_build_command: |
49+
mkdir MyPackage
50+
cd MyPackage
51+
xcrun swift package init --type library
52+
xcrun swift build
53+
4054
soundness:
4155
name: Soundness
4256
uses: ./.github/workflows/soundness.yml

.github/workflows/swift_package_test.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
name: Swift Linux Matrix
1+
name: Swift Matrix
22

33
on:
44
workflow_call:
55
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\"]"
622
linux_swift_versions:
723
type: string
824
description: "Include Linux Swift version list (JSON)"
@@ -35,6 +51,14 @@ on:
3551
type: string
3652
description: "Linux command to execute before building the Swift package"
3753
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"
3862
linux_build_command:
3963
type: string
4064
description: "Linux command to build and test the package"
@@ -50,6 +74,9 @@ on:
5074
Note that Powershell does not automatically exit if a subcommand fails. The Invoke-Program utility is available to propagate non-zero exit codes.
5175
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`.
5276
default: "swift test"
77+
macos_env_vars:
78+
description: "Newline separated list of environment variables"
79+
type: string
5380
linux_env_vars:
5481
description: "Newline separated list of environment variables"
5582
type: string
@@ -60,6 +87,10 @@ on:
6087
type: boolean
6188
description: "Boolean to enable linux testing. Defaults to true"
6289
default: true
90+
enable_macos_checks:
91+
type: boolean
92+
description: "Boolean to enable macOS testing. Defaults to false"
93+
default: false
6394
enable_windows_checks:
6495
type: boolean
6596
description: "Boolean to enable windows testing. Defaults to true"
@@ -74,6 +105,41 @@ on:
74105
default: false
75106

76107
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+
77143
linux-build:
78144
name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
79145
if: ${{ inputs.enable_linux_checks }}

0 commit comments

Comments
 (0)