Skip to content

fix macOS CI Swiftly XCTest handling - #923

Merged
ktoso merged 1 commit into
swiftlang:mainfrom
Hokila:fix-macos-ci-xctest
Sep 25, 2026
Merged

ktoso merged 1 commit into
swiftlang:mainfrom
Hokila:fix-macos-ci-xctest

Conversation

@Hokila

@Hokila Hokila commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Make the macOS Swift CI job reliable: keep Swiftly for the Swift 6.3 production build and use the Xcode toolchain for both test modes.

Problem

The original job failed during Swift Build:

SwiftSyntaxMacrosTestSupport/Assertions.swift:19:16: error: no such module 'XCTest'

Failed job: https://github.com/swiftlang/swift-java/actions/runs/35585778520/job/107554476812?pr=922

PR #921 PR #922
Result Passed Failed
macOS 26.5.2 26.6.2
Runner 2.336.0 2.337.0
Swiftly Swift 6.3.3 Swift 6.3.3
Swift Build swift build --build-tests swift build --build-tests

Both runs used the same Swiftly version and build command, but XCTest discovery behaved differently. This shows that relying on XCTest discovery from the Swiftly standalone toolchain is environment-dependent.

Changes

  • Keep the macOS Install Swiftly step.
  • Build production targets with Swiftly:
    swift build --disable-sandbox
  • Prepend Xcode Swift to PATH before tests so SwiftPM build plugins use the same toolchain.
  • Run Swift Testing with the Xcode toolchain:
    xcrun swift test --disable-xctest
  • Run XCTest with the Xcode toolchain:
    xcrun swift test --disable-experimental-swift-testing

The Swift Build step no longer uses --build-tests. SwiftPM still compiles XCTest test targets when --disable-xctest is set, so both test modes use Xcode Swift to make XCTest available. The build plugin also invokes swift through PATH; putting Xcode Swift first prevents it from writing a Swiftly configuration error instead of static-build-config.json.

Validation

  • Reproduced no such module 'XCTest' with Swiftly 6.3.3 and swift test --disable-xctest in a small package containing XCTest and Swift Testing targets. Both Xcode test modes passed on that package.
  • Reproduced the build plugin writing a Swiftly configuration error instead of JSON when xcrun swift test inherited a Swiftly-first PATH; verified that an Xcode-first PATH produces valid JSON.
  • Completed a clean local rebuild with Xcode Swift first in PATH: xcrun swift test --disable-xctest passed 691 Swift Testing tests; xcrun swift test --disable-experimental-swift-testing passed 117 XCTest tests (1 skipped). Gradle 9.4.0 bootstrapped successfully for the Java integration tests.

@Hokila
Hokila requested a review from ktoso as a code owner September 24, 2026 15:04
@Hokila
Hokila marked this pull request as draft September 24, 2026 15:09
@Hokila Hokila changed the title CI: disable XCTest when building macOS tests [WIP] fix tests fail Sep 24, 2026
@Hokila
Hokila force-pushed the fix-macos-ci-xctest branch from 3b5a31e to 53f796d Compare September 24, 2026 15:58
@Hokila Hokila changed the title [WIP] fix tests fail fix macOS CI Swiftly XCTest handling Sep 24, 2026
@Hokila
Hokila marked this pull request as ready for review September 24, 2026 16:04
Swiftly on macOS can fail to import XCTest while compiling test support. Keep the Swiftly build focused on production targets and run both test modes with Xcode Swift.

SwiftPM build plugins invoke swift through PATH, so prepend Xcode Swift before tests; otherwise the static build config plugin may write a Swiftly configuration error instead of JSON.
@Hokila
Hokila force-pushed the fix-macos-ci-xctest branch from 85781d9 to d9e0bb8 Compare September 25, 2026 08:08
@ktoso
ktoso merged commit d6ff36c into swiftlang:main Sep 25, 2026
@ktoso

ktoso commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants