Skip to content

Commit

Permalink
Swift 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NikSativa committed Sep 27, 2024
1 parent e904712 commit 084fe56
Show file tree
Hide file tree
Showing 26 changed files with 1,071 additions and 436 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/swift_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "NikSativa CI"

on:
push:
branches:
- "main"
paths:
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"
pull_request:
paths:
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"

concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true
jobs:
macOS:
name: "macOS ${{ matrix.xcode }} ${{ matrix.swift }}"
runs-on: ${{ matrix.runsOn }}
env:
DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer"
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16"
runsOn: macOS-15
swift: "6.0"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_15.4"
runsOn: macOS-14
swift: "5.10"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_15.2"
runsOn: macOS-14
swift: "5.9"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_14.3"
runsOn: macOS-13
swift: "5.8"
outputFilter: xcbeautify --renderer github-actions
steps:
- uses: NeedleInAJayStack/setup-swift@feat/swift-6 # swift-actions/setup-swift@main
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: "Build ${{ matrix.xcode }} ${{ matrix.swift }}"
run: swift build -v | ${{ matrix.outputFilter }}
- name: "Test ${{ matrix.xcode }} ${{ matrix.swift }}"
run: swift test -v | ${{ matrix.outputFilter }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Pods/*
Carthage/*
Packages/*
.swiftpm/*
Package.resolved

## Bundler
.bundle/
Expand Down
8 changes: 8 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is manifest file for the Swift Package Index for it to
# auto-generate and host DocC documentation.
# For reference see https://swiftpackageindex.com/swiftpackageindex/spimanifest/documentation/spimanifest/commonusecases#Host-DocC-documentation-in-the-Swift-Package-Index.

version: 1
builder:
configs:
- documentation_targets: [DefferedTaskKit]
41 changes: 0 additions & 41 deletions Package.resolved

This file was deleted.

8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0
// swiftformat:disable all
import PackageDescription

Expand All @@ -16,8 +16,8 @@ let package = Package(
.library(name: "DefferedTaskKit", targets: ["DefferedTaskKit"])
],
dependencies: [
.package(url: "https://github.com/NikSativa/Threading.git", .upToNextMinor(from: "1.3.5")),
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "2.2.3"))
.package(url: "https://github.com/NikSativa/Threading.git", branch: "2.0.0"),
.package(url: "https://github.com/NikSativa/SpryKit.git", branch: "3.0.0")
],
targets: [
.target(name: "DefferedTaskKit",
Expand All @@ -26,7 +26,7 @@ let package = Package(
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
]),
.testTarget(name: "DefferedTaskKitTests",
dependencies: [
Expand Down
38 changes: 0 additions & 38 deletions Package@swift-5.6.swift

This file was deleted.

38 changes: 0 additions & 38 deletions Package@swift-5.7.swift

This file was deleted.

6 changes: 3 additions & 3 deletions Package@swift-5.8.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ let package = Package(
.library(name: "DefferedTaskKit", targets: ["DefferedTaskKit"])
],
dependencies: [
.package(url: "https://github.com/NikSativa/Threading.git", .upToNextMinor(from: "1.3.5")),
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "2.2.3"))
.package(url: "https://github.com/NikSativa/Threading.git", branch: "2.0.0"),
.package(url: "https://github.com/NikSativa/SpryKit.git", branch: "3.0.0")
],
targets: [
.target(name: "DefferedTaskKit",
Expand All @@ -25,7 +25,7 @@ let package = Package(
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
]),
.testTarget(name: "DefferedTaskKitTests",
dependencies: [
Expand Down
9 changes: 5 additions & 4 deletions Package@swift-5.5.swift → Package@swift-5.9.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.9
// swiftformat:disable all
import PackageDescription

Expand All @@ -8,15 +8,16 @@ let package = Package(
.iOS(.v13),
.macOS(.v11),
.macCatalyst(.v13),
.visionOS(.v1),
.tvOS(.v13),
.watchOS(.v6)
],
products: [
.library(name: "DefferedTaskKit", targets: ["DefferedTaskKit"])
],
dependencies: [
.package(url: "https://github.com/NikSativa/Threading.git", .upToNextMinor(from: "1.3.5")),
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "2.2.3"))
.package(url: "https://github.com/NikSativa/Threading.git", branch: "2.0.0"),
.package(url: "https://github.com/NikSativa/SpryKit.git", branch: "3.0.0")
],
targets: [
.target(name: "DefferedTaskKit",
Expand All @@ -25,7 +26,7 @@ let package = Package(
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
]),
.testTarget(name: "DefferedTaskKitTests",
dependencies: [
Expand Down
30 changes: 28 additions & 2 deletions Source/DefferedTask+Async.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
import Foundation

#if swift(>=6.0)
public extension DefferedTask {
func onComplete() async -> ResultType
where ResultType: Sendable {
return await withCheckedContinuation { actual in
onComplete {
actual.resume(returning: $0)
}
}
}

func onComplete<Response, Error: Swift.Error>() async throws -> Response
where ResultType == Result<Response, Error>, Response: Sendable {
return try await withCheckedThrowingContinuation { actual in
onComplete {
actual.resume(with: $0)
}
}
}
}
#else
public extension DefferedTask {
func onComplete() async -> ResultType {
return await withCheckedContinuation { actual in
onComplete(actual.resume(returning:))
onComplete {
actual.resume(returning: $0)
}
}
}

func onComplete<Response, Error: Swift.Error>() async throws -> Response
where ResultType == Result<Response, Error> {
return try await withCheckedThrowingContinuation { actual in
onComplete(actual.resume(with:))
onComplete {
actual.resume(with: $0)
}
}
}
}
#endif
Loading

0 comments on commit 084fe56

Please sign in to comment.