Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 23 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 }
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
8 changes: 5 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
--disable blankLineAfterSwitchCase

# global
--swiftversion 6.2
--swiftversion 6.4
2 changes: 1 addition & 1 deletion CLI/Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 8 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// 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

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(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
]
```

Expand Down
46 changes: 23 additions & 23 deletions Scripts/build.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/AsyncQueueTests/ActorQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ActorQueueTests {
func adoptExecutionContext_doesNotRetainActor() {
let systemUnderTest = ActorQueue<Counter>()
var counter: Counter? = Counter()
weak var weakCounter = counter
weak let weakCounter = counter
systemUnderTest.adoptExecutionContext(of: counter!)
counter = nil
#expect(weakCounter == nil)
Expand All @@ -50,7 +50,7 @@ struct ActorQueueTests {
func task_retainsAdoptedActorUntilEnqueuedTasksComplete() async {
let systemUnderTest = ActorQueue<Counter>()
var counter: Counter? = Counter()
weak var weakCounter = counter
weak let weakCounter = counter
systemUnderTest.adoptExecutionContext(of: counter!)

let semaphore = Semaphore()
Expand All @@ -67,7 +67,7 @@ struct ActorQueueTests {
func throwingTask_retainsAdoptedActorUntilEnqueuedTasksComplete() async {
let systemUnderTest = ActorQueue<Counter>()
var counter: Counter? = Counter()
weak var weakCounter = counter
weak let weakCounter = counter
systemUnderTest.adoptExecutionContext(of: counter!)

let semaphore = Semaphore()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Tests/AsyncQueueTests/FIFOQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions Tests/AsyncQueueTests/Utilities/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
Loading