Skip to content

Commit b4f8b6a

Browse files
authored
Add macOS nightly build support via Swiftly (#301)
1 parent 09c1d32 commit b4f8b6a

2 files changed

Lines changed: 65 additions & 2 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ jobs:
7979
macos_build_command: |
8080
cd tests/TestPackage
8181
xcrun swift build
82+
enable_macos_swiftly_checks: true
83+
macos_swiftly_build_command: |
84+
cd tests/TestPackage
85+
swiftly run swift build
8286
8387
build_tests_ios:
8488
name: Build iOS Tests

.github/workflows/swift_package_test.yml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ on:
2222
type: string
2323
description: "macOS arch list (JSON)"
2424
default: "[\"ARM64\"]"
25+
macos_swiftly_toolchains:
26+
type: string
27+
description: "List of macOS Swiftly toolchain builds to test, each pairing an Xcode version with a Swiftly-managed Swift toolchain (JSON list of objects with xcode_version, swift_version, os_version, arch)"
28+
default: "[{\"xcode_version\": \"26.4\", \"swift_version\": \"main-snapshot\", \"os_version\": \"tahoe\", \"arch\": \"ARM64\"}]"
2529
ios_host_xcode_versions:
2630
type: string
2731
description: "Xcode version list (JSON)"
@@ -139,6 +143,10 @@ on:
139143
type: string
140144
description: "macOS command to build and test the package"
141145
default: "xcrun swift test"
146+
macos_swiftly_build_command:
147+
type: string
148+
description: "macOS command to build and test the package when using a Swiftly-managed toolchain (run via `swiftly run`, so it should not use `xcrun`)"
149+
default: "swiftly run swift test"
142150
macos_build_timeout:
143151
type: number
144152
description: "The default step timeout in minutes"
@@ -245,6 +253,10 @@ on:
245253
type: boolean
246254
description: "Boolean to enable macOS testing. Defaults to false"
247255
default: false
256+
enable_macos_swiftly_checks:
257+
type: boolean
258+
description: "Boolean to enable macOS testing with Swiftly-managed toolchains (e.g. nightly snapshots). Defaults to false"
259+
default: false
248260
enable_ios_checks:
249261
type: boolean
250262
description: "Boolean to enable iOS testing. Defaults to false"
@@ -300,7 +312,7 @@ jobs:
300312
printf "%s\n" $i >> $GITHUB_ENV
301313
done
302314
- name: Select Xcode
303-
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
315+
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
304316
- name: Swift version
305317
run: xcrun swift --version
306318
- name: Clang version
@@ -313,6 +325,53 @@ jobs:
313325
run: ${{ inputs.macos_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
314326
timeout-minutes: ${{ inputs.macos_build_timeout }}
315327

328+
macos-swiftly-build:
329+
name: macOS via Swiftly (Xcode ${{ matrix.xcode_version }} + ${{ matrix.swift_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
330+
if: ${{ inputs.enable_macos_swiftly_checks }}
331+
runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"]
332+
strategy:
333+
fail-fast: false
334+
matrix:
335+
include: ${{ fromJson(inputs.macos_swiftly_toolchains) }}
336+
steps:
337+
- name: Checkout repository
338+
uses: actions/checkout@v7
339+
- name: Provide token
340+
if: ${{ inputs.needs_token }}
341+
run: |
342+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
343+
- name: Set environment variables
344+
if: ${{ inputs.macos_env_vars }}
345+
env:
346+
ENV_VARS: ${{ inputs.macos_env_vars }}
347+
run: |
348+
for i in "${ENV_VARS}"
349+
do
350+
printf "%s\n" $i >> $GITHUB_ENV
351+
done
352+
- name: Select Xcode
353+
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
354+
- name: Set up Swiftly environment
355+
run: |
356+
. "$HOME/.swiftly/env.sh"
357+
echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $GITHUB_ENV
358+
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $GITHUB_ENV
359+
echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> $GITHUB_ENV
360+
echo "$SWIFTLY_BIN_DIR" >> $GITHUB_PATH
361+
- name: Install Swift toolchain via Swiftly
362+
run: |
363+
swiftly install ${{ matrix.swift_version }}
364+
swiftly use ${{ matrix.swift_version }}
365+
- name: Swift version
366+
run: swiftly run swift --version
367+
- name: Pre-build
368+
# zizmor: ignore[template-injection]
369+
run: ${{ inputs.macos_pre_build_command }}
370+
- name: Build / Test
371+
# zizmor: ignore[template-injection]
372+
run: ${{ inputs.macos_swiftly_build_command }} ${{ (contains(matrix.swift_version, 'snapshot') && inputs.swift_nightly_flags) || inputs.swift_flags }}
373+
timeout-minutes: ${{ inputs.macos_build_timeout }}
374+
316375
ios-build:
317376
name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
318377
if: ${{ inputs.enable_ios_checks }}
@@ -342,7 +401,7 @@ jobs:
342401
printf "%s\n" $i >> $GITHUB_ENV
343402
done
344403
- name: Select Xcode
345-
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
404+
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
346405
- name: Swift version
347406
run: |
348407
"$(xcrun -f swift)" --version

0 commit comments

Comments
 (0)