From f1b992bfbbb1ce52052ffea9c29d007519849099 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Mon, 1 Sep 2025 19:53:47 +0200 Subject: [PATCH 01/31] Support cross-PR testing for Swift packages (#52) This allows Swift Packages to be tested in combination with PRs updating their dependencies. To reference a linked PR, `Linked PR: ` needs to be added to the PR description, eg: ``` Linked PR: https://github.com/swiftlang/swift-syntax/pull/2859 ``` --- .github/workflows/pull_request.yml | 1 - .../workflows/scripts/cross-pr-checkout.swift | 247 ++++++++++++++++++ .github/workflows/swift_package_test.yml | 22 ++ .swift-format | 18 ++ README.md | 19 ++ 5 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/scripts/cross-pr-checkout.swift create mode 100644 .swift-format diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index aea1491d..1df9e89f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -83,4 +83,3 @@ jobs: with: api_breakage_check_enabled: false license_header_check_project_name: "Swift.org" - format_check_enabled: false diff --git a/.github/workflows/scripts/cross-pr-checkout.swift b/.github/workflows/scripts/cross-pr-checkout.swift new file mode 100644 index 00000000..7a4550ab --- /dev/null +++ b/.github/workflows/scripts/cross-pr-checkout.swift @@ -0,0 +1,247 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import Foundation + +#if canImport(FoundationNetworking) +// FoundationNetworking is a separate module in swift-foundation but not swift-corelibs-foundation. +import FoundationNetworking +#endif + +#if canImport(WinSDK) +import WinSDK +#endif + +struct GenericError: Error, CustomStringConvertible { + var description: String + + init(_ description: String) { + self.description = description + } +} + +/// Escape the given command to be printed for log output. +func escapeCommand(_ executable: URL, _ arguments: [String]) -> String { + return ([executable.path] + arguments).map { + if $0.contains(" ") { + return "'\($0)'" + } + return $0 + }.joined(separator: " ") +} + +/// Launch a subprocess with the given command and wait for it to finish +func run(_ executable: URL, _ arguments: String..., workingDirectory: URL? = nil) throws { + print("Running \(escapeCommand(executable, arguments)) (working directory: \(workingDirectory?.path ?? ""))") + let process = Process() + process.executableURL = executable + process.arguments = arguments + if let workingDirectory { + process.currentDirectoryURL = workingDirectory + } + + try process.run() + process.waitUntilExit() + guard process.terminationStatus == 0 else { + throw GenericError( + "\(escapeCommand(executable, arguments)) failed with non-zero exit code: \(process.terminationStatus)" + ) + } +} + +/// Find the executable with the given name in PATH. +public func lookup(executable: String) throws -> URL { + #if os(Windows) + let pathSeparator: Character = ";" + let executable = executable + ".exe" + #else + let pathSeparator: Character = ":" + #endif + for pathVariable in ["PATH", "Path"] { + guard let pathString = ProcessInfo.processInfo.environment[pathVariable] else { + continue + } + for searchPath in pathString.split(separator: pathSeparator) { + let candidateUrl = URL(fileURLWithPath: String(searchPath)).appendingPathComponent(executable) + if FileManager.default.isExecutableFile(atPath: candidateUrl.path) { + return candidateUrl + } + } + } + throw GenericError("Did not find \(executable)") +} + +func downloadData(from url: URL) async throws -> Data { + return try await withCheckedThrowingContinuation { continuation in + URLSession.shared.dataTask(with: url) { data, _, error in + if let error { + continuation.resume(throwing: error) + return + } + guard let data else { + continuation.resume(throwing: GenericError("Received no data for \(url)")) + return + } + continuation.resume(returning: data) + } + .resume() + } +} + +/// The JSON fields of the `https://api.github.com/repos//pulls/` endpoint that we care about. +struct PRInfo: Codable { + struct Base: Codable { + /// The name of the PR's base branch. + let ref: String + } + /// The base branch of the PR + let base: Base + + /// The PR's description. + let body: String? +} + +/// - Parameters: +/// - repository: The repository's name, eg. `swiftlang/swift-syntax` +func getPRInfo(repository: String, prNumber: String) async throws -> PRInfo { + guard let prInfoUrl = URL(string: "https://api.github.com/repos/\(repository)/pulls/\(prNumber)") else { + throw GenericError("Failed to form URL for GitHub API") + } + + do { + let data = try await downloadData(from: prInfoUrl) + return try JSONDecoder().decode(PRInfo.self, from: data) + } catch { + throw GenericError("Failed to load PR info from \(prInfoUrl): \(error)") + } +} + +/// Information about a PR that should be tested with this PR. +struct CrossRepoPR { + /// The owner of the repository, eg. `swiftlang` + let repositoryOwner: String + + /// The name of the repository, eg. `swift-syntax` + let repositoryName: String + + /// The PR number that's referenced. + let prNumber: String +} + +/// Retrieve all PRs that are referenced from PR `prNumber` in `repository`. +/// `repository` is the owner and repo name joined by `/`, eg. `swiftlang/swift-syntax`. +func getCrossRepoPrs(repository: String, prNumber: String) async throws -> [CrossRepoPR] { + var result: [CrossRepoPR] = [] + let prInfo = try await getPRInfo(repository: repository, prNumber: prNumber) + for line in prInfo.body?.split(separator: "\n") ?? [] { + guard line.lowercased().starts(with: "linked pr:") else { + continue + } + // We can't use Swift's Regex here because this script needs to run on Windows with Swift 5.9, which doesn't support + // Swift Regex. + var remainder = line[...] + guard let ownerRange = remainder.firstRange(of: "swiftlang/") ?? remainder.firstRange(of: "apple/") else { + continue + } + let repositoryOwner = remainder[ownerRange].dropLast() + remainder = remainder[ownerRange.upperBound...] + let repositoryName = remainder.prefix { $0.isLetter || $0.isNumber || $0 == "-" || $0 == "_" } + if repositoryName.isEmpty { + continue + } + remainder = remainder.dropFirst(repositoryName.count) + if remainder.starts(with: "/pull/") { + remainder = remainder.dropFirst(6) + } else if remainder.starts(with: "#") { + remainder = remainder.dropFirst() + } else { + continue + } + let pullRequestNum = remainder.prefix { $0.isNumber } + if pullRequestNum.isEmpty { + continue + } + result.append( + CrossRepoPR( + repositoryOwner: String(repositoryOwner), + repositoryName: String(repositoryName), + prNumber: String(pullRequestNum) + ) + ) + } + return result +} + +func main() async throws { + guard ProcessInfo.processInfo.arguments.count >= 3 else { + throw GenericError( + """ + Expected two arguments: + - Repository name, eg. `swiftlang/swift-syntax + - PR number + """ + ) + } + let repository = ProcessInfo.processInfo.arguments[1] + let prNumber = ProcessInfo.processInfo.arguments[2] + + let crossRepoPrs = try await getCrossRepoPrs(repository: repository, prNumber: prNumber) + if !crossRepoPrs.isEmpty { + print("Detected cross-repo PRs") + for crossRepoPr in crossRepoPrs { + print(" - \(crossRepoPr.repositoryOwner)/\(crossRepoPr.repositoryName)#\(crossRepoPr.prNumber)") + } + } + + for crossRepoPr in crossRepoPrs { + let git = try lookup(executable: "git") + let swift = try lookup(executable: "swift") + let baseBranch = try await getPRInfo( + repository: "\(crossRepoPr.repositoryOwner)/\(crossRepoPr.repositoryName)", + prNumber: crossRepoPr.prNumber + ).base.ref + + let workspaceDir = URL(fileURLWithPath: "..").resolvingSymlinksInPath() + let repoDir = workspaceDir.appendingPathComponent(crossRepoPr.repositoryName) + try run( + git, + "clone", + "https://github.com/\(crossRepoPr.repositoryOwner)/\(crossRepoPr.repositoryName).git", + "\(crossRepoPr.repositoryName)", + workingDirectory: workspaceDir + ) + try run(git, "fetch", "origin", "pull/\(crossRepoPr.prNumber)/merge:pr_merge", workingDirectory: repoDir) + try run(git, "checkout", baseBranch, workingDirectory: repoDir) + try run(git, "reset", "--hard", "pr_merge", workingDirectory: repoDir) + try run( + swift, + "package", + "config", + "set-mirror", + "--package-url", + "https://github.com/\(crossRepoPr.repositoryOwner)/\(crossRepoPr.repositoryName).git", + "--mirror-url", + repoDir.path + ) + } +} + +do { + try await main() +} catch { + print(error) + #if os(Windows) + _Exit(1) + #else + exit(1) + #endif +} diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index aaf06692..357943ef 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -144,6 +144,10 @@ on: type: boolean description: "Boolean to enable providing the GITHUB_TOKEN to downstream job." default: false + enable_cross_pr_testing: + type: boolean + description: "Whether PRs can be tested in combination with other PRs by mentioning them as `Linked PR: ` in the PR description" + default: false jobs: macos-build: @@ -208,6 +212,12 @@ jobs: if: ${{ inputs.needs_token }} run: | echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + - name: Check out related PRs + if: ${{ inputs.enable_cross_pr_testing && github.event_name == 'pull_request' }} + run: | + apt-get update && apt-get install -y curl + curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/cross-pr-checkout.swift > /tmp/cross-pr-checkout.swift + swift /tmp/cross-pr-checkout.swift "${{ github.repository }}" "${{ github.event.number }}" - name: Set environment variables if: ${{ inputs.linux_env_vars }} run: | @@ -449,6 +459,18 @@ jobs: Invoke-Program swift --version Invoke-Program swift test --version Invoke-Program cd $Source + '@ >> $env:TEMP\test-script\run.ps1 + + if ("${{ inputs.enable_cross_pr_testing && github.event_name == 'pull_request' }}" -eq "true") { + echo @' + Invoke-WebRequest https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/cross-pr-checkout.swift -OutFile $env:TEMP\cross-pr-checkout.swift + # Running in script mode fails on Windows (https://github.com/swiftlang/swift/issues/77263), compile and run the script. + Invoke-Program swiftc -sdk $env:SDKROOT $env:TEMP\cross-pr-checkout.swift -o $env:TEMP\cross-pr-checkout.exe + Invoke-Program $env:TEMP\cross-pr-checkout.exe "${{ github.repository }}" "${{ github.event.number }}" + '@ >> $env:TEMP\test-script\run.ps1 + } + + echo @' ${{ inputs.windows_pre_build_command }} ${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} '@ >> $env:TEMP\test-script\run.ps1 diff --git a/.swift-format b/.swift-format new file mode 100644 index 00000000..41a022f2 --- /dev/null +++ b/.swift-format @@ -0,0 +1,18 @@ +{ + "version": 1, + "lineLength": 120, + "indentation": { + "spaces": 2 + }, + "lineBreakBeforeEachArgument": true, + "indentConditionalCompilationBlocks": false, + "prioritizeKeepingFunctionOutputTogether": true, + "rules": { + "AlwaysUseLowerCamelCase": false, + "AmbiguousTrailingClosureOverload": false, + "NoBlockComments": false, + "OrderedImports": true, + "UseLetInEveryBoundCaseVariable": false, + "UseSynthesizedInitializer": false + } +} diff --git a/README.md b/README.md index bb394483..8006682a 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,25 @@ pre_build_command: "which example || (apt update -q && apt install -yq example" macOS platform support will be available soon. +#### Cross-PR testing + +To support testing of PRs together with PRs for one of the package’s dependencies, set add the following to your PR job. + +```yaml +with: + enable_cross_pr_testing: true +``` + +To reference a linked PR, add `Linked PR: ` to the PR description, eg. + +``` +Linked PR: https://github.com/swiftlang/swift-syntax/pull/2859 +// or alternatively +Linked PR: swiftlang/swift-syntax#2859 +``` + +Enabling cross-PR testing will add about 10s to PR testing time. + ## Running workflows locally You can run the Github Actions workflows locally using From 7c2d4798406693dd036af33415515448eacc97be Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Wed, 10 Sep 2025 00:47:36 -0700 Subject: [PATCH 02/31] Update the checks in the soundness.yml to use Swift 6.1 Docker images (#156) --- .github/workflows/soundness.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 6c7d187b..2de4edbe 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -18,7 +18,7 @@ on: api_breakage_check_container_image: type: string description: "Container image for the API breakage check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.0-noble" + default: "swift:6.1-noble" docs_check_enabled: type: boolean description: "Boolean to enable the docs check job. Defaults to true." @@ -26,7 +26,7 @@ on: docs_check_container_image: type: string description: "Container image for the docs check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.0-noble" + default: "swift:6.1-noble" docs_check_additional_arguments: type: string description: "Additional arguments that should be passed to docc" @@ -58,7 +58,7 @@ on: format_check_container_image: type: string description: "Container image for the format check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.0-noble" + default: "swift:6.1-noble" shell_check_enabled: type: boolean description: "Boolean to enable the shell check job. Defaults to true." @@ -66,7 +66,7 @@ on: shell_check_container_image: type: string description: "Container image for the shell check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.0-noble" + default: "swift:6.1-noble" yamllint_check_enabled: type: boolean description: "Boolean to enable the YAML lint check job. Defaults to true." From a28eb2c8a16ac77b823088e75e51b5cd30f0c1c3 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Wed, 10 Sep 2025 01:10:09 -0700 Subject: [PATCH 03/31] Add support for Xcode 26 beta 6 (#157) --- .github/workflows/swift_package_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 357943ef..d3ba7a4e 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -6,7 +6,7 @@ on: macos_xcode_versions: type: string description: "Xcode version list (JSON)" - default: "[\"16.2\", \"16.3\"]" + default: "[\"16.2\", \"16.3\", \"26.b6\"]" macos_exclude_xcode_versions: type: string description: "Exclude Xcode version list (JSON)" From 271c5b7138111ee59f8aa1c4ec4c5dbf2f17ca66 Mon Sep 17 00:00:00 2001 From: Stuart Montgomery Date: Thu, 11 Sep 2025 16:10:09 -0500 Subject: [PATCH 04/31] Support en dash character within copyright year range in license header checking script (#158) --- .github/workflows/scripts/check-license-header.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/check-license-header.sh b/.github/workflows/scripts/check-license-header.sh index 845eb254..f3e9ce89 100755 --- a/.github/workflows/scripts/check-license-header.sh +++ b/.github/workflows/scripts/check-license-header.sh @@ -116,7 +116,7 @@ while IFS= read -r file_path; do file_header=$(head -n "${expected_file_header_linecount}" "${file_path}") normalized_file_header=$( echo "${file_header}" \ - | sed -E -e 's/20[12][0123456789] ?- ?20[12][0123456789]/YEARS/' -e 's/20[12][0123456789]/YEARS/' \ + | sed -E -e 's/20[12][0123456789] ?[-–] ?20[12][0123456789]/YEARS/' -e 's/20[12][0123456789]/YEARS/' \ ) if ! diff -u \ From 46c9211125c6558a1b4424126c3c75674b8c1b35 Mon Sep 17 00:00:00 2001 From: award999 Date: Wed, 17 Sep 2025 09:09:33 -0400 Subject: [PATCH 05/31] Add 6.2 install script for windows (#160) This is for dockerless workflow --- .../scripts/windows/swift/install-swift-6.2.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/scripts/windows/swift/install-swift-6.2.ps1 diff --git a/.github/workflows/scripts/windows/swift/install-swift-6.2.ps1 b/.github/workflows/scripts/windows/swift/install-swift-6.2.ps1 new file mode 100644 index 00000000..392d0086 --- /dev/null +++ b/.github/workflows/scripts/windows/swift/install-swift-6.2.ps1 @@ -0,0 +1,17 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## +. $PSScriptRoot\install-swift.ps1 + +$SWIFT='https://download.swift.org/swift-6.2-release/windows10/swift-6.2-RELEASE/swift-6.2-RELEASE-windows10.exe' +$SWIFT_SHA256='80FBBC17D4F9EDEC74A83ABBEFEB9FF418FFC2158CD347111583C45E47F9789B' + +Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256 From c8cd040037597d34668ced270148f76840f957f5 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Wed, 17 Sep 2025 10:27:08 -0400 Subject: [PATCH 06/31] Add a call to `clang --version` in the PR worfklow. (#161) This change adds a call to `clang --version` after `swift --version` in the PR workflow YML file. The result of this command is useful for investigating issues stemming from out-of-date clang builds such as https://github.com/swiftlang/swift-testing/pull/1320. --- .github/workflows/swift_package_test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index d3ba7a4e..a4aaeeaa 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -180,6 +180,8 @@ jobs: run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV - name: Swift version run: xcrun swift --version + - name: Clang version + run: xcrun clang --version - name: Pre-build run: ${{ inputs.macos_pre_build_command }} - name: Build / Test @@ -202,6 +204,8 @@ jobs: steps: - name: Swift version run: swift --version + - name: Clang version + run: clang --version - name: Checkout repository uses: actions/checkout@v4 if: ${{ matrix.os_version != 'amazonlinux2' }} @@ -244,6 +248,8 @@ jobs: steps: - name: Swift version run: swift --version + - name: Clang version + run: clang --version - name: Checkout repository uses: actions/checkout@v4 if: ${{ matrix.os_version != 'amazonlinux2' }} @@ -299,6 +305,8 @@ jobs: steps: - name: Swift version run: swift --version + - name: Clang version + run: clang --version - name: Checkout repository uses: actions/checkout@v4 if: ${{ matrix.os_version != 'amazonlinux2' }} @@ -354,6 +362,8 @@ jobs: steps: - name: Swift version run: swift --version + - name: Clang version + run: clang --version - name: Checkout repository uses: actions/checkout@v4 - name: Provide token @@ -458,6 +468,7 @@ jobs: } Invoke-Program swift --version Invoke-Program swift test --version + Invoke-Program clang --version Invoke-Program cd $Source '@ >> $env:TEMP\test-script\run.ps1 From eb4096b4b7e9ddfd70562abb30f25819df7e23cd Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Wed, 17 Sep 2025 14:21:33 -0700 Subject: [PATCH 07/31] Add Swift 6.2 version to swift package testing (#159) --- .github/workflows/swift_package_test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index a4aaeeaa..4662d838 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -22,7 +22,7 @@ on: linux_swift_versions: type: string description: "Include Linux Swift version list (JSON)" - default: "[ \"5.9\", \"5.10\", \"6.0\", \"6.1\", \"nightly-main\", \"nightly-6.2\"]" + default: "[ \"5.9\", \"5.10\", \"6.0\", \"6.1\", \"6.2\", \"nightly-main\", \"nightly-6.2\"]" linux_exclude_swift_versions: type: string description: "Exclude Linux Swift version list (JSON)" @@ -34,11 +34,11 @@ on: linux_static_sdk_versions: type: string description: "Static Linux Swift SDK version list (JSON)" - default: "[\"nightly-6.2\"]" + default: "[\"nightly-6.2\", \"6.2\"]" wasm_sdk_versions: type: string description: "Wasm Swift SDK version list (JSON)" - default: "[\"nightly-main\", \"nightly-6.2\"]" + default: "[\"nightly-main\", \"nightly-6.2\", \"6.2\"]" wasm_exclude_swift_versions: type: string description: "Exclude Wasm Swift SDK version list (JSON)" @@ -47,7 +47,7 @@ on: type: string description: "Include Windows Swift version list (JSON)" # "5.10" is omitted for Windows because the container image is broken. - default: "[\"5.9\", \"6.0\", \"6.1\", \"nightly\", \"nightly-6.2\"]" + default: "[\"5.9\", \"6.0\", \"6.1\", \"6.2\", \"nightly\", \"nightly-6.2\"]" windows_exclude_swift_versions: type: string description: "Exclude Windows Swift version list (JSON)" From 88afc78d7edcb526f0ef216f52a356804b81a0be Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Thu, 18 Sep 2025 01:30:27 -0700 Subject: [PATCH 08/31] =?UTF-8?q?improve=20=E2=80=9Clinux=5Fstatic=5Fsdk?= =?UTF-8?q?=E2=80=9D=20workflow=20(#162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/swift_package_test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 4662d838..728a6d40 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -34,7 +34,11 @@ on: linux_static_sdk_versions: type: string description: "Static Linux Swift SDK version list (JSON)" - default: "[\"nightly-6.2\", \"6.2\"]" + default: "[\"nightly-main\", \"nightly-6.2\", \"6.2\"]" + linux_static_sdk_exclude_swift_versions: + type: string + description: "Exclude Static Linux Swift SDK version list (JSON)" + default: "[{\"swift_version\": \"\"}]" wasm_sdk_versions: type: string description: "Wasm Swift SDK version list (JSON)" @@ -243,6 +247,8 @@ jobs: matrix: swift_version: ${{ fromJson(inputs.linux_static_sdk_versions) }} os_version: ${{ fromJson(inputs.linux_os_versions) }} + exclude: + - ${{ fromJson(inputs.linux_static_sdk_exclude_swift_versions) }} container: image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }} steps: From a255edc5e427c9a5cd6ca08b3fafdf27f01efa74 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 19 Sep 2025 17:00:50 -0700 Subject: [PATCH 09/31] Drop Xcode 16.2 and 26.b6. Add Xcode 26.0 (#163) --- .github/workflows/swift_package_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 728a6d40..524d5ca2 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -6,7 +6,7 @@ on: macos_xcode_versions: type: string description: "Xcode version list (JSON)" - default: "[\"16.2\", \"16.3\", \"26.b6\"]" + default: "[\"16.3\", \"16.4\", \"26.0\"]" macos_exclude_xcode_versions: type: string description: "Exclude Xcode version list (JSON)" From 22efd847fb4f49bc4f67f1db7af7c45cb3e33138 Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Mon, 22 Sep 2025 18:26:13 +0200 Subject: [PATCH 10/31] Update container images for soundness to 6.2 (#164) --- .github/workflows/soundness.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 2de4edbe..2d67af48 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -18,7 +18,7 @@ on: api_breakage_check_container_image: type: string description: "Container image for the API breakage check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.1-noble" + default: "swift:6.2-noble" docs_check_enabled: type: boolean description: "Boolean to enable the docs check job. Defaults to true." @@ -26,7 +26,7 @@ on: docs_check_container_image: type: string description: "Container image for the docs check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.1-noble" + default: "swift:6.2-noble" docs_check_additional_arguments: type: string description: "Additional arguments that should be passed to docc" @@ -58,7 +58,7 @@ on: format_check_container_image: type: string description: "Container image for the format check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.1-noble" + default: "swift:6.2-noble" shell_check_enabled: type: boolean description: "Boolean to enable the shell check job. Defaults to true." @@ -66,7 +66,7 @@ on: shell_check_container_image: type: string description: "Container image for the shell check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.1-noble" + default: "swift:6.2-noble" yamllint_check_enabled: type: boolean description: "Boolean to enable the YAML lint check job. Defaults to true." From 1169be7eef94a42922812820d9cba3c6aa044c49 Mon Sep 17 00:00:00 2001 From: Melissa Kilby Date: Wed, 1 Oct 2025 01:57:48 -0700 Subject: [PATCH 11/31] set explicit permissions for GitHub workflows - soundness.yml (#168) Signed-off-by: Melissa Kilby --- .github/workflows/soundness.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 2d67af48..16803325 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -80,6 +80,9 @@ on: description: "Linux command to execute before building the Swift package" default: "" +permissions: + contents: read + ## We are cancelling previously triggered workflow runs concurrency: group: ${{ github.workflow }}-${{ github.ref }}-soundness From 20d5c09a6968e634d77e9e93e33d9aac753deae8 Mon Sep 17 00:00:00 2001 From: Melissa Kilby Date: Fri, 3 Oct 2025 20:07:46 -0700 Subject: [PATCH 12/31] set explicit permissions for GitHub workflows - all remaining workflows (#170) --- .github/workflows/create_automerge_pr.yml | 4 ++++ .github/workflows/performance_test.yml | 3 +++ .github/workflows/pull_request.yml | 3 +++ .github/workflows/swift_package_test.yml | 3 +++ 4 files changed, 13 insertions(+) diff --git a/.github/workflows/create_automerge_pr.yml b/.github/workflows/create_automerge_pr.yml index 0c5a39c9..ca2e0922 100644 --- a/.github/workflows/create_automerge_pr.yml +++ b/.github/workflows/create_automerge_pr.yml @@ -40,6 +40,10 @@ name: Create automerge PR # types: [..., ready_for_review] # ``` # Unfortunately this will also re-trigger testing evenon a normal user's PR (which may have already been tested), but skipping them causes the checks to reset so this is the best we can do for now. + +permissions: + contents: read + on: workflow_call: inputs: diff --git a/.github/workflows/performance_test.yml b/.github/workflows/performance_test.yml index 105e0049..dcec8325 100644 --- a/.github/workflows/performance_test.yml +++ b/.github/workflows/performance_test.yml @@ -1,5 +1,8 @@ name: Performance test +permissions: + contents: read + on: workflow_call: inputs: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1df9e89f..32b404ac 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,8 @@ name: Pull request +permissions: + contents: read + on: pull_request: types: [opened, reopened, synchronize] diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 524d5ca2..68125a4f 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -1,5 +1,8 @@ name: Swift Matrix +permissions: + contents: read + on: workflow_call: inputs: From 6e1073213a1192a3afbd63e0743cb8b5863ee44d Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Sat, 11 Oct 2025 17:26:13 +0200 Subject: [PATCH 13/31] Increase timeout of API breakage check (#171) --- .github/workflows/soundness.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 16803325..9fc7ab76 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -95,7 +95,7 @@ jobs: runs-on: ubuntu-latest container: image: ${{ inputs.api_breakage_check_container_image }} - timeout-minutes: 20 + timeout-minutes: 40 steps: - name: Checkout repository uses: actions/checkout@v4 From f1ef0dce4f543db24413fc3277d42e0690bc6b93 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Wed, 22 Oct 2025 11:54:47 -0400 Subject: [PATCH 14/31] Add workflow to build packages for iOS. (#169) * Add workflow to build packages for iOS. Add workflow to build packages for iOS on a macOS VM. Can't run tests at this time, but we can at least confirm source compiles. * Build script can just use pwd instead of a child directory maybe * Rename tests_ios --- .github/workflows/pull_request.yml | 12 +++++ .github/workflows/swift_package_test.yml | 67 ++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 32b404ac..6870f2af 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -80,6 +80,18 @@ jobs: xcrun swift package init --type library xcrun swift build + build_tests_ios: + name: Build iOS Tests + uses: ./.github/workflows/swift_package_test.yml + with: + enable_linux_checks: false + enable_windows_checks: false + # iOS + enable_ios_checks: true + ios_pre_build_command: | + pwd + xcrun swift package init --type library + soundness: name: Soundness uses: ./.github/workflows/soundness.yml diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 68125a4f..4e1925a0 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -22,6 +22,22 @@ on: type: string description: "macOS arch list (JSON)" default: "[\"ARM64\"]" + ios_host_xcode_versions: + type: string + description: "Xcode version list (JSON)" + default: null + ios_host_exclude_xcode_versions: + type: string + description: "Exclude Xcode version list (JSON)" + default: null + ios_host_versions: + type: string + description: "iOS host (macOS) version list (JSON)" + default: null + ios_host_archs: + type: string + description: "iOS host (macOS) arch list (JSON)" + default: null linux_swift_versions: type: string description: "Include Linux Swift version list (JSON)" @@ -87,6 +103,14 @@ on: type: string description: "macOS command to build and test the package" default: "xcrun swift test" + ios_pre_build_command: + type: string + description: "macOS command to execute before building the Swift package for iOS" + default: "" + ios_build_command: + type: string + description: "macOS command to build the package for iOS" + default: "xcrun swift build --build-tests --sdk \"$(xcrun --sdk iphoneos --show-sdk-path)\" --triple arm64-apple-ios" linux_build_command: type: string description: "Linux command to build and test the package" @@ -113,6 +137,9 @@ on: macos_env_vars: description: "Newline separated list of environment variables" type: string + ios_host_env_vars: + description: "Newline separated list of environment variables" + type: string linux_env_vars: description: "Newline separated list of environment variables" type: string @@ -139,6 +166,10 @@ on: type: boolean description: "Boolean to enable macOS testing. Defaults to false" default: false + enable_ios_checks: + type: boolean + description: "Boolean to enable iOS testing. Defaults to false" + default: false enable_windows_checks: type: boolean description: "Boolean to enable windows testing. Defaults to true" @@ -195,6 +226,42 @@ jobs: run: ${{ inputs.macos_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} timeout-minutes: 60 + ios-build: + name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) + if: ${{ inputs.enable_ios_checks }} + runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"] + strategy: + fail-fast: false + matrix: + xcode_version: ${{ fromJson(inputs.ios_host_xcode_versions || inputs.macos_xcode_versions) }} + os_version: ${{ fromJson(inputs.ios_host_versions || inputs.macos_versions) }} + arch: ${{ fromJson(inputs.ios_host_archs || inputs.macos_archs) }} + exclude: + - ${{ fromJson(inputs.ios_host_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Provide token + if: ${{ inputs.needs_token }} + run: | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + - name: Set environment variables + if: ${{ inputs.ios_host_env_vars }} + run: | + for i in "${{ inputs.ios_host_env_vars }}" + do + printf "%s\n" $i >> $GITHUB_ENV + done + - name: Select Xcode + run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV + - name: Swift version + run: xcrun swift --version + - name: Pre-build + run: ${{ inputs.ios_pre_build_command }} + - name: Build + run: ${{ inputs.ios_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} + timeout-minutes: 60 + linux-build: name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }}) if: ${{ inputs.enable_linux_checks }} From 1bc359192e63798baf1d39dafb1bc9dd7aa30b29 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Thu, 23 Oct 2025 12:14:07 -0400 Subject: [PATCH 15/31] Add Swift SDK for Android to swift_package_test workflow (#172) --- .github/workflows/pull_request.yml | 12 ++ .../scripts/install-and-build-with-sdk.sh | 187 ++++++++++++++++-- .github/workflows/swift_package_test.yml | 87 ++++++++ 3 files changed, 265 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6870f2af..7c06909f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -44,6 +44,12 @@ jobs: cd MyPackage swift package init --type library enable_wasm_sdk_build: true + # Android + android_sdk_pre_build_command: | + mkdir MyPackage + cd MyPackage + swift package init --type library + enable_android_sdk_build: true # Windows windows_build_command: | mkdir MyPackage @@ -58,6 +64,12 @@ jobs: with: # Skip Linux which doesn't currently support docker-less workflow enable_linux_checks: false + # Android + android_sdk_pre_build_command: | + mkdir MyPackage + cd MyPackage + swift package init --type library + enable_android_sdk_build: true # Windows windows_build_command: | mkdir MyPackage diff --git a/.github/workflows/scripts/install-and-build-with-sdk.sh b/.github/workflows/scripts/install-and-build-with-sdk.sh index 6111a631..986aa8ca 100644 --- a/.github/workflows/scripts/install-and-build-with-sdk.sh +++ b/.github/workflows/scripts/install-and-build-with-sdk.sh @@ -18,6 +18,7 @@ error() { printf -- "** ERROR: %s\n" "$*" >&2; } fatal() { error "$@"; exit 1; } # Parse command line options +INSTALL_ANDROID=false INSTALL_STATIC_LINUX=false INSTALL_WASM=false BUILD_EMBEDDED_WASM=false @@ -27,6 +28,18 @@ SWIFT_BUILD_COMMAND="swift build" while [[ $# -gt 0 ]]; do case $1 in + --android) + INSTALL_ANDROID=true + shift + ;; + --android-ndk-version=*) + ANDROID_NDK_VERSION="${1#*=}" + shift + ;; + --android-sdk-triple=*) + ANDROID_SDK_TRIPLE="${1#*=}" + shift + ;; --static) INSTALL_STATIC_LINUX=true shift @@ -64,32 +77,32 @@ done # Validate arguments if [[ -z "$SWIFT_VERSION_INPUT" ]]; then - fatal "Usage: $0 [--static] [--wasm] [--flags=\"\"] [--build-command=\"\"] " + fatal "Usage: $0 [--android] [--static] [--wasm] [--flags=\"\"] [--build-command=\"\"] " fi -if [[ "$INSTALL_STATIC_LINUX" == false && "$INSTALL_WASM" == false ]]; then - fatal "At least one of --static or --wasm must be specified" +if [[ "$INSTALL_ANDROID" == false && "$INSTALL_STATIC_LINUX" == false && "$INSTALL_WASM" == false ]]; then + fatal "At least one of --android or --static or --wasm must be specified" fi log "Requested Swift version: $SWIFT_VERSION_INPUT" +log "Install Android Swift SDK: $INSTALL_ANDROID" log "Install Static Linux Swift SDK: $INSTALL_STATIC_LINUX" log "Install Wasm Swift SDK: $INSTALL_WASM" if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then log "Additional build flags: $SWIFT_BUILD_FLAGS" fi -# Detect package manager -if command -v apt >/dev/null 2>&1; then - INSTALL_PACKAGE_COMMAND="apt update -q && apt install -yq" -elif command -v dnf >/dev/null 2>&1; then - INSTALL_PACKAGE_COMMAND="dnf install -y" -elif command -v yum >/dev/null 2>&1; then - INSTALL_PACKAGE_COMMAND="yum install -y" -else - fatal "No supported package manager found" -fi - install_package() { + # Detect package manager + if command -v apt >/dev/null 2>&1; then + INSTALL_PACKAGE_COMMAND="apt update -q && apt install -yq" + elif command -v dnf >/dev/null 2>&1; then + INSTALL_PACKAGE_COMMAND="dnf install -y" + elif command -v yum >/dev/null 2>&1; then + INSTALL_PACKAGE_COMMAND="yum install -y" + else + fatal "No supported package manager found" + fi eval "$INSTALL_PACKAGE_COMMAND $1" } @@ -103,7 +116,7 @@ SWIFT_API_INSTALL_ROOT="https://www.swift.org/api/v1/install" # and gets the checksum for the patch version's Static Linux and/or Wasm Swift SDK. # # $1 (string): A minor Swift version, e.g. "6.1" -# Output: A string of the form "|| +# Output: A string of the form "||| find_latest_swift_version() { local minor_version="$1" @@ -128,6 +141,23 @@ find_latest_swift_version() { log "Found latest patch version: $latest_version" + local android_sdk_checksum="" + if [[ "$INSTALL_ANDROID" == true ]]; then + android_sdk_checksum=$(echo "$releases_json" | jq -r --arg version "$latest_version" ' + .[] + | select(.name == $version) + | .platforms[] + | select(.platform == "android") + | .checksum + ') + + if [[ -z "$android_sdk_checksum" ]]; then + fatal "No Android Swift SDK checksum found for Swift $latest_version" + fi + + log "Found Android Swift SDK checksum: ${android_sdk_checksum:0:12}..." + fi + local static_linux_sdk_checksum="" if [[ "$INSTALL_STATIC_LINUX" == true ]]; then static_linux_sdk_checksum=$(echo "$releases_json" | jq -r --arg version "$latest_version" ' @@ -162,14 +192,15 @@ find_latest_swift_version() { log "Found Swift SDK for Wasm checksum: ${wasm_sdk_checksum:0:12}..." fi - echo "${latest_version}|${static_linux_sdk_checksum}|${wasm_sdk_checksum}" + echo "${latest_version}|${android_sdk_checksum}|${static_linux_sdk_checksum}|${wasm_sdk_checksum}" } -# Finds the latest Static Linux or Wasm Swift SDK development snapshot -# for the inputted Swift version and its checksum. +# Finds the latest Android or Static Linux or Wasm +# Swift SDK development snapshot for the inputted +# Swift version and its checksum. # # $1 (string): Nightly Swift version, e.g. "6.2" or "main" -# $2 (string): "static" or "wasm" +# $2 (string): "android" or "static" or "wasm" # Output: A string of the form "|", # e.g. "swift-6.2-DEVELOPMENT-SNAPSHOT-2025-07-29-a|" find_latest_sdk_snapshot() { @@ -206,6 +237,12 @@ find_latest_sdk_snapshot() { } SWIFT_VERSION_BRANCH="" +ANDROID_SDK_TAG="" +ANDROID_SDK_CHECKSUM="" +# TODO: we will be removing the "-0.1" suffix in a future nightly +ANDROID_SDK_PATH_SUFFIX="-0.1" +ANDROID_SDK_PATH_SEP="-" + STATIC_LINUX_SDK_TAG="" STATIC_LINUX_SDK_CHECKSUM="" WASM_SDK_TAG="" @@ -220,6 +257,13 @@ if [[ "$SWIFT_VERSION_INPUT" == nightly-* ]]; then SWIFT_VERSION_BRANCH="swift-${version}-branch" fi + if [[ "$INSTALL_ANDROID" == true ]]; then + android_sdk_info=$(find_latest_sdk_snapshot "$version" "android") + + ANDROID_SDK_TAG=$(echo "$android_sdk_info" | cut -d'|' -f1) + ANDROID_SDK_CHECKSUM=$(echo "$android_sdk_info" | cut -d'|' -f2) + fi + if [[ "$INSTALL_STATIC_LINUX" == true ]]; then static_linux_sdk_info=$(find_latest_sdk_snapshot "$version" "static") @@ -239,14 +283,21 @@ else latest_version=$(echo "$latest_version_info" | cut -d'|' -f1) SWIFT_VERSION_BRANCH="swift-${latest_version}-release" + ANDROID_SDK_TAG="swift-${latest_version}-RELEASE" + ANDROID_SDK_CHECKSUM=$(echo "$latest_version_info" | cut -d'|' -f2) + STATIC_LINUX_SDK_TAG="swift-${latest_version}-RELEASE" - STATIC_LINUX_SDK_CHECKSUM=$(echo "$latest_version_info" | cut -d'|' -f2) + STATIC_LINUX_SDK_CHECKSUM=$(echo "$latest_version_info" | cut -d'|' -f3) WASM_SDK_TAG="swift-${latest_version}-RELEASE" - WASM_SDK_CHECKSUM=$(echo "$latest_version_info" | cut -d'|' -f3) + WASM_SDK_CHECKSUM=$(echo "$latest_version_info" | cut -d'|' -f4) fi # Validate that required Swift SDK tags are set +if [[ "$INSTALL_ANDROID" == true && -z "$ANDROID_SDK_TAG" ]]; then + fatal "ANDROID_SDK_TAG is not set but Android Swift SDK installation was requested" +fi + if [[ "$INSTALL_STATIC_LINUX" == true && -z "$STATIC_LINUX_SDK_TAG" ]]; then fatal "STATIC_LINUX_SDK_TAG is not set but Static Linux Swift SDK installation was requested" fi @@ -439,9 +490,25 @@ download_and_extract_toolchain() { } INSTALLED_SWIFT_TAG=$(get_installed_swift_tag) +SWIFT_EXECUTABLE_FOR_ANDROID_SDK="" SWIFT_EXECUTABLE_FOR_STATIC_LINUX_SDK="" SWIFT_EXECUTABLE_FOR_WASM_SDK="" +if [[ "$INSTALL_ANDROID" == true ]]; then + if [[ "$INSTALLED_SWIFT_TAG" == "$ANDROID_SDK_TAG" ]]; then + log "Current toolchain matches Android Swift SDK snapshot: $ANDROID_SDK_TAG" + SWIFT_EXECUTABLE_FOR_ANDROID_SDK="swift" + else + log "Installing Swift toolchain to match Android Swift SDK snapshot: $ANDROID_SDK_TAG" + initialize_os_info + SWIFT_EXECUTABLE_FOR_ANDROID_SDK=$(download_and_extract_toolchain "$ANDROID_SDK_TAG") + if [[ $? -eq $EXIT_TOOLCHAIN_NOT_FOUND ]]; then + # Don't fail the workflow if we can't find the right toolchain + exit 0 + fi + fi +fi + if [[ "$INSTALL_STATIC_LINUX" == true ]]; then if [[ "$INSTALLED_SWIFT_TAG" == "$STATIC_LINUX_SDK_TAG" ]]; then log "Current toolchain matches Static Linux Swift SDK snapshot: $STATIC_LINUX_SDK_TAG" @@ -472,9 +539,57 @@ if [[ "$INSTALL_WASM" == true ]]; then fi fi +ANDROID_SDK_DOWNLOAD_ROOT="${SWIFT_DOWNLOAD_ROOT}/${SWIFT_VERSION_BRANCH}/android-sdk" STATIC_LINUX_SDK_DOWNLOAD_ROOT="${SWIFT_DOWNLOAD_ROOT}/${SWIFT_VERSION_BRANCH}/static-sdk" WASM_SDK_DOWNLOAD_ROOT="${SWIFT_DOWNLOAD_ROOT}/${SWIFT_VERSION_BRANCH}/wasm-sdk" +install_android_sdk() { + # Check if the Android Swift SDK is already installed + if "$SWIFT_EXECUTABLE_FOR_ANDROID_SDK" sdk list 2>/dev/null | grep -q "^${ANDROID_SDK_TAG}_android"; then + log "✅ Android Swift SDK ${ANDROID_SDK_TAG} is already installed, skipping installation" + return 0 + fi + + log "Installing Android Swift SDK: $ANDROID_SDK_TAG" + + local android_sdk_name="${ANDROID_SDK_TAG}_android${ANDROID_SDK_PATH_SUFFIX}" + local android_sdk_bundle_name="${android_sdk_name}.artifactbundle" + # TODO: remove once the next nightly changes the "-" to "_" in the name + local android_sdk_bundle_dir="${android_sdk_bundle_name//_android/${ANDROID_SDK_PATH_SEP}android}" + local android_sdk_filename="${android_sdk_bundle_name}.tar.gz" + local sdk_url="${ANDROID_SDK_DOWNLOAD_ROOT}/${ANDROID_SDK_TAG}/${android_sdk_filename}" + + log "Running: ${SWIFT_EXECUTABLE_FOR_ANDROID_SDK} sdk install ${sdk_url} --checksum ${ANDROID_SDK_CHECKSUM}" + + if "$SWIFT_EXECUTABLE_FOR_ANDROID_SDK" sdk install "$sdk_url" --checksum "$ANDROID_SDK_CHECKSUM"; then + log "✅ Android Swift SDK installed successfully" + else + fatal "Failed to install Android Swift SDK" + fi + + # now setup the link to the local ANDROID_NDK_HOME + swift sdk configure --show-configuration "$(swift sdk list | grep android | tail -n 1)" + + # guess some common places where the swift-sdks file lives + cd ~/Library/org.swift.swiftpm || cd ~/.config/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm || cd /root/.swiftpm + + # Download and install the Android NDK. + # Note that we could use the system package manager, but it is + # named different things for different distributions + # (e.g., "google-android-ndk-r26-installer" on Debian) + if [[ ! -d "${ANDROID_NDK_HOME:-}" ]]; then + # permit the "--android-ndk" flag to override the default + local android_ndk_version="${ANDROID_NDK_VERSION:-r27d}" + curl -fsSL -o ndk.zip --retry 3 https://dl.google.com/android/repository/android-ndk-"${android_ndk_version}"-"$(uname -s)".zip + unzip -q ndk.zip + rm ndk.zip + export ANDROID_NDK_HOME="${PWD}"/android-ndk-"${android_ndk_version}" + fi + + ./swift-sdks/"${android_sdk_bundle_dir}"/swift-android/scripts/setup-android-sdk.sh + cd - +} + install_static_linux_sdk() { # Check if the Static Linux Swift SDK is already installed if "$SWIFT_EXECUTABLE_FOR_STATIC_LINUX_SDK" sdk list 2>/dev/null | grep -q "^${STATIC_LINUX_SDK_TAG}_static-linux-0.0.1"; then @@ -518,6 +633,11 @@ install_wasm_sdk() { } install_sdks() { + if [[ "$INSTALL_ANDROID" == true ]]; then + log "Starting install of Swift ${SWIFT_VERSION_INPUT} Android Swift SDK" + install_android_sdk + fi + if [[ "$INSTALL_STATIC_LINUX" == true ]]; then log "Starting install of Swift ${SWIFT_VERSION_INPUT} Static Linux Swift SDK" install_static_linux_sdk @@ -533,6 +653,31 @@ build() { # Enable alias expansion to use a 'swift' alias for the executable path shopt -s expand_aliases + if [[ "$INSTALL_ANDROID" == true ]]; then + log "Running Swift build with Android Swift SDK" + + local sdk_name="${ANDROID_SDK_TAG}${ANDROID_SDK_PATH_SEP}android${ANDROID_SDK_PATH_SUFFIX}" + + alias swift='$SWIFT_EXECUTABLE_FOR_ANDROID_SDK' + local build_command="$SWIFT_BUILD_COMMAND --swift-sdk ${ANDROID_SDK_TRIPLE:-$sdk_name}" + if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then + build_command="$build_command $SWIFT_BUILD_FLAGS" + fi + + log "Running: $build_command" + + # clear the ANDROID_NDK_ROOT environment variable if it is set + # due to https://github.com/swiftlang/swift-driver/pull/1879 + # otherwise build error: missing required module 'SwiftAndroid' + export ANDROID_NDK_ROOT="" + + if eval "$build_command"; then + log "✅ Swift build with Android Swift SDK completed successfully" + else + fatal "Swift build with Android Swift SDK failed" + fi + fi + if [[ "$INSTALL_STATIC_LINUX" == true ]]; then log "Running Swift build with Static Linux Swift SDK" diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 4e1925a0..b80f1502 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -66,6 +66,14 @@ on: type: string description: "Exclude Wasm Swift SDK version list (JSON)" default: "[{\"swift_version\": \"\"}]" + android_sdk_versions: + type: string + description: "Android Swift SDK version list (JSON)" + default: "[\"nightly-main\"]" + android_exclude_swift_versions: + type: string + description: "Exclude Android Swift SDK version list (JSON)" + default: "[{\"swift_version\": \"\"}]" windows_swift_versions: type: string description: "Include Windows Swift version list (JSON)" @@ -95,6 +103,10 @@ on: type: string description: "Linux command to execute before building the Swift package with the Embedded Swift SDK for Wasm" default: "" + android_sdk_pre_build_command: + type: string + description: "Linux command to execute before building the Swift package with the Embedded Swift SDK for Android" + default: "" macos_pre_build_command: type: string description: "macOS command to execute before building the Swift package" @@ -123,6 +135,18 @@ on: type: string description: "Command to use when building the package with the Swift SDK for Wasm" default: "swift build" + android_sdk_build_command: + type: string + description: "Command to use when building the package with the Swift SDK for Android" + default: "swift build" + android_sdk_triple: + type: string + description: "The triple to use when building with the Swift SDK for Android" + default: "[\"x86_64-unknown-linux-android28\"]" + android_ndk_version: + type: string + description: "The NDK version to use when building with the Swift SDK for Android" + default: "[\"r27d\"]" windows_pre_build_command: type: string description: "Windows Command Prompt command to execute before building the Swift package" @@ -162,6 +186,10 @@ on: type: boolean description: "Boolean to enable building with the Embedded Swift SDK for Wasm. Defaults to false" default: false + enable_android_sdk_build: + type: boolean + description: "Boolean to enable building with the Swift SDK for Android. Defaults to false" + default: false enable_macos_checks: type: boolean description: "Boolean to enable macOS testing. Defaults to false" @@ -475,6 +503,65 @@ jobs: curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ bash -s -- --embedded-wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }} + android-sdk-build: + name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) + if: ${{ inputs.enable_android_sdk_build }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + swift_version: ${{ fromJson(inputs.android_sdk_versions) }} + sdk_triple: ${{ fromJson(inputs.android_sdk_triple) }} + ndk_version: ${{ fromJson(inputs.android_ndk_version) }} + os_version: ${{ fromJson(inputs.linux_os_versions) }} + exclude: + - ${{ fromJson(inputs.android_exclude_swift_versions) }} + container: + image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }} + steps: + - name: Swift version + run: swift --version + - name: Clang version + run: clang --version + - name: Checkout repository + uses: actions/checkout@v4 + if: ${{ matrix.os_version != 'amazonlinux2' }} + - name: Checkout repository + uses: actions/checkout@v1 + if: ${{ matrix.os_version == 'amazonlinux2' }} + - name: Provide token + if: ${{ inputs.needs_token }} + run: | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + - name: Set environment variables + if: ${{ inputs.linux_env_vars }} + run: | + for i in "${{ inputs.linux_env_vars }}" + do + printf "%s\n" $i >> $GITHUB_ENV + done + - name: Pre-build + run: ${{ inputs.linux_pre_build_command }} + - name: Install Swift SDK for Android and build + env: + BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} + run: | + ${{ inputs.android_sdk_pre_build_command }} + if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal + apt-get -q update && apt-get -yq install curl + elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 + dnf -y update + dnf -y install curl-minimal + elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 + yum -y update + yum -y install curl + else + echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 + exit 1 + fi + curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple="${{ inputs.sdk_triple }}" --android-ndk-version="${{ inputs.ndk_version }}" ${{ matrix.swift_version }} + windows-build: name: Windows (${{ matrix.swift_version }} - windows-2022) if: ${{ inputs.enable_windows_checks }} From 2fe9a61880307905778b1718c95c28f92a90ad7e Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 24 Oct 2025 00:21:14 -0700 Subject: [PATCH 16/31] Android SDK build: install unzip package (#174) On some distributions (like Debian Bookworm), unzip is not installed in containers by default. Ensure we install it when needed. --- .github/workflows/scripts/install-and-build-with-sdk.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/scripts/install-and-build-with-sdk.sh b/.github/workflows/scripts/install-and-build-with-sdk.sh index 986aa8ca..e942ecff 100644 --- a/.github/workflows/scripts/install-and-build-with-sdk.sh +++ b/.github/workflows/scripts/install-and-build-with-sdk.sh @@ -581,6 +581,7 @@ install_android_sdk() { # permit the "--android-ndk" flag to override the default local android_ndk_version="${ANDROID_NDK_VERSION:-r27d}" curl -fsSL -o ndk.zip --retry 3 https://dl.google.com/android/repository/android-ndk-"${android_ndk_version}"-"$(uname -s)".zip + command -v unzip >/dev/null || install_package unzip unzip -q ndk.zip rm ndk.zip export ANDROID_NDK_HOME="${PWD}"/android-ndk-"${android_ndk_version}" From b2b2b25a585f3b1821c2cc5d71b9bb0d7f5d1662 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 28 Oct 2025 09:46:46 -0700 Subject: [PATCH 17/31] Update Android SDK build name to include NDK version (#175) * Update Android SDK build name to include NDK version This allows differentiating them when multiple NDKs are used. As far as multiple triples, I think those should be handled within the workflow, rather than splitting off into new matrix entries (especially as we already have some multi-triple build capabilities in swiftpm for macOS now and could conceivably extend that to Android), but that's for another PR. * Fix variable reference in Android build script --- .github/workflows/swift_package_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index b80f1502..4b915fee 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -504,7 +504,7 @@ jobs: bash -s -- --embedded-wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }} android-sdk-build: - name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) + name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }} - NDK ${{ matrix.ndk_version }}) if: ${{ inputs.enable_android_sdk_build }} runs-on: ubuntu-latest strategy: @@ -560,7 +560,7 @@ jobs: exit 1 fi curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple="${{ inputs.sdk_triple }}" --android-ndk-version="${{ inputs.ndk_version }}" ${{ matrix.swift_version }} + bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple="${{ matrix.sdk_triple }}" --android-ndk-version="${{ matrix.ndk_version }}" ${{ matrix.swift_version }} windows-build: name: Windows (${{ matrix.swift_version }} - windows-2022) From 457d77cd6608ae11ed850f96921782a8db89e4aa Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 4 Nov 2025 11:16:35 -0500 Subject: [PATCH 18/31] Support .psm1 files in check-licence-header.sh (#178) --- .github/workflows/scripts/check-license-header.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/scripts/check-license-header.sh b/.github/workflows/scripts/check-license-header.sh index f3e9ce89..fa512e24 100755 --- a/.github/workflows/scripts/check-license-header.sh +++ b/.github/workflows/scripts/check-license-header.sh @@ -91,6 +91,7 @@ while IFS= read -r file_path; do plist) continue ;; # Plists don't support line comments proto) comment_marker='//' ;; ps1) comment_marker='##' ;; + psm1) comment_marker='##' ;; py) comment_marker='##'; header_prefix=$'#!/usr/bin/env python3\n' ;; rb) comment_marker='##'; header_prefix=$'#!/usr/bin/env ruby\n' ;; sh) comment_marker='##'; header_prefix=$'#!/bin/bash\n' ;; From 00b19f5dad686d4565cee1580ae75b744dc19b79 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 6 Nov 2025 07:56:00 -0800 Subject: [PATCH 19/31] De-matrix Android triples (#176) * De-matrix Android triples Building for multiple ABIs at once is something the swift-build frontend does for macOS and should eventually do for other platforms. Don't "lift" the triple into a new matrix axis. This also renames the android_sdk_triple and android_ndk_version properties to plurals, since they support multiple versions. This is breaking, but the Android workflow is only a couple of days old, so this should be fine. * Always use the current version of the Android script --- .../scripts/install-and-build-with-sdk.sh | 35 ++++++++++-------- .github/workflows/swift_package_test.yml | 37 ++++++++++++++----- 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/.github/workflows/scripts/install-and-build-with-sdk.sh b/.github/workflows/scripts/install-and-build-with-sdk.sh index e942ecff..c3347445 100644 --- a/.github/workflows/scripts/install-and-build-with-sdk.sh +++ b/.github/workflows/scripts/install-and-build-with-sdk.sh @@ -25,6 +25,7 @@ BUILD_EMBEDDED_WASM=false SWIFT_VERSION_INPUT="" SWIFT_BUILD_FLAGS="" SWIFT_BUILD_COMMAND="swift build" +ANDROID_SDK_TRIPLES=() while [[ $# -gt 0 ]]; do case $1 in @@ -37,7 +38,7 @@ while [[ $# -gt 0 ]]; do shift ;; --android-sdk-triple=*) - ANDROID_SDK_TRIPLE="${1#*=}" + ANDROID_SDK_TRIPLES+=("${1#*=}") shift ;; --static) @@ -660,23 +661,27 @@ build() { local sdk_name="${ANDROID_SDK_TAG}${ANDROID_SDK_PATH_SEP}android${ANDROID_SDK_PATH_SUFFIX}" alias swift='$SWIFT_EXECUTABLE_FOR_ANDROID_SDK' - local build_command="$SWIFT_BUILD_COMMAND --swift-sdk ${ANDROID_SDK_TRIPLE:-$sdk_name}" - if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then - build_command="$build_command $SWIFT_BUILD_FLAGS" - fi - log "Running: $build_command" + # This can become a single invocation in the future when `swift build` supports multiple Android triples at once + for android_sdk_triple in "${ANDROID_SDK_TRIPLES[@]}" ; do + local build_command="$SWIFT_BUILD_COMMAND --swift-sdk ${android_sdk_triple}" + if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then + build_command="$build_command $SWIFT_BUILD_FLAGS" + fi - # clear the ANDROID_NDK_ROOT environment variable if it is set - # due to https://github.com/swiftlang/swift-driver/pull/1879 - # otherwise build error: missing required module 'SwiftAndroid' - export ANDROID_NDK_ROOT="" + log "Running: $build_command" - if eval "$build_command"; then - log "✅ Swift build with Android Swift SDK completed successfully" - else - fatal "Swift build with Android Swift SDK failed" - fi + # clear the ANDROID_NDK_ROOT environment variable if it is set + # due to https://github.com/swiftlang/swift-driver/pull/1879 + # otherwise build error: missing required module 'SwiftAndroid' + export ANDROID_NDK_ROOT="" + + if eval "$build_command"; then + log "✅ Swift build with Android Swift SDK completed successfully" + else + fatal "Swift build with Android Swift SDK failed" + fi + done fi if [[ "$INSTALL_STATIC_LINUX" == true ]]; then diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 4b915fee..c86c42d7 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -139,13 +139,13 @@ on: type: string description: "Command to use when building the package with the Swift SDK for Android" default: "swift build" - android_sdk_triple: + android_sdk_triples: type: string - description: "The triple to use when building with the Swift SDK for Android" - default: "[\"x86_64-unknown-linux-android28\"]" - android_ndk_version: + description: "The triples to use when building with the Swift SDK for Android" + default: "[\"aarch64-unknown-linux-android28\", \"x86_64-unknown-linux-android28\"]" + android_ndk_versions: type: string - description: "The NDK version to use when building with the Swift SDK for Android" + description: "The NDK versions to use when building with the Swift SDK for Android" default: "[\"r27d\"]" windows_pre_build_command: type: string @@ -511,8 +511,7 @@ jobs: fail-fast: false matrix: swift_version: ${{ fromJson(inputs.android_sdk_versions) }} - sdk_triple: ${{ fromJson(inputs.android_sdk_triple) }} - ndk_version: ${{ fromJson(inputs.android_ndk_version) }} + ndk_version: ${{ fromJson(inputs.android_ndk_versions) }} os_version: ${{ fromJson(inputs.linux_os_versions) }} exclude: - ${{ fromJson(inputs.android_exclude_swift_versions) }} @@ -529,6 +528,26 @@ jobs: - name: Checkout repository uses: actions/checkout@v1 if: ${{ matrix.os_version == 'amazonlinux2' }} + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version != 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version == 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v1 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -559,8 +578,8 @@ jobs: echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 exit 1 fi - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple="${{ matrix.sdk_triple }}" --android-ndk-version="${{ matrix.ndk_version }}" ${{ matrix.swift_version }} + cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple=${{ join(fromJson(inputs.android_sdk_triples), ' --android-sdk-triple=') }} --android-ndk-version="${{ matrix.ndk_version }}" ${{ matrix.swift_version }} windows-build: name: Windows (${{ matrix.swift_version }} - windows-2022) From 3c07ac0f01f9bd3a652832cceaf44eff204057e5 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 6 Nov 2025 15:04:41 -0800 Subject: [PATCH 20/31] Always use the current version of the scripts (Linux + Wasm) (#182) * Always use the current version of the scripts (Linux + Wasm) This applies the changes previously made for Android to: - Linux - Linux Static SDK - Wasm SDK - Embedded Wasm SDK * Apply checkout fix for Amazon Linux 2 to the embedded wasm SDK build This was missed earlier. --- .github/workflows/swift_package_test.yml | 97 +++++++++++++++++++++++- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index c86c42d7..df1acc78 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -314,6 +314,27 @@ jobs: - name: Checkout repository uses: actions/checkout@v1 if: ${{ matrix.os_version == 'amazonlinux2' }} + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version != 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version == 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v1 + with: + repository: swiftlang/github-workflows + path: github-workflows + ref: main + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -322,7 +343,7 @@ jobs: if: ${{ inputs.enable_cross_pr_testing && github.event_name == 'pull_request' }} run: | apt-get update && apt-get install -y curl - curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/cross-pr-checkout.swift > /tmp/cross-pr-checkout.swift + cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/cross-pr-checkout.swift > /tmp/cross-pr-checkout.swift swift /tmp/cross-pr-checkout.swift "${{ github.repository }}" "${{ github.event.number }}" - name: Set environment variables if: ${{ inputs.linux_env_vars }} @@ -360,6 +381,27 @@ jobs: - name: Checkout repository uses: actions/checkout@v1 if: ${{ matrix.os_version == 'amazonlinux2' }} + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version != 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version == 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v1 + with: + repository: swiftlang/github-workflows + path: github-workflows + ref: main + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -390,7 +432,7 @@ jobs: echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 exit 1 fi - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ bash -s -- --static --flags="$BUILD_FLAGS" --build-command="${{ inputs.linux_static_sdk_build_command }}" ${{ matrix.swift_version }} wasm-sdk-build: @@ -417,6 +459,27 @@ jobs: - name: Checkout repository uses: actions/checkout@v1 if: ${{ matrix.os_version == 'amazonlinux2' }} + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version != 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version == 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v1 + with: + repository: swiftlang/github-workflows + path: github-workflows + ref: main + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -447,7 +510,7 @@ jobs: echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 exit 1 fi - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ bash -s -- --wasm --flags="$BUILD_FLAGS" --build-command="${{ inputs.wasm_sdk_build_command }}" ${{ matrix.swift_version }} embedded-wasm-sdk-build: @@ -470,6 +533,31 @@ jobs: run: clang --version - name: Checkout repository uses: actions/checkout@v4 + if: ${{ matrix.os_version != 'amazonlinux2' }} + - name: Checkout repository + uses: actions/checkout@v1 + if: ${{ matrix.os_version == 'amazonlinux2' }} + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version != 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Checkout swiftlang/github-workflows repository + if: ${{ matrix.os_version == 'amazonlinux2' && github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v1 + with: + repository: swiftlang/github-workflows + path: github-workflows + ref: main + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -500,7 +588,7 @@ jobs: echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 exit 1 fi - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ bash -s -- --embedded-wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }} android-sdk-build: @@ -540,6 +628,7 @@ jobs: with: repository: swiftlang/github-workflows path: github-workflows + ref: main - name: Determine script-root path id: script_path run: | From ecac3e3e4523f1cb3d3b9695a741e3c7f4bf5740 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 6 Nov 2025 16:12:27 -0800 Subject: [PATCH 21/31] Always use the current version of the scripts (Windows) (#181) This applies the changes previously made for Android to Windows --- .github/workflows/swift_package_test.yml | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index df1acc78..288e198a 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -683,6 +683,20 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if ("${{ github.repository }}" -eq "swiftlang/github-workflows") { + echo "root=$env:GITHUB_WORKSPACE" >> $env:GITHUB_OUTPUT + } else { + echo "root=$env:GITHUB_WORKSPACE/github-workflows" >> $env:GITHUB_OUTPUT + } - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -707,17 +721,10 @@ jobs: echo "image=$Image" >> "$env:GITHUB_OUTPUT" - name: Install Visual Studio Build Tools if: ${{ !inputs.enable_windows_docker }} - run: | - Invoke-WebRequest -Uri https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/windows/install-vsb.ps1 -OutFile $env:TEMP\install-vsb.ps1 - . $env:TEMP\install-vsb.ps1 - del $env:TEMP\install-vsb.ps1 + run: . ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/windows/install-vsb.ps1 - name: Install Swift if: ${{ !inputs.enable_windows_docker }} - run: | - Invoke-WebRequest -Uri https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/windows/swift/install-swift.ps1 -OutFile $env:TEMP\install-swift.ps1 - Invoke-WebRequest -Uri https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/windows/swift/install-swift-${{ matrix.swift_version }}.ps1 -OutFile $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1 - . $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1 - del $env:TEMP\install-swift*.ps1 + run: . ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/windows/swift/install-swift-${{ matrix.swift_version }}.ps1 - name: Create test script run: | mkdir $env:TEMP\test-script @@ -745,9 +752,8 @@ jobs: if ("${{ inputs.enable_cross_pr_testing && github.event_name == 'pull_request' }}" -eq "true") { echo @' - Invoke-WebRequest https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/cross-pr-checkout.swift -OutFile $env:TEMP\cross-pr-checkout.swift # Running in script mode fails on Windows (https://github.com/swiftlang/swift/issues/77263), compile and run the script. - Invoke-Program swiftc -sdk $env:SDKROOT $env:TEMP\cross-pr-checkout.swift -o $env:TEMP\cross-pr-checkout.exe + Invoke-Program swiftc -sdk $env:SDKROOT ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/cross-pr-checkout.swift -o $env:TEMP\cross-pr-checkout.exe Invoke-Program $env:TEMP\cross-pr-checkout.exe "${{ github.repository }}" "${{ github.event.number }}" '@ >> $env:TEMP\test-script\run.ps1 } From dfa66dab3d52571db0c5db40285480fd23d16a80 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 6 Nov 2025 16:12:41 -0800 Subject: [PATCH 22/31] Always use the current version of the scripts (soundness checks) (#180) This applies the changes previously made swift_package_test to the soundness checks. --- .github/workflows/soundness.yml | 112 ++++++++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 7 deletions(-) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 9fc7ab76..6c8aad28 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -142,6 +142,20 @@ jobs: with: persist-credentials: false submodules: true + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Pre-build if: ${{ inputs.linux_pre_build_command }} run: ${{ inputs.linux_pre_build_command }} @@ -150,7 +164,7 @@ jobs: ADDITIONAL_DOCC_ARGUMENTS: ${{ inputs.docs_check_additional_arguments }} run: | which curl yq || (apt -q update && apt -yq install curl yq) - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-docs.sh | bash + cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-docs.sh | bash unacceptable-language-check: name: Unacceptable language check @@ -163,10 +177,24 @@ jobs: with: persist-credentials: false submodules: true + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Run unacceptable language check env: UNACCEPTABLE_WORD_LIST: ${{ inputs.unacceptable_language_check_word_list}} - run: curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-unacceptable-language.sh | bash + run: cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-unacceptable-language.sh | bash license-header-check: name: License headers check @@ -179,10 +207,24 @@ jobs: with: persist-credentials: false submodules: true + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Run license header check env: PROJECT_NAME: ${{ inputs.license_header_check_project_name }} - run: curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-license-header.sh | bash + run: cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-license-header.sh | bash broken-symlink-check: name: Broken symlinks check @@ -195,8 +237,22 @@ jobs: with: persist-credentials: false submodules: true + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Run broken symlinks check - run: curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-broken-symlinks.sh | bash + run: cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-broken-symlinks.sh | bash format-check: name: Format check @@ -211,13 +267,27 @@ jobs: with: persist-credentials: false submodules: true + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Mark the workspace as safe # https://github.com/actions/checkout/issues/766 run: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Run format check run: | which curl || (apt -q update && apt -yq install curl) - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-swift-format.sh | bash + cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-swift-format.sh | bash shell-check: name: Shell check @@ -251,13 +321,27 @@ jobs: with: persist-credentials: false submodules: true + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Run yamllint run: | which yamllint || (apt -q update && apt install -yq yamllint) cd ${GITHUB_WORKSPACE} if [ ! -f ".yamllint.yml" ]; then echo "Downloading default yamllint config file" - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/configs/yamllint.yml > .yamllint.yml + cat ${{ steps.script_path.outputs.root }}/.github/workflows/configs/yamllint.yml > .yamllint.yml fi yamllint --strict --config-file .yamllint.yml . @@ -272,12 +356,26 @@ jobs: with: persist-credentials: false submodules: true + - name: Checkout swiftlang/github-workflows repository + if: ${{ github.repository != 'swiftlang/github-workflows' }} + uses: actions/checkout@v4 + with: + repository: swiftlang/github-workflows + path: github-workflows + - name: Determine script-root path + id: script_path + run: | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then + echo "root=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + else + echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT + fi - name: Run flake8 run: | pip3 install flake8 flake8-import-order cd ${GITHUB_WORKSPACE} if [ ! -f ".flake8" ]; then echo "Downloading default flake8 config file" - curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/configs/.flake8 > .flake8 + cat ${{ steps.script_path.outputs.root }}/.github/workflows/configs/.flake8 > .flake8 fi flake8 From dcbe5142ca805d817d1dac2d37e29520c73ece1c Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 10 Nov 2025 14:42:58 -0800 Subject: [PATCH 23/31] Skip matrix jobs more cleanly (#183) Now disabled jobs will just disappear entirely, rather than appear with confusing unexpanded placeholders. --- .github/workflows/swift_package_test.yml | 44 ++++++++++-------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 288e198a..feed3e8e 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -218,14 +218,13 @@ on: jobs: macos-build: name: macOS (Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) - if: ${{ inputs.enable_macos_checks }} runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"] strategy: fail-fast: false matrix: - xcode_version: ${{ fromJson(inputs.macos_xcode_versions) }} - os_version: ${{ fromJson(inputs.macos_versions) }} - arch: ${{ fromJson(inputs.macos_archs) }} + xcode_version: ${{ fromJson((inputs.enable_macos_checks && inputs.macos_xcode_versions) || '[]') }} + os_version: ${{ fromJson((inputs.enable_macos_checks && inputs.macos_versions) || '[]') }} + arch: ${{ fromJson((inputs.enable_macos_checks && inputs.macos_archs) || '[]') }} exclude: - ${{ fromJson(inputs.macos_exclude_xcode_versions) }} steps: @@ -256,14 +255,13 @@ jobs: ios-build: name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) - if: ${{ inputs.enable_ios_checks }} runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"] strategy: fail-fast: false matrix: - xcode_version: ${{ fromJson(inputs.ios_host_xcode_versions || inputs.macos_xcode_versions) }} - os_version: ${{ fromJson(inputs.ios_host_versions || inputs.macos_versions) }} - arch: ${{ fromJson(inputs.ios_host_archs || inputs.macos_archs) }} + xcode_version: ${{ fromJson((inputs.enable_ios_checks && (inputs.ios_host_xcode_versions || inputs.macos_xcode_versions)) || '[]') }} + os_version: ${{ fromJson((inputs.enable_ios_checks && (inputs.ios_host_versions || inputs.macos_versions)) || '[]') }} + arch: ${{ fromJson((inputs.enable_ios_checks && (inputs.ios_host_archs || inputs.macos_archs)) || '[]') }} exclude: - ${{ fromJson(inputs.ios_host_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }} steps: @@ -292,13 +290,12 @@ jobs: linux-build: name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }}) - if: ${{ inputs.enable_linux_checks }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson(inputs.linux_swift_versions) }} - os_version: ${{ fromJson(inputs.linux_os_versions) }} + swift_version: ${{ fromJson((inputs.enable_linux_checks && inputs.linux_swift_versions) || '[]') }} + os_version: ${{ fromJson((inputs.enable_linux_checks && inputs.linux_os_versions) || '[]') }} exclude: - ${{ fromJson(inputs.linux_exclude_swift_versions) }} container: @@ -359,13 +356,12 @@ jobs: linux-static-sdk-build: name: Static Linux Swift SDK Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) - if: ${{ inputs.enable_linux_static_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson(inputs.linux_static_sdk_versions) }} - os_version: ${{ fromJson(inputs.linux_os_versions) }} + swift_version: ${{ fromJson((inputs.enable_linux_static_sdk_build && inputs.linux_static_sdk_versions) || '[]') }} + os_version: ${{ fromJson((inputs.enable_linux_static_sdk_build && inputs.linux_os_versions) || '[]') }} exclude: - ${{ fromJson(inputs.linux_static_sdk_exclude_swift_versions) }} container: @@ -437,13 +433,12 @@ jobs: wasm-sdk-build: name: Swift SDK for Wasm Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) - if: ${{ inputs.enable_wasm_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson(inputs.wasm_sdk_versions) }} - os_version: ${{ fromJson(inputs.linux_os_versions) }} + swift_version: ${{ fromJson((inputs.enable_wasm_sdk_build && inputs.wasm_sdk_versions) || '[]') }} + os_version: ${{ fromJson((inputs.enable_wasm_sdk_build && inputs.linux_os_versions) || '[]') }} exclude: - ${{ fromJson(inputs.wasm_exclude_swift_versions) }} container: @@ -515,13 +510,12 @@ jobs: embedded-wasm-sdk-build: name: Embedded Swift SDK for Wasm Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) - if: ${{ inputs.enable_embedded_wasm_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson(inputs.wasm_sdk_versions) }} - os_version: ${{ fromJson(inputs.linux_os_versions) }} + swift_version: ${{ fromJson((inputs.enable_embedded_wasm_sdk_build && inputs.wasm_sdk_versions) || '[]') }} + os_version: ${{ fromJson((inputs.enable_embedded_wasm_sdk_build && inputs.linux_os_versions) || '[]') }} exclude: - ${{ fromJson(inputs.wasm_exclude_swift_versions) }} container: @@ -593,14 +587,13 @@ jobs: android-sdk-build: name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }} - NDK ${{ matrix.ndk_version }}) - if: ${{ inputs.enable_android_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson(inputs.android_sdk_versions) }} - ndk_version: ${{ fromJson(inputs.android_ndk_versions) }} - os_version: ${{ fromJson(inputs.linux_os_versions) }} + swift_version: ${{ fromJson((inputs.enable_android_sdk_build && inputs.android_sdk_versions) || '[]') }} + ndk_version: ${{ fromJson((inputs.enable_android_sdk_build && inputs.android_ndk_versions) || '[]') }} + os_version: ${{ fromJson((inputs.enable_android_sdk_build && inputs.linux_os_versions) || '[]') }} exclude: - ${{ fromJson(inputs.android_exclude_swift_versions) }} container: @@ -672,12 +665,11 @@ jobs: windows-build: name: Windows (${{ matrix.swift_version }} - windows-2022) - if: ${{ inputs.enable_windows_checks }} runs-on: windows-2022 strategy: fail-fast: false matrix: - swift_version: ${{ fromJson(inputs.windows_swift_versions) }} + swift_version: ${{ fromJson((inputs.enable_windows_checks && inputs.windows_swift_versions) || '[]') }} exclude: - ${{ fromJson(inputs.windows_exclude_swift_versions) }} steps: From 30f1411aaee9df82ccc9728e0a23c70a7e5ce6b8 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Tue, 11 Nov 2025 09:58:56 -0800 Subject: [PATCH 24/31] Revert "Skip matrix jobs more cleanly (#183)" (#184) This reverts commit dcbe5142ca805d817d1dac2d37e29520c73ece1c. --- .github/workflows/swift_package_test.yml | 44 ++++++++++++++---------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index feed3e8e..288e198a 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -218,13 +218,14 @@ on: jobs: macos-build: name: macOS (Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) + if: ${{ inputs.enable_macos_checks }} runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"] strategy: fail-fast: false matrix: - xcode_version: ${{ fromJson((inputs.enable_macos_checks && inputs.macos_xcode_versions) || '[]') }} - os_version: ${{ fromJson((inputs.enable_macos_checks && inputs.macos_versions) || '[]') }} - arch: ${{ fromJson((inputs.enable_macos_checks && inputs.macos_archs) || '[]') }} + xcode_version: ${{ fromJson(inputs.macos_xcode_versions) }} + os_version: ${{ fromJson(inputs.macos_versions) }} + arch: ${{ fromJson(inputs.macos_archs) }} exclude: - ${{ fromJson(inputs.macos_exclude_xcode_versions) }} steps: @@ -255,13 +256,14 @@ jobs: ios-build: name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) + if: ${{ inputs.enable_ios_checks }} runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"] strategy: fail-fast: false matrix: - xcode_version: ${{ fromJson((inputs.enable_ios_checks && (inputs.ios_host_xcode_versions || inputs.macos_xcode_versions)) || '[]') }} - os_version: ${{ fromJson((inputs.enable_ios_checks && (inputs.ios_host_versions || inputs.macos_versions)) || '[]') }} - arch: ${{ fromJson((inputs.enable_ios_checks && (inputs.ios_host_archs || inputs.macos_archs)) || '[]') }} + xcode_version: ${{ fromJson(inputs.ios_host_xcode_versions || inputs.macos_xcode_versions) }} + os_version: ${{ fromJson(inputs.ios_host_versions || inputs.macos_versions) }} + arch: ${{ fromJson(inputs.ios_host_archs || inputs.macos_archs) }} exclude: - ${{ fromJson(inputs.ios_host_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }} steps: @@ -290,12 +292,13 @@ jobs: linux-build: name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }}) + if: ${{ inputs.enable_linux_checks }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson((inputs.enable_linux_checks && inputs.linux_swift_versions) || '[]') }} - os_version: ${{ fromJson((inputs.enable_linux_checks && inputs.linux_os_versions) || '[]') }} + swift_version: ${{ fromJson(inputs.linux_swift_versions) }} + os_version: ${{ fromJson(inputs.linux_os_versions) }} exclude: - ${{ fromJson(inputs.linux_exclude_swift_versions) }} container: @@ -356,12 +359,13 @@ jobs: linux-static-sdk-build: name: Static Linux Swift SDK Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) + if: ${{ inputs.enable_linux_static_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson((inputs.enable_linux_static_sdk_build && inputs.linux_static_sdk_versions) || '[]') }} - os_version: ${{ fromJson((inputs.enable_linux_static_sdk_build && inputs.linux_os_versions) || '[]') }} + swift_version: ${{ fromJson(inputs.linux_static_sdk_versions) }} + os_version: ${{ fromJson(inputs.linux_os_versions) }} exclude: - ${{ fromJson(inputs.linux_static_sdk_exclude_swift_versions) }} container: @@ -433,12 +437,13 @@ jobs: wasm-sdk-build: name: Swift SDK for Wasm Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) + if: ${{ inputs.enable_wasm_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson((inputs.enable_wasm_sdk_build && inputs.wasm_sdk_versions) || '[]') }} - os_version: ${{ fromJson((inputs.enable_wasm_sdk_build && inputs.linux_os_versions) || '[]') }} + swift_version: ${{ fromJson(inputs.wasm_sdk_versions) }} + os_version: ${{ fromJson(inputs.linux_os_versions) }} exclude: - ${{ fromJson(inputs.wasm_exclude_swift_versions) }} container: @@ -510,12 +515,13 @@ jobs: embedded-wasm-sdk-build: name: Embedded Swift SDK for Wasm Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) + if: ${{ inputs.enable_embedded_wasm_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson((inputs.enable_embedded_wasm_sdk_build && inputs.wasm_sdk_versions) || '[]') }} - os_version: ${{ fromJson((inputs.enable_embedded_wasm_sdk_build && inputs.linux_os_versions) || '[]') }} + swift_version: ${{ fromJson(inputs.wasm_sdk_versions) }} + os_version: ${{ fromJson(inputs.linux_os_versions) }} exclude: - ${{ fromJson(inputs.wasm_exclude_swift_versions) }} container: @@ -587,13 +593,14 @@ jobs: android-sdk-build: name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }} - NDK ${{ matrix.ndk_version }}) + if: ${{ inputs.enable_android_sdk_build }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - swift_version: ${{ fromJson((inputs.enable_android_sdk_build && inputs.android_sdk_versions) || '[]') }} - ndk_version: ${{ fromJson((inputs.enable_android_sdk_build && inputs.android_ndk_versions) || '[]') }} - os_version: ${{ fromJson((inputs.enable_android_sdk_build && inputs.linux_os_versions) || '[]') }} + swift_version: ${{ fromJson(inputs.android_sdk_versions) }} + ndk_version: ${{ fromJson(inputs.android_ndk_versions) }} + os_version: ${{ fromJson(inputs.linux_os_versions) }} exclude: - ${{ fromJson(inputs.android_exclude_swift_versions) }} container: @@ -665,11 +672,12 @@ jobs: windows-build: name: Windows (${{ matrix.swift_version }} - windows-2022) + if: ${{ inputs.enable_windows_checks }} runs-on: windows-2022 strategy: fail-fast: false matrix: - swift_version: ${{ fromJson((inputs.enable_windows_checks && inputs.windows_swift_versions) || '[]') }} + swift_version: ${{ fromJson(inputs.windows_swift_versions) }} exclude: - ${{ fromJson(inputs.windows_exclude_swift_versions) }} steps: From 0afed449df03f1e8fc61924e537a01805bbce3d8 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 12 Nov 2025 08:47:12 +1000 Subject: [PATCH 25/31] Update github-workflows source location for Windows docker (#186) The workspace is mounted into `C:\source` when using docker, update the script root to take that into account. --- .github/workflows/swift_package_test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 288e198a..0376ab47 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -692,10 +692,16 @@ jobs: - name: Determine script-root path id: script_path run: | + if ("${{ inputs.enable_windows_docker }}" -eq "true") { + $source = "C:\source" + } else { + $source = $env:GITHUB_WORKSPACE + } + if ("${{ github.repository }}" -eq "swiftlang/github-workflows") { - echo "root=$env:GITHUB_WORKSPACE" >> $env:GITHUB_OUTPUT + echo "root=$source" >> $env:GITHUB_OUTPUT } else { - echo "root=$env:GITHUB_WORKSPACE/github-workflows" >> $env:GITHUB_OUTPUT + echo "root=$source/github-workflows" >> $env:GITHUB_OUTPUT } - name: Provide token if: ${{ inputs.needs_token }} From 04e42367110d8c53c717f54e5332d256505665be Mon Sep 17 00:00:00 2001 From: award999 Date: Wed, 12 Nov 2025 09:41:36 -0500 Subject: [PATCH 26/31] Install 6.2.1 for Windows (#187) --- .github/workflows/scripts/windows/swift/install-swift-6.2.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/windows/swift/install-swift-6.2.ps1 b/.github/workflows/scripts/windows/swift/install-swift-6.2.ps1 index 392d0086..2827cb9d 100644 --- a/.github/workflows/scripts/windows/swift/install-swift-6.2.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift-6.2.ps1 @@ -11,7 +11,7 @@ ##===----------------------------------------------------------------------===## . $PSScriptRoot\install-swift.ps1 -$SWIFT='https://download.swift.org/swift-6.2-release/windows10/swift-6.2-RELEASE/swift-6.2-RELEASE-windows10.exe' -$SWIFT_SHA256='80FBBC17D4F9EDEC74A83ABBEFEB9FF418FFC2158CD347111583C45E47F9789B' +$SWIFT='https://download.swift.org/swift-6.2.1-release/windows10/swift-6.2.1-RELEASE/swift-6.2.1-RELEASE-windows10.exe' +$SWIFT_SHA256='FD1209AC3E008152924E0409E5590F2FE41644132E532D4526B8641339E88000' Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256 From 54f71e9c214cbac37f7a393420c45cff419476c0 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 20 Nov 2025 08:32:04 -0800 Subject: [PATCH 27/31] Various fixes for Amazon Linux 2 (#188) * Add missing executable bit to install-and-build-with-sdk.sh script * Don't use unnecessary piping This causes failures to be ignored when -o pipefail is not set. * Check out github-workflows into subdirectory checkout@v1 and checkout@v4 differ in their behavior, try to make v1 clone the workflows repo in the same place as v4. * Stop installing curl when we don't need it This can save tens of seconds on some of the soundness checks. --- .github/workflows/scripts/check-docs.sh | 2 +- .../scripts/install-and-build-with-sdk.sh | 0 .github/workflows/soundness.yml | 14 ++-- .github/workflows/swift_package_test.yml | 71 +++---------------- 4 files changed, 15 insertions(+), 72 deletions(-) mode change 100644 => 100755 .github/workflows/scripts/install-and-build-with-sdk.sh diff --git a/.github/workflows/scripts/check-docs.sh b/.github/workflows/scripts/check-docs.sh index 5c4fb026..f170af15 100755 --- a/.github/workflows/scripts/check-docs.sh +++ b/.github/workflows/scripts/check-docs.sh @@ -23,7 +23,7 @@ if [ ! -f .spi.yml ]; then fi if ! command -v yq &> /dev/null; then - fatal "yq could not be found. Please install yq to proceed." + apt -q update && apt -yq install yq fi package_files=$(find . -maxdepth 1 -name 'Package*.swift') diff --git a/.github/workflows/scripts/install-and-build-with-sdk.sh b/.github/workflows/scripts/install-and-build-with-sdk.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 6c8aad28..95e5e7fd 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -162,9 +162,7 @@ jobs: - name: Run documentation check env: ADDITIONAL_DOCC_ARGUMENTS: ${{ inputs.docs_check_additional_arguments }} - run: | - which curl yq || (apt -q update && apt -yq install curl yq) - cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-docs.sh | bash + run: ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-docs.sh unacceptable-language-check: name: Unacceptable language check @@ -194,7 +192,7 @@ jobs: - name: Run unacceptable language check env: UNACCEPTABLE_WORD_LIST: ${{ inputs.unacceptable_language_check_word_list}} - run: cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-unacceptable-language.sh | bash + run: ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-unacceptable-language.sh license-header-check: name: License headers check @@ -224,7 +222,7 @@ jobs: - name: Run license header check env: PROJECT_NAME: ${{ inputs.license_header_check_project_name }} - run: cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-license-header.sh | bash + run: ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-license-header.sh broken-symlink-check: name: Broken symlinks check @@ -252,7 +250,7 @@ jobs: echo "root=$GITHUB_WORKSPACE/github-workflows" >> $GITHUB_OUTPUT fi - name: Run broken symlinks check - run: cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-broken-symlinks.sh | bash + run: ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-broken-symlinks.sh format-check: name: Format check @@ -285,9 +283,7 @@ jobs: # https://github.com/actions/checkout/issues/766 run: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Run format check - run: | - which curl || (apt -q update && apt -yq install curl) - cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-swift-format.sh | bash + run: ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/check-swift-format.sh shell-check: name: Shell check diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 0376ab47..8637a1c2 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -325,7 +325,7 @@ jobs: uses: actions/checkout@v1 with: repository: swiftlang/github-workflows - path: github-workflows + path: ${{ github.event.repository.name }}/github-workflows ref: main - name: Determine script-root path id: script_path @@ -342,7 +342,6 @@ jobs: - name: Check out related PRs if: ${{ inputs.enable_cross_pr_testing && github.event_name == 'pull_request' }} run: | - apt-get update && apt-get install -y curl cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/cross-pr-checkout.swift > /tmp/cross-pr-checkout.swift swift /tmp/cross-pr-checkout.swift "${{ github.repository }}" "${{ github.event.number }}" - name: Set environment variables @@ -392,7 +391,7 @@ jobs: uses: actions/checkout@v1 with: repository: swiftlang/github-workflows - path: github-workflows + path: ${{ github.event.repository.name }}/github-workflows ref: main - name: Determine script-root path id: script_path @@ -420,20 +419,7 @@ jobs: BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} run: | ${{ inputs.linux_static_sdk_pre_build_command }} - if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal - apt-get -q update && apt-get -yq install curl - elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 - dnf -y update - dnf -y install curl-minimal - elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 - yum -y update - yum -y install curl - else - echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 - exit 1 - fi - cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --static --flags="$BUILD_FLAGS" --build-command="${{ inputs.linux_static_sdk_build_command }}" ${{ matrix.swift_version }} + ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh --static --flags="$BUILD_FLAGS" --build-command="${{ inputs.linux_static_sdk_build_command }}" ${{ matrix.swift_version }} wasm-sdk-build: name: Swift SDK for Wasm Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) @@ -470,7 +456,7 @@ jobs: uses: actions/checkout@v1 with: repository: swiftlang/github-workflows - path: github-workflows + path: ${{ github.event.repository.name }}/github-workflows ref: main - name: Determine script-root path id: script_path @@ -498,20 +484,7 @@ jobs: BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} run: | ${{ inputs.wasm_sdk_pre_build_command }} - if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal - apt-get -q update && apt-get -yq install curl - elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 - dnf -y update - dnf -y install curl-minimal - elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 - yum -y update - yum -y install curl - else - echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 - exit 1 - fi - cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --wasm --flags="$BUILD_FLAGS" --build-command="${{ inputs.wasm_sdk_build_command }}" ${{ matrix.swift_version }} + ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh --wasm --flags="$BUILD_FLAGS" --build-command="${{ inputs.wasm_sdk_build_command }}" ${{ matrix.swift_version }} embedded-wasm-sdk-build: name: Embedded Swift SDK for Wasm Build (${{ matrix.swift_version }} - ${{ matrix.os_version }}) @@ -548,7 +521,7 @@ jobs: uses: actions/checkout@v1 with: repository: swiftlang/github-workflows - path: github-workflows + path: ${{ github.event.repository.name }}/github-workflows ref: main - name: Determine script-root path id: script_path @@ -576,20 +549,7 @@ jobs: BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} run: | ${{ inputs.wasm_sdk_pre_build_command }} - if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal - apt-get -q update && apt-get -yq install curl - elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 - dnf -y update - dnf -y install curl-minimal - elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 - yum -y update - yum -y install curl - else - echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 - exit 1 - fi - cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --embedded-wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }} + ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh --embedded-wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }} android-sdk-build: name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }} - NDK ${{ matrix.ndk_version }}) @@ -627,7 +587,7 @@ jobs: uses: actions/checkout@v1 with: repository: swiftlang/github-workflows - path: github-workflows + path: ${{ github.event.repository.name }}/github-workflows ref: main - name: Determine script-root path id: script_path @@ -655,20 +615,7 @@ jobs: BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} run: | ${{ inputs.android_sdk_pre_build_command }} - if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal - apt-get -q update && apt-get -yq install curl - elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 - dnf -y update - dnf -y install curl-minimal - elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 - yum -y update - yum -y install curl - else - echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 - exit 1 - fi - cat ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple=${{ join(fromJson(inputs.android_sdk_triples), ' --android-sdk-triple=') }} --android-ndk-version="${{ matrix.ndk_version }}" ${{ matrix.swift_version }} + ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/install-and-build-with-sdk.sh --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple=${{ join(fromJson(inputs.android_sdk_triples), ' --android-sdk-triple=') }} --android-ndk-version="${{ matrix.ndk_version }}" ${{ matrix.swift_version }} windows-build: name: Windows (${{ matrix.swift_version }} - windows-2022) From 071bbad7ff4ef2c46089c677975ecbac02b6a1a2 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 20 Nov 2025 12:15:05 -0800 Subject: [PATCH 28/31] Switch shellcheck soundness check to a lighter weight image (#191) This just installs and runs shellcheck. It doesn't need a 1 GB Swift toolchain image, use the much smaller baseline Ubuntu Noble variant. This makes shellcheck run faster and doesn't waste resources. --- .github/workflows/soundness.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 95e5e7fd..ce8f63f0 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -65,8 +65,8 @@ on: default: true shell_check_container_image: type: string - description: "Container image for the shell check job. Defaults to latest Swift Ubuntu image." - default: "swift:6.2-noble" + description: "Container image for the shell check job. Defaults to latest Ubuntu 24.04 Noble image." + default: "ubuntu:noble" yamllint_check_enabled: type: boolean description: "Boolean to enable the YAML lint check job. Defaults to true." @@ -293,6 +293,8 @@ jobs: image: ${{ inputs.shell_check_container_image }} timeout-minutes: 5 steps: + - name: Install git + run: which git || (apt -q update && apt -yq install git) - name: Checkout repository uses: actions/checkout@v4 with: From 30fccd9863ccad4db19144d0808b629de9ef8a45 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 20 Nov 2025 16:19:44 -0800 Subject: [PATCH 29/31] Remove Swift SDK download archives after installing them (#192) This avoids using unnecessary disk space that the action might need. --- .github/workflows/scripts/install-and-build-with-sdk.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/scripts/install-and-build-with-sdk.sh b/.github/workflows/scripts/install-and-build-with-sdk.sh index c3347445..e866ca14 100755 --- a/.github/workflows/scripts/install-and-build-with-sdk.sh +++ b/.github/workflows/scripts/install-and-build-with-sdk.sh @@ -568,6 +568,8 @@ install_android_sdk() { fatal "Failed to install Android Swift SDK" fi + rm -f "${sdk_url}" + # now setup the link to the local ANDROID_NDK_HOME swift sdk configure --show-configuration "$(swift sdk list | grep android | tail -n 1)" @@ -611,6 +613,8 @@ install_static_linux_sdk() { else fatal "Failed to install Static Linux Swift SDK" fi + + rm -f "${sdk_url}" } install_wasm_sdk() { @@ -632,6 +636,8 @@ install_wasm_sdk() { else fatal "Failed to install Swift SDK for Wasm" fi + + rm -f "${sdk_url}" } install_sdks() { From bd52b59f6c0d922f01f8d3f5e1f3279da52b8480 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Mon, 1 Dec 2025 23:44:13 +0100 Subject: [PATCH 30/31] Invoke `swift-format` instead of `swift format` in `check-swift-format.sh` (#193) This allows us to override the `swift-format` executable to a locally built copy by adding the locally built version to PATH in https://github.com/swiftlang/swift-format/pull/1093. --- .github/workflows/scripts/check-swift-format.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/scripts/check-swift-format.sh b/.github/workflows/scripts/check-swift-format.sh index a3c32216..fb6d351b 100755 --- a/.github/workflows/scripts/check-swift-format.sh +++ b/.github/workflows/scripts/check-swift-format.sh @@ -21,19 +21,19 @@ fatal() { error "$@"; exit 1; } if [[ -f .swiftformatignore ]]; then log "Found swiftformatignore file..." - log "Running swift format format..." - tr '\n' '\0' < .swiftformatignore| xargs -0 -I% printf '":(exclude)%" '| xargs git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place + log "Running swift-format format..." + tr '\n' '\0' < .swiftformatignore| xargs -0 -I% printf '":(exclude)%" '| xargs git ls-files -z '*.swift' | xargs -0 swift-format format --parallel --in-place - log "Running swift format lint..." + log "Running swift-format lint..." - tr '\n' '\0' < .swiftformatignore | xargs -0 -I% printf '":(exclude)%" '| xargs git ls-files -z '*.swift' | xargs -0 swift format lint --strict --parallel + tr '\n' '\0' < .swiftformatignore | xargs -0 -I% printf '":(exclude)%" '| xargs git ls-files -z '*.swift' | xargs -0 swift-format lint --strict --parallel else - log "Running swift format format..." - git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place + log "Running swift-format format..." + git ls-files -z '*.swift' | xargs -0 swift-format format --parallel --in-place - log "Running swift format lint..." + log "Running swift-format lint..." - git ls-files -z '*.swift' | xargs -0 swift format lint --strict --parallel + git ls-files -z '*.swift' | xargs -0 swift-format lint --strict --parallel fi From 4b0f2e8d2864c3e8545468eb9f9d727778951ac6 Mon Sep 17 00:00:00 2001 From: Bassam Khouri Date: Tue, 2 Dec 2025 09:42:55 -0500 Subject: [PATCH 31/31] Update automerger workflow Add additional configurability to the GitHub automerger workflow to optionally create the PR as non-draft, and to trigger testing --- .github/workflows/create_automerge_pr.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create_automerge_pr.yml b/.github/workflows/create_automerge_pr.yml index ca2e0922..0a04f687 100644 --- a/.github/workflows/create_automerge_pr.yml +++ b/.github/workflows/create_automerge_pr.yml @@ -59,6 +59,14 @@ on: type: string description: The message that should be included in the PR created by this job default: This PR was automatically opened by a GitHub action. Review the changes included in this PR and determine if they should be included in the release branch. If yes, merge the PR. Otherwise revert changes that should not be included on this branch. + create_as_draft: + type: boolean + description: Whether to create the PR as a draft + default: true + should_test: + type: boolean + description: Whether the created PR should trigger tests + default: false jobs: create_merge_pr: @@ -93,6 +101,10 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | + # Define variables based on workflow input + if [[ "${{ inputs.create_as_draft }} == "true" ]] ; then + DRAFT_FLAG="--draft" + fi # Create a branch for the PR instead of opening a PR that merges head_branch directly so that we have a fixed # target in the PR and don't modify the PR as new commits are put on the head branch. PR_BRANCH="automerge/merge-main-$(date +%Y-%m-%d_%H-%M)" @@ -102,7 +114,11 @@ jobs: gh pr create \ --base "${{ inputs.base_branch }}" \ - --head "$PR_BRANCH" \ + --head "$PR_BRANCH" ${DRAFT_FLAG} \ --title 'Merge `${{ inputs.head_branch }}` into `${{ inputs.base_branch }}`' \ - --body '${{ inputs.pr_message }}' \ - --draft + --body '${{ inputs.pr_message }}' + + # Trigger tests is requested + if [[ "${{ inputs.should_test }}" == "true" ]] ; then + gh pr ready "$PR_BRANCH" + fi