From 4bef42af89ef7e20391986532b4cc2ebcd56aaca Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 17 Nov 2025 22:19:43 -0800 Subject: [PATCH 1/7] [CI] Add support for GitHub Actions --- .github/workflows/automerge.yml | 23 +++++++++++++++++++++ .github/workflows/pull_request.yml | 33 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000000..e773ad737f2 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,23 @@ +name: Create PR to merge main into release branch +# In the first period after branching the release branch, +# we typically want to include many changes from `main` in the release branch. +# This workflow automatically creates a PR to merge the main into the release branch. +# Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow. +# To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow +permissions: + contents: read +on: + schedule: + - cron: '0 9 * * MON' + workflow_dispatch: +jobs: + create_merge_pr: + name: Create PR to merge main into release branch + uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main + with: + head_branch: main + base_branch: release/6.3 + permissions: + contents: write + pull-requests: write + if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-package-manager') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000000..d47808355d0 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,33 @@ +name: Pull request + +permissions: + contents: read + +on: + pull_request: + types: [opened, reopened, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: Test + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + with: + linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]' + linux_swift_versions: '["nightly-main"]' + windows_swift_versions: '["nightly-main"]' + enable_android_sdk_build: true + android_sdk_build_command: "swift build --build-tests" + android_ndk_versions: '["r27d", "r29"]' + enable_ios_checks: true + enable_macos_checks: true + macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]" + + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + license_header_check_project_name: "Swift.org" From f69d3b1ce3999342fd78f388a7af0a45a3ab6599 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 17 Nov 2025 23:00:06 -0800 Subject: [PATCH 2/7] Fix the yml files to pass the linter --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 94 ++++++++++--------- .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml | 70 +++++++------- .github/workflows/pull_request.yml | 3 +- .../PackageRegistry/registry.openapi.yaml | 18 ++-- Utilities/Docker/docker-compose.yaml | 2 +- 5 files changed, 98 insertions(+), 89 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index ac3bd5b4867..43f67913d73 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -2,46 +2,54 @@ name: Bug Report description: Something isn't working as expected labels: [bug] body: -- type: checkboxes - id: cat-preferences - attributes: - label: "Is it reproducible with SwiftPM command-line tools: `swift build`, `swift test`, `swift package` etc?" - description: "Issues related to closed-source software are not tracked by this repository and will be closed. For Xcode and `xcodebuild`, please file a feedback at https://feedbackassistant.apple.com instead." - options: - - label: Confirmed reproduction steps with SwiftPM CLI. The description text _must_ include reproduction steps with either of command-line SwiftPM commands, `swift build`, `swift test`, `swift package` etc. - required: true -- type: textarea - attributes: - label: Description - validations: - required: true -- type: textarea - attributes: - label: Expected behavior - description: What you expected to happen. - validations: - required: false -- type: textarea - attributes: - label: Actual behavior - description: What actually happened. - validations: - required: false -- type: textarea - attributes: - label: Steps to reproduce - placeholder: | - 1. ... - 2. ... - validations: - required: false -- type: input - attributes: - label: Swift Package Manager version/commit hash - validations: - required: false -- type: textarea - attributes: - label: Swift & OS version (output of `swift --version ; uname -a`) - validations: - required: false + - type: checkboxes + id: cat-preferences + attributes: + label: >- + Is it reproducible with SwiftPM command-line tools: `swift build`, + `swift test`, `swift package` etc? + description: >- + Issues related to closed-source software are not tracked by this + repository and will be closed. For Xcode and `xcodebuild`, please + file a feedback at https://feedbackassistant.apple.com instead." + options: + - label: >- + Confirmed reproduction steps with SwiftPM CLI. The description + text _must_ include reproduction steps with either of command-line + SwiftPM commands, `swift build`, `swift test`, `swift package` etc. + required: true + - type: textarea + attributes: + label: Description + validations: + required: true + - type: textarea + attributes: + label: Expected behavior + description: What you expected to happen. + validations: + required: false + - type: textarea + attributes: + label: Actual behavior + description: What actually happened. + validations: + required: false + - type: textarea + attributes: + label: Steps to reproduce + placeholder: | + 1. ... + 2. ... + validations: + required: false + - type: input + attributes: + label: Swift Package Manager version/commit hash + validations: + required: false + - type: textarea + attributes: + label: Swift & OS version (output of `swift --version ; uname -a`) + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml index 7c2149d3d0a..054a093da11 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml @@ -2,38 +2,38 @@ name: Feature Request description: A suggestion for a new feature labels: [enhancement] body: -- type: textarea - attributes: - label: Description - validations: - required: true -- type: textarea - attributes: - label: Expected behavior - description: What you expected to happen. - validations: - required: false -- type: textarea - attributes: - label: Actual behavior - description: What actually happened. - validations: - required: false -- type: textarea - attributes: - label: Steps to reproduce - placeholder: | - 1. ... - 2. ... - validations: - required: false -- type: input - attributes: - label: Swift Package Manager version/commit hash - validations: - required: false -- type: textarea - attributes: - label: Swift & OS version (output of `swift --version && uname -a`) - validations: - required: false + - type: textarea + attributes: + label: Description + validations: + required: true + - type: textarea + attributes: + label: Expected behavior + description: What you expected to happen. + validations: + required: false + - type: textarea + attributes: + label: Actual behavior + description: What actually happened. + validations: + required: false + - type: textarea + attributes: + label: Steps to reproduce + placeholder: | + 1. ... + 2. ... + validations: + required: false + - type: input + attributes: + label: Swift Package Manager version/commit hash + validations: + required: false + - type: textarea + attributes: + label: Swift & OS version (output of `swift --version && uname -a`) + validations: + required: false diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d47808355d0..d769b8a38ee 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -18,6 +18,7 @@ jobs: with: linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]' linux_swift_versions: '["nightly-main"]' + linux_pre_build_command: 'curl -L https://raw.githubusercontent.com/swiftlang/swift-build/refs/heads/main/.github/scripts/prebuild.sh > prebuild.sh && sh prebuild.sh' windows_swift_versions: '["nightly-main"]' enable_android_sdk_build: true android_sdk_build_command: "swift build --build-tests" @@ -30,4 +31,4 @@ jobs: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: - license_header_check_project_name: "Swift.org" + license_header_check_project_name: "Swift" diff --git a/Documentation/PackageRegistry/registry.openapi.yaml b/Documentation/PackageRegistry/registry.openapi.yaml index 99f9b5ddb16..1ae22231c75 100644 --- a/Documentation/PackageRegistry/registry.openapi.yaml +++ b/Documentation/PackageRegistry/registry.openapi.yaml @@ -225,12 +225,12 @@ paths: schema: type: string description: |- - One value for each version-specific package manifest file in the release's source archive, + One value for each version-specific package manifest file in the release's source archive, whose filename matches the following regular expression pattern: `\APackage@swift-(\d+)(?:\.(\d+))?(?:\.(\d+))?.swift\z` - Each link value should have the alternate relation type, a filename attribute set to the version-specific package manifest filename - (for example, Package@swift-4.swift), and a swift-tools-version attribute set to the Swift tools version specified by the package + Each link value should have the alternate relation type, a filename attribute set to the version-specific package manifest filename + (for example, Package@swift-4.swift), and a swift-tools-version attribute set to the Swift tools version specified by the package manifest file (for example, 4.0 for a manifest beginning with the comment // swift-tools-version:4.0). content: text/x-swift: @@ -277,8 +277,8 @@ paths: type: string example: 'sha-256=oqxUzyX7wa0AKPA/CqS5aDO4O7BaFOUQiSuyfepNyBI=' Content-Disposition: - description: |- - A header set to attachment with a filename parameter equal to the name of the package followed by a hyphen (-), + description: |- + A header set to attachment with a filename parameter equal to the name of the package followed by a hyphen (-), the version number, and file extension (for example, "LinkedList-1.1.1.zip") schema: type: string @@ -455,7 +455,7 @@ components: PackageLinks: schema: type: string - description: |- + description: |- A set of related links. An example: @@ -583,13 +583,13 @@ components: format: uri description: |- A URI reference that identifies the problem type. - This specification encourages that, when dereferenced, + This specification encourages that, when dereferenced, it provides human-readable documentation for the problem type. example: 'https://example.com/problem/invalid-request-parameters' title: type: string description: |- - A short, human-readable summary of the problem type. + A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. example: 'Invalid request parameters' @@ -682,7 +682,7 @@ components: type: string format: date-time description: |- - The ISO 8601-formatted datetime string of when the package release was published, as recorded by the registry. + The ISO 8601-formatted datetime string of when the package release was published, as recorded by the registry. See related `originalPublicationTime` in metadata. required: - id diff --git a/Utilities/Docker/docker-compose.yaml b/Utilities/Docker/docker-compose.yaml index 7a6a42fc539..a0b899d60cc 100644 --- a/Utilities/Docker/docker-compose.yaml +++ b/Utilities/Docker/docker-compose.yaml @@ -27,7 +27,7 @@ services: - ~/.ssh:/root/.ssh - ~/.cache:/root/.cache - ~/.swiftpm/cache:/root/.swiftpm/cache - - ~/.swiftpm/configuration:/root/.swiftpm/config # old location, remove after 5.6 + - ~/.swiftpm/configuration:/root/.swiftpm/config # old location, remove after 5.6 - ~/.swiftpm/configuration:/root/.swiftpm/configuration - ~/.swiftpm/security:/root/.swiftpm/security # swift-package-manager code From 2b6f4c93c6dc42daafea9e85fd71769e501dcdf2 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 17 Nov 2025 23:06:48 -0800 Subject: [PATCH 3/7] Add script to install pre-build packages on Linux and Windows --- .github/scripts/prebuild.ps1 | 40 ++++++++++++++ .github/scripts/prebuild.sh | 85 ++++++++++++++++++++++++++++++ .github/workflows/pull_request.yml | 3 +- 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/prebuild.ps1 create mode 100755 .github/scripts/prebuild.sh diff --git a/.github/scripts/prebuild.ps1 b/.github/scripts/prebuild.ps1 new file mode 100644 index 00000000000..1e40dfa412c --- /dev/null +++ b/.github/scripts/prebuild.ps1 @@ -0,0 +1,40 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## + +param ( + [switch]$SkipAndroid, + [switch]$InstallCMake +) + +# winget isn't easily made available in containers, so use chocolatey +Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + +if ($InstallCMake) { + choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' --apply-install-arguments-to-dependencies + choco install -y ninja + + Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 + refreshenv + + # Let swiftc find the path to link.exe in the CMake smoke test + $env:Path += ";$(Split-Path -Path "$(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" "-latest" -products Microsoft.VisualStudio.Product.BuildTools -find VC\Tools\MSVC\*\bin\HostX64\x64\link.exe)" -Parent)" +} + +if (-not $SkipAndroid) { + choco install -y android-ndk + + Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 + refreshenv + + # Work around a bug in the package causing the env var to be set incorrectly + $env:ANDROID_NDK_ROOT = $env:ANDROID_NDK_ROOT.replace('-windows.zip','') +} diff --git a/.github/scripts/prebuild.sh b/.github/scripts/prebuild.sh new file mode 100755 index 00000000000..1cd6d3cd298 --- /dev/null +++ b/.github/scripts/prebuild.sh @@ -0,0 +1,85 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## + +set -e + +if [[ $(uname) == Darwin ]] ; then + if [[ "$INSTALL_CMAKE" == "1" ]] ; then + mkdir -p "$RUNNER_TOOL_CACHE" + if ! command -v cmake >/dev/null 2>&1 ; then + curl -fsSLO https://github.com/Kitware/CMake/releases/download/v4.1.2/cmake-4.1.2-macos-universal.tar.gz + echo '3be85f5b999e327b1ac7d804cbc9acd767059e9f603c42ec2765f6ab68fbd367 cmake-4.1.2-macos-universal.tar.gz' > cmake-4.1.2-macos-universal.tar.gz.sha256 + sha256sum -c cmake-4.1.2-macos-universal.tar.gz.sha256 + tar -xf cmake-4.1.2-macos-universal.tar.gz + ln -s "$PWD/cmake-4.1.2-macos-universal/CMake.app/Contents/bin/cmake" "$RUNNER_TOOL_CACHE/cmake" + fi + if ! command -v ninja >/dev/null 2>&1 ; then + curl -fsSLO https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-mac.zip + echo 'da7797794153629aca5570ef7c813342d0be214ba84632af886856e8f0063dd9 ninja-mac.zip' > ninja-mac.zip.sha256 + sha256sum -c ninja-mac.zip.sha256 + unzip ninja-mac.zip + rm -f ninja-mac.zip + mv ninja "$RUNNER_TOOL_CACHE/ninja" + fi + fi +elif command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy + export DEBIAN_FRONTEND=noninteractive + + apt-get update -y + + # Build dependencies + apt-get install -y libsqlite3-dev libncurses-dev + + # Debug symbols + apt-get install -y libc6-dbg + + 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 + + # Build dependencies + dnf install -y sqlite-devel ncurses-devel + + # Debug symbols + dnf debuginfo-install -y glibc +elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 + yum update -y + + # Build dependencies + yum install -y sqlite-devel ncurses-devel + + # Debug symbols + yum install -y yum-utils + debuginfo-install -y glibc +fi diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d769b8a38ee..fd35b216a13 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -18,8 +18,9 @@ jobs: with: linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]' linux_swift_versions: '["nightly-main"]' - linux_pre_build_command: 'curl -L https://raw.githubusercontent.com/swiftlang/swift-build/refs/heads/main/.github/scripts/prebuild.sh > prebuild.sh && sh prebuild.sh' + linux_pre_build_command: ./.github/scripts/prebuild.sh windows_swift_versions: '["nightly-main"]' + windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1' enable_android_sdk_build: true android_sdk_build_command: "swift build --build-tests" android_ndk_versions: '["r27d", "r29"]' From 04312b7c808594e29b7dbba62ab9e5d5ad1ab622 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 17 Nov 2025 23:14:12 -0800 Subject: [PATCH 4/7] Add license header template and ignore file --- .license_header_template | 11 +++++++++++ .licenseignore | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 .license_header_template create mode 100644 .licenseignore diff --git a/.license_header_template b/.license_header_template new file mode 100644 index 00000000000..52d6f2786e2 --- /dev/null +++ b/.license_header_template @@ -0,0 +1,11 @@ +@@===----------------------------------------------------------------------===@@ +@@ +@@ This source file is part of the Swift open source project +@@ +@@ Copyright (c) YEARS Apple Inc. and the Swift project authors +@@ Licensed under Apache License v2.0 with Runtime Library Exception +@@ +@@ See http://swift.org/LICENSE.txt for license information +@@ See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +@@ +@@===----------------------------------------------------------------------===@@ diff --git a/.licenseignore b/.licenseignore new file mode 100644 index 00000000000..e7babf0caf4 --- /dev/null +++ b/.licenseignore @@ -0,0 +1,10 @@ +**/*.mlmodel +**/*.pbxproj +**/*.png +**/*.xcworkspacedata +**/Package.swift +.dir-locals.el +.editorconfig +.swift-version +CODEOWNERS +Package.swift From f2a5c16f2d3414ec1ff07aaeaf194661ebad6686 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 17 Nov 2025 23:22:10 -0800 Subject: [PATCH 5/7] Disable License, Unacceptable Lang, API Breakage, Format, and Shell checks --- .github/workflows/pull_request.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fd35b216a13..b3edff773b8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -33,3 +33,8 @@ jobs: uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: license_header_check_project_name: "Swift" + license_header_check_enabled: false + unacceptable_language_check_enabled: false + api_breakage_check_enabled: false + format_check_enabled: false + shell_check_enabled: false From 34096c80b6f7b85bca571b6ce0d530babdc45808 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 17 Nov 2025 23:44:39 -0800 Subject: [PATCH 6/7] Fix the Android build --- Sources/Basics/Concurrency/AsyncProcess.swift | 8 +++-- .../PackageRegistryCommand+Auth.swift | 2 ++ .../Plugins/DefaultPluginScriptRunner.swift | 30 +++++++++++-------- .../BuildPrebuilts.swift | 4 +-- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Sources/Basics/Concurrency/AsyncProcess.swift b/Sources/Basics/Concurrency/AsyncProcess.swift index 86222f8fa67..17149e833bc 100644 --- a/Sources/Basics/Concurrency/AsyncProcess.swift +++ b/Sources/Basics/Concurrency/AsyncProcess.swift @@ -567,7 +567,9 @@ package final class AsyncProcess { return stdinPipe.fileHandleForWriting #elseif(!canImport(Darwin) || os(macOS)) // Initialize the spawn attributes. - #if canImport(Darwin) || os(Android) || os(OpenBSD) || os(FreeBSD) + #if os(Android) + var attributes: posix_spawnattr_t! = nil + #elseif canImport(Darwin) || os(OpenBSD) || os(FreeBSD) var attributes: posix_spawnattr_t? = nil #else var attributes = posix_spawnattr_t() @@ -612,7 +614,9 @@ package final class AsyncProcess { posix_spawnattr_setflags(&attributes, Int16(flags)) // Setup the file actions. - #if canImport(Darwin) || os(Android) || os(OpenBSD) || os(FreeBSD) + #if os(Android) + var fileActions: posix_spawn_file_actions_t! = nil + #elseif canImport(Darwin) || os(Android) || os(OpenBSD) || os(FreeBSD) var fileActions: posix_spawn_file_actions_t? = nil #else var fileActions = posix_spawn_file_actions_t() diff --git a/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift b/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift index a7a5cb35521..2c01cf1413d 100644 --- a/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift +++ b/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift @@ -82,6 +82,8 @@ private func readpassword(_ prompt: String) throws -> String { return String(cString: passwordPtr) } + #elseif canImport(Android) + throw StringError("unable to read input - not implemented on this platform") #else // GNU C implementation of getpass has no limit on the password length // (https://man7.org/linux/man-pages/man3/getpass.3.html) diff --git a/Sources/SPMBuildCore/Plugins/DefaultPluginScriptRunner.swift b/Sources/SPMBuildCore/Plugins/DefaultPluginScriptRunner.swift index c1f487c7bba..a5b450a6f5a 100644 --- a/Sources/SPMBuildCore/Plugins/DefaultPluginScriptRunner.swift +++ b/Sources/SPMBuildCore/Plugins/DefaultPluginScriptRunner.swift @@ -23,6 +23,10 @@ import class Basics.AsyncProcess import struct TSCUtility.SerializedDiagnostics +#if os(Android) +import Android +#endif + /// A plugin script runner that compiles the plugin source files as an executable binary for the host platform, and invokes it as a subprocess. public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { private let fileSystem: FileSystem @@ -51,7 +55,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { self.cancellator = Cancellator(observabilityScope: .none) self.verboseOutput = verboseOutput } - + /// Starts evaluating a plugin by compiling it and running it as a subprocess. The name is used as the basename for the executable and auxiliary files. The tools version controls the availability of APIs in PackagePlugin, and should be set to the tools version of the package that defines the plugin (not the package containing the target to which it is being applied). This function returns immediately and then repeated calls the output handler on the given callback queue as plain-text output is received from the plugin, and then eventually calls the completion handler on the given callback queue once the plugin is done. public func runPluginScript( sourceFiles: [Basics.AbsolutePath], @@ -109,7 +113,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { public var hostTriple: Triple { return self.toolchain.targetTriple } - + /// Starts compiling a plugin script asynchronously and when done, calls the completion handler on the callback queue with the results (including the path of the compiled plugin executable and with any emitted diagnostics, etc). Existing compilation results that are still valid are reused, if possible. This function itself returns immediately after starting the compile. Note that the completion handler only receives a `.failure` result if the compiler couldn't be invoked at all; a non-zero exit code from the compiler still returns `.success` with a full compilation result that notes the error in the diagnostics (in other words, a `.failure` result only means "failure to invoke the compiler"). public func compilePluginScript( sourceFiles: [Basics.AbsolutePath], @@ -136,7 +140,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { // We use the toolchain's Swift compiler for compiling the plugin. var commandLine = [self.toolchain.swiftCompilerPathForManifests.pathString] - + observabilityScope.emit(debug: "Using compiler \(self.toolchain.swiftCompilerPathForManifests.pathString)") // Get access to the path containing the PackagePlugin module and library. @@ -246,7 +250,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { completion(.failure(DefaultPluginScriptRunnerError.compilationPreparationFailed(error: error))) } } - + // Hash the compiler inputs to decide whether we really need to recompile. let compilerInputHash: String? do { @@ -267,7 +271,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { observabilityScope.emit(debug: "Couldn't compute hash of plugin compilation inputs", underlyingError: error) compilerInputHash = .none } - + /// Persisted information about the last time the compiler was invoked. struct PersistedCompilationState: Codable { var commandLine: [String] @@ -279,7 +283,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { case exit(code: Int32) case abnormal(exception: UInt32) case signal(number: Int32) - + init(_ processExitStatus: AsyncProcessResult.ExitStatus) { switch processExitStatus { case .terminated(let code): @@ -294,12 +298,12 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { } } } - + var succeeded: Bool { return result == .exit(code: 0) } } - + // Check if we already have a compiled executable and a persisted state (we only recompile if things have changed). let stateFilePath = self.cacheDir.appending(component: execName + "-state" + ".json") var compilationState: PersistedCompilationState? = .none @@ -310,7 +314,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { path: stateFilePath, fileSystem: fileSystem, as: PersistedCompilationState.self) - + // If it succeeded last time and the compiler inputs are the same, we don't need to recompile. if previousState.succeeded && previousState.inputHash == compilerInputHash { compilationState = previousState @@ -321,7 +325,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { observabilityScope.emit(debug: "Couldn't read previous compilation state", underlyingError: error) } } - + // If we still have a compilation state, it means the executable is still valid and we don't need to do anything. if let compilationState { // Just call the completion handler with the persisted results. @@ -350,7 +354,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { catch { observabilityScope.emit(debug: "Couldn't clean up before invoking compiler", underlyingError: error) } - + // Now invoke the compiler asynchronously. AsyncProcess.popen(arguments: commandLine, environment: environment, queue: callbackQueue) { // We are now on our caller's requested callback queue, so we just call the completion handler directly. @@ -388,7 +392,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { // Tell the delegate that we're done compiling the plugin, passing it the result. delegate.didCompilePlugin(result: result) - + // Also return the result to the caller. return result }) @@ -487,7 +491,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable { process.environment = .init(env) process.currentDirectoryURL = workingDirectory.asURL - + // Set up a pipe for sending structured messages to the plugin on its stdin. let stdinPipe = Pipe() let outputHandle = stdinPipe.fileHandleForWriting diff --git a/Sources/swift-build-prebuilts/BuildPrebuilts.swift b/Sources/swift-build-prebuilts/BuildPrebuilts.swift index 09e46bb518d..88bf4516cd3 100644 --- a/Sources/swift-build-prebuilts/BuildPrebuilts.swift +++ b/Sources/swift-build-prebuilts/BuildPrebuilts.swift @@ -251,7 +251,7 @@ struct BuildPrebuilts: AsyncParsableCommand { guard let swiftVersion = try computeSwiftVersion() else { print("Unable to determine swift compiler version") - _exit(1) + Foundation.exit(1) } let id = "swift-syntax" @@ -296,7 +296,7 @@ struct BuildPrebuilts: AsyncParsableCommand { let manifestURL = URL(string: prebuiltsUrl)?.appending(components: id, version, manifestFile) guard let manifestURL else { print("Invalid URL \(prebuiltsUrl)") - _exit(1) + Foundation.exit(1) } var headers = HTTPClientHeaders() From 00241315033bb2b6d0f7d644f1dca1fb03415504 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Tue, 18 Nov 2025 08:30:27 -0800 Subject: [PATCH 7/7] Only build to avoid timeout and remove Swift SDK for Android --- .github/workflows/pull_request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b3edff773b8..881f66b67b5 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -19,14 +19,14 @@ jobs: 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"]' windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1' - enable_android_sdk_build: true - android_sdk_build_command: "swift build --build-tests" - android_ndk_versions: '["r27d", "r29"]' + windows_build_command: 'Invoke-Program swift build' 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' soundness: name: Soundness