From b080a2e5108bf2482732e73555a468e911a50b5b Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 17 Nov 2025 22:19:43 -0800 Subject: [PATCH] [CI] Add support for GitHub Actions # Conflicts: # .github/workflows/pull_request.yml --- .github/scripts/prebuild.sh | 19 ------------------- .github/workflows/pull_request.yml | 16 +++++++++++----- Sources/Basics/Concurrency/AsyncProcess.swift | 12 ++++++++++-- .../LibraryEvolutionXCFLinuxTests.swift | 2 ++ Tests/IntegrationTests/SwiftPMTests.swift | 2 +- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/.github/scripts/prebuild.sh b/.github/scripts/prebuild.sh index 1cd6d3cd298..f275643bd75 100755 --- a/.github/scripts/prebuild.sh +++ b/.github/scripts/prebuild.sh @@ -46,25 +46,6 @@ elif command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy if [[ "$INSTALL_CMAKE" == "1" ]] ; then apt-get install -y cmake ninja-build fi - - # Android NDK - dpkg_architecture="$(dpkg --print-architecture)" - if [[ "$SKIP_ANDROID" != "1" ]] && [[ "$dpkg_architecture" == amd64 ]] ; then - eval "$(cat /etc/os-release)" - case "$VERSION_CODENAME" in - bookworm|jammy) - : # Not available - ;; - noble) - apt-get install -y google-android-ndk-r26c-installer - ;; - *) - echo "Unable to fetch Android NDK for unknown Linux distribution: $VERSION_CODENAME" >&2 - exit 1 - esac - else - echo "Skipping Android NDK installation on $dpkg_architecture" >&2 - fi elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 dnf update -y diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 881f66b67b5..b7b72989f49 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -15,18 +15,24 @@ jobs: tests: name: Test uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + needs: [soundness] with: linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]' - linux_swift_versions: '["nightly-main"]' linux_pre_build_command: ./.github/scripts/prebuild.sh - linux_build_command: 'swift build' - windows_swift_versions: '["nightly-main"]' + linux_build_command: 'swift build --build-tests' + linux_swift_versions: '["nightly-main"]' windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1' - windows_build_command: 'Invoke-Program swift build' + windows_swift_versions: '["nightly-main"]' + windows_build_command: 'Invoke-Program swift build --build-tests' + enable_android_sdk_build: true + android_sdk_build_command: "swift build --build-tests" + android_ndk_versions: '["r27d", "r29"]' + android_sdk_triples: '["aarch64-unknown-linux-android28"]' enable_ios_checks: true enable_macos_checks: true macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]" - macos_build_command: 'swift build' + macos_pre_build_command: ./.github/scripts/prebuild.sh + macos_build_command: 'swift build --build-tests' soundness: name: Soundness diff --git a/Sources/Basics/Concurrency/AsyncProcess.swift b/Sources/Basics/Concurrency/AsyncProcess.swift index 17149e833bc..849614189f0 100644 --- a/Sources/Basics/Concurrency/AsyncProcess.swift +++ b/Sources/Basics/Concurrency/AsyncProcess.swift @@ -25,9 +25,13 @@ import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported @_implementationOnly import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np + +@_implementationOnly +import func TSCclibc.SPM_posix_spawnp #else -private import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported -private import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np +package import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported +package import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np +package import func TSCclibc.SPM_posix_spawnp #endif // #if USE_IMPL_ONLY_IMPORTS #endif @@ -687,7 +691,11 @@ package final class AsyncProcess { } let argv = CStringArray(resolvedArgs) let env = CStringArray(environment.map { "\($0.0)=\($0.1)" }) + #if canImport(Darwin) let rv = posix_spawnp(&self.processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray) + #else + let rv = SPM_posix_spawnp(&self.processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray) + #endif guard rv == 0 else { throw SystemError.posix_spawn(rv, self.arguments) diff --git a/Tests/FunctionalTests/LibraryEvolutionXCFLinuxTests.swift b/Tests/FunctionalTests/LibraryEvolutionXCFLinuxTests.swift index b441c1a83f9..dca99d59141 100644 --- a/Tests/FunctionalTests/LibraryEvolutionXCFLinuxTests.swift +++ b/Tests/FunctionalTests/LibraryEvolutionXCFLinuxTests.swift @@ -35,6 +35,8 @@ private struct SwiftPMTests { let arch = "aarch64" #elseif arch(x86_64) let arch = "x86_64" + #else + preconditionFailure("Unsupported platform or host arch for test") #endif let platform = "linux" diff --git a/Tests/IntegrationTests/SwiftPMTests.swift b/Tests/IntegrationTests/SwiftPMTests.swift index b8cf10ecc85..a20e3aea8d4 100644 --- a/Tests/IntegrationTests/SwiftPMTests.swift +++ b/Tests/IntegrationTests/SwiftPMTests.swift @@ -216,7 +216,7 @@ private struct SwiftPMTests { #elseif arch(arm64) hostArch = "arm64" #else - precondition("Unsupported platform or host arch for test") + preconditionFailure("Unsupported platform or host arch for test") #endif switch buildSystem { case .native: