From cf39e867ef93b1c5876a670eb42709fc0631513a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 13 Nov 2026 22:12:32 +0000 Subject: [PATCH 1/2] Raise minimum Swift, Xcode, and platform versions Begin a breaking-change series for 2.0.0: - Require Swift tools version 6.4, and build and lint with Swift 6.4 on Linux and Xcode 27.2 on macOS. - Raise the platform minimums to the first releases that ship the Synchronization module's `Mutex`: macOS 15, iOS 18, tvOS 18, watchOS 11, Mac Catalyst 18, and visionOS 2. The `xcode-27` runner image ships the Xcode 27.2 simulator runtimes, so CI no longer downloads platforms. Swift 6.4 builds with Swift Build by default, so the Linux coverage step reads the test binary from the new products directory. Tests declare never-reassigned weak references with `weak let`, which Swift 6.4 otherwise warns about. The tests' `DispatchQueueExecutor` implements the `ExecutorJob` form of `enqueue(_:)`, which the raised minimums allow. CI jobs and build platforms are now named without tool or OS versions ("Build Xcode (iOS,watchOS)", "Swift Build Xcode", "Build and Test on Linux"), so that future toolchain updates do not change the names of the checks that branch protection requires. The required checks on `main` need to be updated once, when this change lands. The renamed jobs keep their timeouts. The simulator jobs' longest run so far on the `xcode-27` image took about 25 minutes, half of their 50-minute timeout, and the others still take about a minute, well within their 15 minutes. The Linux job's check that every coverage counter update is atomic reads the same binary as the coverage export, `AsyncQueueTests.so`. Swift Build passes `-instrprof-atomic-counter-update-all` through on Linux, so the check passes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HLuVQLsTNvRnyh155N25UM --- .github/workflows/ci.yml | 65 +++++++------------ .github/workflows/codeql.yml | 4 +- .swiftformat | 2 +- CLI/Package.swift | 2 +- Package.swift | 15 +++-- README.md | 2 +- Scripts/build.swift | 46 ++++++------- Tests/AsyncQueueTests/ActorQueueTests.swift | 10 +-- Tests/AsyncQueueTests/FIFOQueueTests.swift | 8 +-- .../Utilities/TestHelpers.swift | 7 +- 10 files changed, 70 insertions(+), 91 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6492921..774b41c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,18 +14,20 @@ concurrency: cancel-in-progress: true jobs: - spm-16: - name: Build Xcode 26 - runs-on: macos-15 + # Job names omit tool and OS versions so that branch protection's required checks survive toolchain updates. + spm: + name: Build Xcode + # The `xcode-27` image ships Xcode 27.2 with its simulator runtimes installed. + runs-on: xcode-27 # A test that deadlocks keeps the test run from ending, so stop the # job after 50 minutes rather than at GitHub's six-hour default. timeout-minutes: 50 strategy: matrix: platforms: [ - 'iOS_18,watchOS_11', - 'macOS_26,tvOS_18', - 'visionOS_2' + 'iOS,watchOS', + 'macOS,tvOS', + 'visionOS' ] fail-fast: false permissions: @@ -34,31 +36,7 @@ jobs: - name: Checkout Repo uses: actions/checkout@v7 - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_26.1.1.app/Contents/Developer - - name: Download visionOS - if: matrix.platforms == 'visionOS_2' - run: | - sudo xcodebuild -runFirstLaunch - sudo xcrun simctl list - sudo xcodebuild -downloadPlatform visionOS - - name: Download iOS - if: matrix.platforms == 'iOS_18,watchOS_11' - run: | - sudo xcodebuild -runFirstLaunch - sudo xcrun simctl list - sudo xcodebuild -downloadPlatform iOS -buildVersion 22F77 - - name: Download watchOS - if: matrix.platforms == 'iOS_18,watchOS_11' - run: | - sudo xcodebuild -runFirstLaunch - sudo xcrun simctl list - sudo xcodebuild -downloadPlatform watchOS -buildVersion 22T572 - - name: Download tvOS - if: matrix.platforms == 'macOS_26,tvOS_18' - run: | - sudo xcodebuild -runFirstLaunch - sudo xcrun simctl list - sudo xcodebuild -downloadPlatform tvOS -buildVersion 22L572 + run: sudo xcode-select --switch /Applications/Xcode_27.2.app/Contents/Developer - name: Build and Test Framework run: Scripts/build.swift ${{ matrix.platforms }} - name: Prepare Coverage Reports @@ -69,9 +47,9 @@ jobs: with: fail_ci_if_error: true verbose: true - spm-16-swift: - name: Swift Build Xcode 26 - runs-on: macos-15 + spm-swift: + name: Swift Build Xcode + runs-on: xcode-27 # A test that deadlocks keeps the test run from ending, so stop the # job after 15 minutes rather than at GitHub's six-hour default. timeout-minutes: 15 @@ -81,13 +59,13 @@ jobs: - name: Checkout Repo uses: actions/checkout@v7 - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_26.1.1.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_27.2.app/Contents/Developer - name: Build and Test Framework run: xcrun swift test -c release -Xswiftc -enable-testing - linux-6-2: - name: "Build and Test on Linux Swift 6.2" + linux: + name: "Build and Test on Linux" runs-on: ubuntu-24.04 - container: swift:6.2 + container: swift:6.4 # A test that deadlocks keeps the test run from ending, so stop the # job after 15 minutes rather than at GitHub's six-hour default. timeout-minutes: 15 @@ -115,7 +93,8 @@ jobs: # test binary fails the step with llvm-objdump's own error. - name: Check Atomic Coverage Counters run: | - llvm-objdump -d --no-show-raw-insn .build/x86_64-unknown-linux-gnu/release/swift-async-queuePackageTests.xctest > .build/disassembly.txt + BIN_PATH=$(swift build -c release --show-bin-path) + llvm-objdump -d --no-show-raw-insn "$BIN_PATH/AsyncQueueTests.so" > .build/disassembly.txt awk ' /<__profc_/ && $2 != "leaq" { if (previous == "lock") atomic++; else plain++ } { previous = $2 } @@ -126,8 +105,10 @@ jobs: exit (plain > 0 || atomic == 0) }' .build/disassembly.txt - name: Prepare Coverage Reports + # Swift 6.4 builds with Swift Build, which links the tests into `AsyncQueueTests.so`. run: | - llvm-cov export -format="lcov" .build/x86_64-unknown-linux-gnu/release/swift-async-queuePackageTests.xctest -instr-profile .build/x86_64-unknown-linux-gnu/release/codecov/default.profdata > coverage.lcov + BIN_PATH=$(swift build -c release --show-bin-path) + llvm-cov export -format="lcov" "$BIN_PATH/AsyncQueueTests.so" -instr-profile "$BIN_PATH/codecov/default.profdata" > coverage.lcov - name: Install curl for Codecov run: | apt-get update @@ -171,7 +152,7 @@ jobs: lint-swift: name: Lint Swift runs-on: ubuntu-latest - container: swift:6.2 + container: swift:6.4 permissions: contents: read steps: @@ -183,6 +164,6 @@ jobs: uses: actions/cache@v6 with: path: CLI/.build - key: swiftformat-${{ runner.os }}-swift-6.2-${{ hashFiles('CLI/Package.resolved') }} + key: swiftformat-${{ runner.os }}-swift-6.4-${{ hashFiles('CLI/Package.resolved') }} - name: Lint Swift run: swift run --package-path CLI swiftformat . --lint diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 574bf1e..129b496 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest - language: swift build-mode: manual - runs-on: macos-15 + runs-on: xcode-27 # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift' # Use `c-cpp` to analyze code written in C, C++ or both # Use 'java-kotlin' to analyze code written in Java, Kotlin or both @@ -50,7 +50,7 @@ jobs: uses: actions/checkout@v7 - if: matrix.language == 'swift' name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_26.1.1.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_27.2.app/Contents/Developer # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.swiftformat b/.swiftformat index 05d8160..69a397a 100644 --- a/.swiftformat +++ b/.swiftformat @@ -20,4 +20,4 @@ --disable blankLineAfterSwitchCase # global ---swiftversion 6.2 +--swiftversion 6.4 diff --git a/CLI/Package.swift b/CLI/Package.swift index caf3e61..ce0c5d5 100644 --- a/CLI/Package.swift +++ b/CLI/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.2 +// swift-tools-version: 6.4 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Package.swift b/Package.swift index 0ce69cf..74d159f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.2 +// swift-tools-version: 6.4 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -6,12 +6,13 @@ import PackageDescription let package = Package( name: "swift-async-queue", platforms: [ - .macOS(.v10_15), - .iOS(.v13), - .tvOS(.v13), - .watchOS(.v6), - .macCatalyst(.v13), - .visionOS(.v1), + // The minimum versions that support `Mutex`. + .macOS(.v15), + .iOS(.v18), + .tvOS(.v18), + .watchOS(.v11), + .macCatalyst(.v18), + .visionOS(.v2), ], products: [ .library( diff --git a/README.md b/README.md index 475037d..c00ab17 100644 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ To install swift-async-queue in your project with [Swift Package Manager](https: ```swift dependencies: [ - .package(url: "https://github.com/dfed/swift-async-queue", from: "1.0.0"), + .package(url: "https://github.com/dfed/swift-async-queue", from: "2.0.0"), ] ``` diff --git a/Scripts/build.swift b/Scripts/build.swift index 3af8069..d5a0447 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -21,49 +21,49 @@ enum TaskError: Error { } enum Platform: String, CaseIterable, CustomStringConvertible { - case iOS_18 - case tvOS_18 - case macOS_26 - case macCatalyst_15 - case watchOS_11 - case visionOS_2 + case iOS + case tvOS + case macOS + case macCatalyst + case watchOS + case visionOS var destination: String { switch self { - case .iOS_18: - "platform=iOS Simulator,OS=18.5,name=iPad (10th generation)" + case .iOS: + "platform=iOS Simulator,OS=27.2,name=iPad (A16)" - case .tvOS_18: - "platform=tvOS Simulator,OS=18.5,name=Apple TV" + case .tvOS: + "platform=tvOS Simulator,OS=27.2,name=Apple TV 4K (4th generation)" - case .macOS_26, - .macCatalyst_15: + case .macOS, + .macCatalyst: "platform=OS X" - case .watchOS_11: - "OS=11.5,name=Apple Watch Series 10 (46mm)" + case .watchOS: + "OS=27.2,name=Apple Watch Series 12 (46mm)" - case .visionOS_2: - "OS=2.5,name=Apple Vision Pro" + case .visionOS: + "OS=27.2,name=Apple Vision Pro" } } var sdk: String { switch self { - case .iOS_18: + case .iOS: "iphonesimulator" - case .tvOS_18: + case .tvOS: "appletvsimulator" - case .macOS_26, - .macCatalyst_15: - "macosx26.1" + case .macOS, + .macCatalyst: + "macosx27.2" - case .watchOS_11: + case .watchOS: "watchsimulator" - case .visionOS_2: + case .visionOS: "xrsimulator" } } diff --git a/Tests/AsyncQueueTests/ActorQueueTests.swift b/Tests/AsyncQueueTests/ActorQueueTests.swift index 378656b..292e212 100644 --- a/Tests/AsyncQueueTests/ActorQueueTests.swift +++ b/Tests/AsyncQueueTests/ActorQueueTests.swift @@ -40,7 +40,7 @@ struct ActorQueueTests { func adoptExecutionContext_doesNotRetainActor() { let systemUnderTest = ActorQueue() var counter: Counter? = Counter() - weak var weakCounter = counter + weak let weakCounter = counter systemUnderTest.adoptExecutionContext(of: counter!) counter = nil #expect(weakCounter == nil) @@ -50,7 +50,7 @@ struct ActorQueueTests { func task_retainsAdoptedActorUntilEnqueuedTasksComplete() async { let systemUnderTest = ActorQueue() var counter: Counter? = Counter() - weak var weakCounter = counter + weak let weakCounter = counter systemUnderTest.adoptExecutionContext(of: counter!) let semaphore = Semaphore() @@ -67,7 +67,7 @@ struct ActorQueueTests { func throwingTask_retainsAdoptedActorUntilEnqueuedTasksComplete() async { let systemUnderTest = ActorQueue() var counter: Counter? = Counter() - weak var weakCounter = counter + weak let weakCounter = counter systemUnderTest.adoptExecutionContext(of: counter!) let semaphore = Semaphore() @@ -249,7 +249,7 @@ struct ActorQueueTests { await semaphore.wait() counter.incrementAndExpectCount(equals: 1) } - weak var queue = systemUnderTest + weak let queue = systemUnderTest // Nil out our reference to the queue to show that the enqueued tasks will still complete systemUnderTest = nil #expect(queue == nil) @@ -273,7 +273,7 @@ struct ActorQueueTests { await semaphore.wait() counter.incrementAndExpectCount(equals: 1) } - weak var queue = systemUnderTest + weak let queue = systemUnderTest // Nil out our reference to the queue to show that the enqueued tasks will still complete systemUnderTest = nil #expect(queue == nil) diff --git a/Tests/AsyncQueueTests/FIFOQueueTests.swift b/Tests/AsyncQueueTests/FIFOQueueTests.swift index 1baa78f..b506139 100644 --- a/Tests/AsyncQueueTests/FIFOQueueTests.swift +++ b/Tests/AsyncQueueTests/FIFOQueueTests.swift @@ -275,7 +275,7 @@ struct FIFOQueueTests { // This async task should not execute until the semaphore is released. await counter.incrementAndExpectCount(equals: 2) } - weak var queue = systemUnderTest + weak let queue = systemUnderTest // Nil out our reference to the queue to show that the enqueued tasks will still complete systemUnderTest = nil #expect(queue == nil) @@ -300,7 +300,7 @@ struct FIFOQueueTests { // This async task should not execute until the semaphore is released. counter.incrementAndExpectCount(equals: 2) } - weak var queue = systemUnderTest + weak let queue = systemUnderTest // Nil out our reference to the queue to show that the enqueued tasks will still complete systemUnderTest = nil #expect(queue == nil) @@ -327,7 +327,7 @@ struct FIFOQueueTests { await counter.incrementAndExpectCount(equals: 2) try doWork() } - weak var queue = systemUnderTest + weak let queue = systemUnderTest // Nil out our reference to the queue to show that the enqueued tasks will still complete systemUnderTest = nil #expect(queue == nil) @@ -354,7 +354,7 @@ struct FIFOQueueTests { counter.incrementAndExpectCount(equals: 2) try doWork() } - weak var queue = systemUnderTest + weak let queue = systemUnderTest // Nil out our reference to the queue to show that the enqueued tasks will still complete systemUnderTest = nil #expect(queue == nil) diff --git a/Tests/AsyncQueueTests/Utilities/TestHelpers.swift b/Tests/AsyncQueueTests/Utilities/TestHelpers.swift index 18718ab..506a9f1 100644 --- a/Tests/AsyncQueueTests/Utilities/TestHelpers.swift +++ b/Tests/AsyncQueueTests/Utilities/TestHelpers.swift @@ -37,16 +37,13 @@ func suspendUntilCancelled() async { /// A serial executor that runs its jobs on a dispatch queue of its own, in the order in which they are enqueued. final class DispatchQueueExecutor: SerialExecutor { - func enqueue(_ job: UnownedJob) { + func enqueue(_ job: consuming ExecutorJob) { + let job = UnownedJob(job) dispatchQueue.async { [self] in job.runSynchronously(on: asUnownedSerialExecutor()) } } - func asUnownedSerialExecutor() -> UnownedSerialExecutor { - UnownedSerialExecutor(ordinary: self) - } - private let dispatchQueue = DispatchQueue(label: "DispatchQueueExecutor") } From 9a40bacd0f8ada373f5374b5ba292bf45e0f0915 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Mon, 16 Nov 2026 15:39:08 -0800 Subject: [PATCH 2/2] Build without SwiftPM's sandbox under CodeQL On the xcode-27 image, SwiftPM's sandbox-exec cannot launch the compiled package manifest under the CodeQL tracer ("Bad CPU type in executable"), so the Swift analysis failed every run. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/codeql.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 129b496..5974a5f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -79,7 +79,9 @@ jobs: export PATH="$TOOLCHAIN:$DEVELOPER_DIR/usr/bin:$PATH" SDKROOT=$(xcrun --sdk macosx --show-sdk-path) export SDKROOT - arch -arm64 "$TOOLCHAIN/swift" build --target AsyncQueue + # Under the CodeQL tracer, SwiftPM's sandbox-exec cannot launch the compiled manifest + # ("Bad CPU type in executable"), so build without SwiftPM's sandbox. + arch -arm64 "$TOOLCHAIN/swift" build --target AsyncQueue --disable-sandbox - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v4