Skip to content

Commit 3eca46b

Browse files
authored
Add Swift 5.7 support to legacy release/0.x branch. (#1062)
1 parent 9fc4710 commit 3eca46b

File tree

3 files changed

+66
-6
lines changed

3 files changed

+66
-6
lines changed

Package.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ var dependencies: [Package.Dependency] = [
296296
// ~~~ SSWG APIs ~~~
297297

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

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

310308
#if swift(>=5.7)
309+
// swift-metrics 2.3.2 changed a test API. only pull it in for swift 5.7 to keep backwards compatibility.
311310
dependencies.append(
312-
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .revision("swift-DEVELOPMENT-SNAPSHOT-2022-03-13-a"))
311+
.package(url: "https://github.com/apple/swift-metrics.git", .upToNextMajor(from: "2.3.2"))
312+
)
313+
#else
314+
// swift-metrics 1.x and 2.x are almost API compatible, so most clients should use
315+
dependencies.append(
316+
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0" ..< "2.3.2")
317+
)
318+
#endif
319+
320+
#if swift(>=5.8)
321+
dependencies.append(
322+
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .revision("swift-DEVELOPMENT-SNAPSHOT-2022-09-12-a "))
323+
)
324+
#elseif swift(>=5.7)
325+
dependencies.append(
326+
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .exact("0.50700.0"))
313327
)
314328
#elseif swift(>=5.6)
315329
dependencies.append(

Tests/DistributedActorsTests/MetricsTestKit/MetricsTestKit.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ extension TestMetrics {
126126
// MARK: Counter
127127

128128
public func expectCounter(_ metric: Counter) throws -> TestCounter {
129-
metric.handler as! TestCounter
129+
#if swift(>=5.7)
130+
metric._handler as! TestCounter
131+
#else
132+
metric.handler as! TestCounter
133+
#endif
130134
}
131135

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

161165
public func expectRecorder(_ metric: Recorder) throws -> TestRecorder {
162-
metric.handler as! TestRecorder
166+
#if swift(>=5.7)
167+
metric._handler as! TestRecorder
168+
#else
169+
metric.handler as! TestRecorder
170+
#endif
163171
}
164172

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

179187
public func expectTimer(_ metric: Timer) throws -> TestTimer {
180-
metric.handler as! TestTimer
188+
#if swift(>=5.7)
189+
metric._handler as! TestTimer
190+
#else
191+
metric.handler as! TestTimer
192+
#endif
181193
}
182194

183195
public func expectTimer(_ label: String, _ dimensions: [(String, String)] = []) throws -> TestTimer {

docker/docker-compose.2004.57.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: "3"
2+
3+
services:
4+
5+
runtime-setup:
6+
image: swift-distributed-actors:20.04-5.7
7+
build:
8+
args:
9+
ubuntu_version: "focal"
10+
swift_version: "5.7"
11+
12+
unit-tests:
13+
image: swift-distributed-actors:20.04-5.7
14+
15+
unit-tests-until-failure:
16+
image: swift-distributed-actors:20.04-5.7
17+
18+
integration-tests:
19+
image: swift-distributed-actors:20.04-5.7
20+
21+
test:
22+
image: swift-distributed-actors:20.04-5.7
23+
24+
bench:
25+
image: swift-distributed-actors:20.04-5.7
26+
27+
shell:
28+
image: swift-distributed-actors:20.04-5.7
29+
30+
sample-crash:
31+
image: swift-distributed-actors:20.04-5.7
32+
33+
sample-crash-actor:
34+
image: swift-distributed-actors:20.04-5.7

0 commit comments

Comments
 (0)