Skip to content

Commit f1ef0dc

Browse files
authored
Add workflow to build packages for iOS. (#169)
* Add workflow to build packages for iOS. Add workflow to build packages for iOS on a macOS VM. Can't run tests at this time, but we can at least confirm source compiles. * Build script can just use pwd instead of a child directory maybe * Rename tests_ios
1 parent 6e10732 commit f1ef0dc

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

.github/workflows/pull_request.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ jobs:
8080
xcrun swift package init --type library
8181
xcrun swift build
8282
83+
build_tests_ios:
84+
name: Build iOS Tests
85+
uses: ./.github/workflows/swift_package_test.yml
86+
with:
87+
enable_linux_checks: false
88+
enable_windows_checks: false
89+
# iOS
90+
enable_ios_checks: true
91+
ios_pre_build_command: |
92+
pwd
93+
xcrun swift package init --type library
94+
8395
soundness:
8496
name: Soundness
8597
uses: ./.github/workflows/soundness.yml

.github/workflows/swift_package_test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ on:
2222
type: string
2323
description: "macOS arch list (JSON)"
2424
default: "[\"ARM64\"]"
25+
ios_host_xcode_versions:
26+
type: string
27+
description: "Xcode version list (JSON)"
28+
default: null
29+
ios_host_exclude_xcode_versions:
30+
type: string
31+
description: "Exclude Xcode version list (JSON)"
32+
default: null
33+
ios_host_versions:
34+
type: string
35+
description: "iOS host (macOS) version list (JSON)"
36+
default: null
37+
ios_host_archs:
38+
type: string
39+
description: "iOS host (macOS) arch list (JSON)"
40+
default: null
2541
linux_swift_versions:
2642
type: string
2743
description: "Include Linux Swift version list (JSON)"
@@ -87,6 +103,14 @@ on:
87103
type: string
88104
description: "macOS command to build and test the package"
89105
default: "xcrun swift test"
106+
ios_pre_build_command:
107+
type: string
108+
description: "macOS command to execute before building the Swift package for iOS"
109+
default: ""
110+
ios_build_command:
111+
type: string
112+
description: "macOS command to build the package for iOS"
113+
default: "xcrun swift build --build-tests --sdk \"$(xcrun --sdk iphoneos --show-sdk-path)\" --triple arm64-apple-ios"
90114
linux_build_command:
91115
type: string
92116
description: "Linux command to build and test the package"
@@ -113,6 +137,9 @@ on:
113137
macos_env_vars:
114138
description: "Newline separated list of environment variables"
115139
type: string
140+
ios_host_env_vars:
141+
description: "Newline separated list of environment variables"
142+
type: string
116143
linux_env_vars:
117144
description: "Newline separated list of environment variables"
118145
type: string
@@ -139,6 +166,10 @@ on:
139166
type: boolean
140167
description: "Boolean to enable macOS testing. Defaults to false"
141168
default: false
169+
enable_ios_checks:
170+
type: boolean
171+
description: "Boolean to enable iOS testing. Defaults to false"
172+
default: false
142173
enable_windows_checks:
143174
type: boolean
144175
description: "Boolean to enable windows testing. Defaults to true"
@@ -195,6 +226,42 @@ jobs:
195226
run: ${{ inputs.macos_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
196227
timeout-minutes: 60
197228

229+
ios-build:
230+
name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
231+
if: ${{ inputs.enable_ios_checks }}
232+
runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"]
233+
strategy:
234+
fail-fast: false
235+
matrix:
236+
xcode_version: ${{ fromJson(inputs.ios_host_xcode_versions || inputs.macos_xcode_versions) }}
237+
os_version: ${{ fromJson(inputs.ios_host_versions || inputs.macos_versions) }}
238+
arch: ${{ fromJson(inputs.ios_host_archs || inputs.macos_archs) }}
239+
exclude:
240+
- ${{ fromJson(inputs.ios_host_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }}
241+
steps:
242+
- name: Checkout repository
243+
uses: actions/checkout@v4
244+
- name: Provide token
245+
if: ${{ inputs.needs_token }}
246+
run: |
247+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
248+
- name: Set environment variables
249+
if: ${{ inputs.ios_host_env_vars }}
250+
run: |
251+
for i in "${{ inputs.ios_host_env_vars }}"
252+
do
253+
printf "%s\n" $i >> $GITHUB_ENV
254+
done
255+
- name: Select Xcode
256+
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
257+
- name: Swift version
258+
run: xcrun swift --version
259+
- name: Pre-build
260+
run: ${{ inputs.ios_pre_build_command }}
261+
- name: Build
262+
run: ${{ inputs.ios_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
263+
timeout-minutes: 60
264+
198265
linux-build:
199266
name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
200267
if: ${{ inputs.enable_linux_checks }}

0 commit comments

Comments
 (0)