Skip to content

Commit d35535f

Browse files
glbrnttbimawa
authored andcommitted
Raise minimum supported Swift version to 5.4 (grpc#1397)
Motivation: SwiftNIO raised its minimum supported Swift version to 5.4 in the 2.40.0 release. To be able to use the latest updates, we must do the same. Modifications: - Bump swift-tools-version to 5.4 in the various package manifests (including QPS and FuzzTesting) - Add excludes for non-source files (READMEs and protos) - Use 'executableTarget' instead of 'target' for executables - Update the README to reflect supported versions - Remove 5.2 and 5.3 from CI - Remove LinuxMain.swift as test discovery is enabled by default Result: Minimum supported Swift version is 5.4
1 parent 1fc018f commit d35535f

File tree

7 files changed

+77
-65
lines changed

7 files changed

+77
-65
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,11 @@ jobs:
2525
matrix:
2626
include:
2727
- image: swift:5.6-focal
28-
swift-test-flags: "--enable-test-discovery --sanitize=thread"
28+
swift-test-flags: "--sanitize=thread"
2929
- image: swift:5.5-focal
30-
swift-test-flags: "--enable-test-discovery --sanitize=thread"
30+
swift-test-flags: "--sanitize=thread"
3131
- image: swift:5.4-focal
32-
swift-test-flags: "--enable-test-discovery --sanitize=thread"
33-
- image: swift:5.3-focal
34-
swift-build-flags: "--enable-test-discovery"
35-
swift-test-flags: "--enable-test-discovery"
36-
- image: swift:5.2-bionic
37-
swift-build-flags: "--enable-test-discovery"
38-
swift-test-flags: "--enable-test-discovery"
32+
swift-test-flags: "--sanitize=thread"
3933
name: Build and Test on ${{ matrix.image }}
4034
runs-on: ubuntu-latest
4135
container:
@@ -85,16 +79,6 @@ jobs:
8579
MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 186000
8680
MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 193000
8781
MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 193000
88-
- image: swift:5.3-focal
89-
env:
90-
MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 460000
91-
MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 190000
92-
MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_10_small_requests: 110000
93-
MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_1_small_request: 65000
94-
MAX_ALLOCS_ALLOWED_embedded_server_unary_1k_rpcs_1_small_request: 61000
95-
MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 187000
96-
MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 194000
97-
MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 194000
9882
name: Performance Tests on ${{ matrix.image }}
9983
runs-on: ubuntu-latest
10084
container:
@@ -113,8 +97,6 @@ jobs:
11397
- image: swift:5.6-focal
11498
- image: swift:5.5-focal
11599
- image: swift:5.4-focal
116-
- image: swift:5.3-focal
117-
- image: swift:5.2-bionic
118100
name: Integration Tests on ${{ matrix.image }}
119101
runs-on: ubuntu-latest
120102
container:
@@ -129,7 +111,7 @@ jobs:
129111
- name: Test without NIOSSL
130112
# Skip tests on 5.6: https://bugs.swift.org/browse/SR-15955
131113
if: ${{ matrix.image != 'swift:5.6-focal' }}
132-
run: swift test --enable-test-discovery
114+
run: swift test
133115
env:
134116
GRPC_NO_NIO_SSL: 1
135117
timeout-minutes: 20

FuzzTesting/Package.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.3
1+
// swift-tools-version:5.4
22
/*
33
* Copyright 2021, gRPC Authors All rights reserved.
44
*
@@ -23,24 +23,27 @@ let package = Package(
2323
.package(url: "https://github.com/apple/swift-nio.git", from: "2.27.0"),
2424
],
2525
targets: [
26-
.target(
26+
.executableTarget(
2727
name: "ServerFuzzer",
2828
dependencies: [
29-
.product(name: "SwiftGRPC", package: "grpc-swift"),
29+
.product(name: "GRPC", package: "grpc-swift"),
3030
.product(name: "NIO", package: "swift-nio"),
3131
.target(name: "EchoImplementation"),
3232
]
3333
),
3434
.target(
3535
name: "EchoModel",
3636
dependencies: [
37-
.product(name: "SwiftGRPC", package: "grpc-swift"),
37+
.product(name: "GRPC", package: "grpc-swift"),
38+
],
39+
exclude: [
40+
"echo.proto",
3841
]
3942
),
4043
.target(
4144
name: "EchoImplementation",
4245
dependencies: [
43-
.product(name: "SwiftGRPC", package: "grpc-swift"),
46+
.product(name: "GRPC", package: "grpc-swift"),
4447
.target(name: "EchoModel"),
4548
]
4649
),

Package.swift

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.4
22
/*
33
* Copyright 2017, gRPC Authors All rights reserved.
44
*
@@ -149,11 +149,14 @@ extension Target {
149149
]
150150
)
151151

152-
static let protocGenGRPCSwift: Target = .target(
152+
static let protocGenGRPCSwift: Target = .executableTarget(
153153
name: "protoc-gen-grpc-swift",
154154
dependencies: [
155155
.protobuf,
156156
.protobufPluginLibrary,
157+
],
158+
exclude: [
159+
"README.md",
157160
]
158161
)
159162

@@ -178,7 +181,10 @@ extension Target {
178181
.logging,
179182
].appending(
180183
.nioSSL, if: includeNIOSSL
181-
)
184+
),
185+
exclude: [
186+
"Codegen/Normalization/normalization.proto",
187+
]
182188
)
183189

184190
static let interopTestModels: Target = .target(
@@ -187,6 +193,15 @@ extension Target {
187193
.grpc,
188194
.nio,
189195
.protobuf,
196+
],
197+
exclude: [
198+
"README.md",
199+
"generate.sh",
200+
"src/proto/grpc/testing/empty.proto",
201+
"src/proto/grpc/testing/empty_service.proto",
202+
"src/proto/grpc/testing/messages.proto",
203+
"src/proto/grpc/testing/test.proto",
204+
"unimplemented_call.patch",
190205
]
191206
)
192207

@@ -204,7 +219,7 @@ extension Target {
204219
)
205220
)
206221

207-
static let interopTests: Target = .target(
222+
static let interopTests: Target = .executableTarget(
208223
name: "GRPCInteroperabilityTests",
209224
dependencies: [
210225
.grpc,
@@ -216,7 +231,7 @@ extension Target {
216231
]
217232
)
218233

219-
static let backoffInteropTest: Target = .target(
234+
static let backoffInteropTest: Target = .executableTarget(
220235
name: "GRPCConnectionBackoffInteropTest",
221236
dependencies: [
222237
.grpc,
@@ -225,10 +240,13 @@ extension Target {
225240
.nioPosix,
226241
.logging,
227242
.argumentParser,
243+
],
244+
exclude: [
245+
"README.md",
228246
]
229247
)
230248

231-
static let perfTests: Target = .target(
249+
static let perfTests: Target = .executableTarget(
232250
name: "GRPCPerformanceTests",
233251
dependencies: [
234252
.grpc,
@@ -243,7 +261,10 @@ extension Target {
243261

244262
static let grpcSampleData: Target = .target(
245263
name: "GRPCSampleData",
246-
dependencies: includeNIOSSL ? [.nioSSL] : []
264+
dependencies: includeNIOSSL ? [.nioSSL] : [],
265+
exclude: [
266+
"bundle.p12",
267+
]
247268
)
248269

249270
static let echoModel: Target = .target(
@@ -253,7 +274,10 @@ extension Target {
253274
.nio,
254275
.protobuf,
255276
],
256-
path: "Sources/Examples/Echo/Model"
277+
path: "Sources/Examples/Echo/Model",
278+
exclude: [
279+
"echo.proto",
280+
]
257281
)
258282

259283
static let echoImplementation: Target = .target(
@@ -268,7 +292,7 @@ extension Target {
268292
path: "Sources/Examples/Echo/Implementation"
269293
)
270294

271-
static let echo: Target = .target(
295+
static let echo: Target = .executableTarget(
272296
name: "Echo",
273297
dependencies: [
274298
.grpc,
@@ -292,10 +316,13 @@ extension Target {
292316
.nio,
293317
.protobuf,
294318
],
295-
path: "Sources/Examples/HelloWorld/Model"
319+
path: "Sources/Examples/HelloWorld/Model",
320+
exclude: [
321+
"helloworld.proto",
322+
]
296323
)
297324

298-
static let helloWorldClient: Target = .target(
325+
static let helloWorldClient: Target = .executableTarget(
299326
name: "HelloWorldClient",
300327
dependencies: [
301328
.grpc,
@@ -307,7 +334,7 @@ extension Target {
307334
path: "Sources/Examples/HelloWorld/Client"
308335
)
309336

310-
static let helloWorldServer: Target = .target(
337+
static let helloWorldServer: Target = .executableTarget(
311338
name: "HelloWorldServer",
312339
dependencies: [
313340
.grpc,
@@ -326,10 +353,13 @@ extension Target {
326353
.nio,
327354
.protobuf,
328355
],
329-
path: "Sources/Examples/RouteGuide/Model"
356+
path: "Sources/Examples/RouteGuide/Model",
357+
exclude: [
358+
"route_guide.proto",
359+
]
330360
)
331361

332-
static let routeGuideClient: Target = .target(
362+
static let routeGuideClient: Target = .executableTarget(
333363
name: "RouteGuideClient",
334364
dependencies: [
335365
.grpc,
@@ -341,7 +371,7 @@ extension Target {
341371
path: "Sources/Examples/RouteGuide/Client"
342372
)
343373

344-
static let routeGuideServer: Target = .target(
374+
static let routeGuideServer: Target = .executableTarget(
345375
name: "RouteGuideServer",
346376
dependencies: [
347377
.grpc,
@@ -354,7 +384,7 @@ extension Target {
354384
path: "Sources/Examples/RouteGuide/Server"
355385
)
356386

357-
static let packetCapture: Target = .target(
387+
static let packetCapture: Target = .executableTarget(
358388
name: "PacketCapture",
359389
dependencies: [
360390
.grpc,
@@ -365,7 +395,10 @@ extension Target {
365395
.logging,
366396
.argumentParser,
367397
],
368-
path: "Sources/Examples/PacketCapture"
398+
path: "Sources/Examples/PacketCapture",
399+
exclude: [
400+
"README.md",
401+
]
369402
)
370403
}
371404

Performance/QPSBenchmark/Package.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.4
22
/*
33
* Copyright 2020, gRPC Authors All rights reserved.
44
*
@@ -38,7 +38,7 @@ let package = Package(
3838
),
3939
],
4040
targets: [
41-
.target(
41+
.executableTarget(
4242
name: "QPSBenchmark",
4343
dependencies: [
4444
.product(name: "GRPC", package: "grpc-swift"),
@@ -50,6 +50,15 @@ let package = Package(
5050
.product(name: "Lifecycle", package: "swift-service-lifecycle"),
5151
.product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
5252
.target(name: "BenchmarkUtils"),
53+
],
54+
exclude: [
55+
"Model/benchmark_service.proto",
56+
"Model/control.proto",
57+
"Model/core_stats.proto",
58+
"Model/messages.proto",
59+
"Model/payloads.proto",
60+
"Model/stats.proto",
61+
"Model/worker_service.proto",
5362
]
5463
),
5564
.target(

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ servers are described in [`docs/plugin.md`][docs-plugin].
5252
gRPC Swift's platform support is identical to the [platform support of Swift
5353
NIO][swift-nio-platforms].
5454

55-
Note that gRPC Swift uses NIO 2 and requires Swift to be version 5.2 or higher.
55+
The earliest supported Swift version for gRPC Swift 1.8.x and newer is 5.4.
56+
For 1.7.x and earlier the oldest supported Swift version is 5.2.
5657

5758
## Getting gRPC Swift
5859

Tests/LinuxMain.swift

Lines changed: 0 additions & 16 deletions
This file was deleted.

scripts/build_podspecs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def as_podspec(self):
6868
podspec += indent + "s.homepage = 'https://www.grpc.io'\n"
6969
podspec += indent + "s.authors = { 'The gRPC contributors' => \'[email protected]' }\n\n"
7070

71-
podspec += indent + "s.swift_version = '5.2'\n"
72-
podspec += indent + "s.ios.deployment_target = '15.0'\n"
71+
podspec += indent + "s.swift_version = '5.4'\n"
72+
podspec += indent + "s.ios.deployment_target = '10.0'\n"
7373
podspec += indent + "s.osx.deployment_target = '10.12'\n"
7474
podspec += indent + "s.tvos.deployment_target = '10.0'\n"
7575
podspec += indent + "s.watchos.deployment_target = '6.0'\n"

0 commit comments

Comments
 (0)