Skip to content

Commit dff412d

Browse files
committed
Add macOS nightly build support via Swiftly
Adds a new opt-in macos-swiftly-build job that pairs an Xcode version with a Swiftly-managed Swift toolchain (defaulting to main-snapshot), since xcrun cannot see toolchains that Swiftly selects on PATH.
1 parent 09c1d32 commit dff412d

2 files changed

Lines changed: 56 additions & 0 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+
swift build
8286
8387
build_tests_ios:
8488
name: Build iOS Tests

.github/workflows/swift_package_test.yml

Lines changed: 52 additions & 0 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: "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"
@@ -313,6 +325,46 @@ 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" >> $GITHUB_ENV
354+
- name: Install Swift toolchain via Swiftly
355+
run: |
356+
swiftly install ${{ matrix.swift_version }}
357+
swiftly use ${{ matrix.swift_version }}
358+
- name: Swift version
359+
run: swiftly run swift --version
360+
- name: Pre-build
361+
# zizmor: ignore[template-injection]
362+
run: ${{ inputs.macos_pre_build_command }}
363+
- name: Build / Test
364+
# zizmor: ignore[template-injection]
365+
run: swiftly run ${{ inputs.macos_swiftly_build_command }} ${{ (contains(matrix.swift_version, 'snapshot') && inputs.swift_nightly_flags) || inputs.swift_flags }}
366+
timeout-minutes: ${{ inputs.macos_build_timeout }}
367+
316368
ios-build:
317369
name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
318370
if: ${{ inputs.enable_ios_checks }}

0 commit comments

Comments
 (0)