Skip to content

Commit fd38e3c

Browse files
committed
Add support for macOS platform (default: false)
1 parent 40c6b00 commit fd38e3c

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

.github/workflows/pull_request.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ jobs:
2222
swift package init --type library
2323
swift build
2424
enable_windows_docker: true
25+
# macOS
26+
enable_macos_checks: true
27+
macos_build_command: |
28+
mkdir MyPackage
29+
cd MyPackage
30+
swift package init --type library
31+
swift build
2532
2633
tests_without_docker:
2734
name: Test without Docker

.github/workflows/swift_package_test.yml

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

33
on:
44
workflow_call:
55
inputs:
6+
macos_exclude_xcode_versions:
7+
type: string
8+
description: "Exclude Xcode version list (JSON)"
9+
default: "[{\"xcode_version\": \"\"}]"
10+
macos_versions:
11+
type: string
12+
description: "macOS version list (JSON)"
13+
default: "[\"sequoia\"]"
14+
macos_archs:
15+
type: string
16+
description: "macOS arch list (JSON)"
17+
default: "[\"ARM64\"]"
618
linux_exclude_swift_versions:
719
type: string
820
description: "Exclude Linux Swift version list (JSON)"
@@ -27,6 +39,14 @@ on:
2739
type: string
2840
description: "Linux command to execute before building the Swift package"
2941
default: ""
42+
macos_pre_build_command:
43+
type: string
44+
description: "macOS command to execute before building the Swift package"
45+
default: ""
46+
macos_build_command:
47+
type: string
48+
description: "macOS command to build and test the package"
49+
default: "swift test"
3050
linux_build_command:
3151
type: string
3252
description: "Linux command to build and test the package"
@@ -42,6 +62,9 @@ on:
4262
Note that Powershell does not automatically exit if a subcommand fails. The Invoke-Program utility is available to propagate non-zero exit codes.
4363
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`.
4464
default: "swift test"
65+
macos_env_vars:
66+
description: "Newline separated list of environment variables"
67+
type: string
4568
linux_env_vars:
4669
description: "Newline separated list of environment variables"
4770
type: string
@@ -52,6 +75,10 @@ on:
5275
type: boolean
5376
description: "Boolean to enable linux testing. Defaults to true"
5477
default: true
78+
enable_macos_checks:
79+
type: boolean
80+
description: "Boolean to enable linux testing. Defaults to false"
81+
default: false
5582
enable_windows_checks:
5683
type: boolean
5784
description: "Boolean to enable windows testing. Defaults to true"
@@ -66,6 +93,40 @@ on:
6693
default: false
6794

6895
jobs:
96+
macos-build:
97+
name: macOS (Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
98+
if: ${{ inputs.enable_macos_checks }}
99+
runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"]
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
xcode_version: ['15.4', '16.0', '16.1', '16.2']
104+
os_version: ${{ fromJson(inputs.macos_versions) }}
105+
arch: ${{ fromJson(inputs.macos_archs) }}
106+
exclude:
107+
- ${{ fromJson(inputs.macos_exclude_xcode_versions) }}
108+
steps:
109+
- name: Checkout repository
110+
uses: actions/checkout@v4
111+
- name: Provide token
112+
if: ${{ inputs.needs_token }}
113+
run: |
114+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
115+
- name: Set environment variables
116+
if: ${{ inputs.macos_env_vars }}
117+
run: |
118+
for i in "${{ inputs.macos_env_vars }}"
119+
do
120+
printf "%s\n" $i >> $GITHUB_ENV
121+
done
122+
echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
123+
- name: Swift version
124+
run: swift --version
125+
- name: Pre-build
126+
run: ${{ inputs.macos_pre_build_command }}
127+
- name: Build / Test
128+
run: ${{ inputs.macos_build_command }}
129+
69130
linux-build:
70131
name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
71132
if: ${{ inputs.enable_linux_checks }}

0 commit comments

Comments
 (0)