Skip to content

Commit

Permalink
Add Swift 5.7 support to legacy release/0.x branch. (#1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstegeman authored Sep 20, 2022
1 parent 9fc4710 commit 3eca46b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 6 deletions.
20 changes: 17 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ var dependencies: [Package.Dependency] = [
// ~~~ SSWG APIs ~~~

.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
// swift-metrics 1.x and 2.x are almost API compatible, so most clients should use
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0" ..< "3.0.0"),
.package(url: "https://github.com/apple/swift-service-discovery.git", from: "1.0.0"),

// ~~~ only for GenActors ~~~
Expand All @@ -308,8 +306,24 @@ var dependencies: [Package.Dependency] = [
]

#if swift(>=5.7)
// swift-metrics 2.3.2 changed a test API. only pull it in for swift 5.7 to keep backwards compatibility.
dependencies.append(
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .revision("swift-DEVELOPMENT-SNAPSHOT-2022-03-13-a"))
.package(url: "https://github.com/apple/swift-metrics.git", .upToNextMajor(from: "2.3.2"))
)
#else
// swift-metrics 1.x and 2.x are almost API compatible, so most clients should use
dependencies.append(
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0" ..< "2.3.2")
)
#endif

#if swift(>=5.8)
dependencies.append(
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .revision("swift-DEVELOPMENT-SNAPSHOT-2022-09-12-a "))
)
#elseif swift(>=5.7)
dependencies.append(
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .exact("0.50700.0"))
)
#elseif swift(>=5.6)
dependencies.append(
Expand Down
18 changes: 15 additions & 3 deletions Tests/DistributedActorsTests/MetricsTestKit/MetricsTestKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ extension TestMetrics {
// MARK: Counter

public func expectCounter(_ metric: Counter) throws -> TestCounter {
metric.handler as! TestCounter
#if swift(>=5.7)
metric._handler as! TestCounter
#else
metric.handler as! TestCounter
#endif
}

public func expectCounter(_ label: String, _ dimensions: [(String, String)] = []) throws -> TestCounter {
Expand Down Expand Up @@ -159,7 +163,11 @@ extension TestMetrics {
// MARK: Recorder

public func expectRecorder(_ metric: Recorder) throws -> TestRecorder {
metric.handler as! TestRecorder
#if swift(>=5.7)
metric._handler as! TestRecorder
#else
metric.handler as! TestRecorder
#endif
}

public func expectRecorder(_ label: String, _ dimensions: [(String, String)] = []) throws -> TestRecorder {
Expand All @@ -177,7 +185,11 @@ extension TestMetrics {
// MARK: Timer

public func expectTimer(_ metric: Timer) throws -> TestTimer {
metric.handler as! TestTimer
#if swift(>=5.7)
metric._handler as! TestTimer
#else
metric.handler as! TestTimer
#endif
}

public func expectTimer(_ label: String, _ dimensions: [(String, String)] = []) throws -> TestTimer {
Expand Down
34 changes: 34 additions & 0 deletions docker/docker-compose.2004.57.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3"

services:

runtime-setup:
image: swift-distributed-actors:20.04-5.7
build:
args:
ubuntu_version: "focal"
swift_version: "5.7"

unit-tests:
image: swift-distributed-actors:20.04-5.7

unit-tests-until-failure:
image: swift-distributed-actors:20.04-5.7

integration-tests:
image: swift-distributed-actors:20.04-5.7

test:
image: swift-distributed-actors:20.04-5.7

bench:
image: swift-distributed-actors:20.04-5.7

shell:
image: swift-distributed-actors:20.04-5.7

sample-crash:
image: swift-distributed-actors:20.04-5.7

sample-crash-actor:
image: swift-distributed-actors:20.04-5.7

0 comments on commit 3eca46b

Please sign in to comment.