From 0c45a0945f623e86ddf6d6c5016a50a9b12a3b1e Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 4 May 2022 09:32:48 +0100 Subject: [PATCH 1/2] Raise minimum supported Swift version to 5.4 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 --- .github/workflows/ci.yaml | 26 ++-------- FuzzTesting/Package.swift | 7 ++- Package.swift | 67 +++++++++++++++++++------- Performance/QPSBenchmark/Package.swift | 13 ++++- README.md | 3 +- Tests/LinuxMain.swift | 16 ------ scripts/build_podspecs.py | 2 +- 7 files changed, 73 insertions(+), 61 deletions(-) delete mode 100644 Tests/LinuxMain.swift diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d828b35ee..e2c16205f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,17 +25,11 @@ jobs: matrix: include: - image: swift:5.6-focal - swift-test-flags: "--enable-test-discovery --sanitize=thread" + swift-test-flags: "--sanitize=thread" - image: swift:5.5-focal - swift-test-flags: "--enable-test-discovery --sanitize=thread" + swift-test-flags: "--sanitize=thread" - image: swift:5.4-focal - swift-test-flags: "--enable-test-discovery --sanitize=thread" - - image: swift:5.3-focal - swift-build-flags: "--enable-test-discovery" - swift-test-flags: "--enable-test-discovery" - - image: swift:5.2-bionic - swift-build-flags: "--enable-test-discovery" - swift-test-flags: "--enable-test-discovery" + swift-test-flags: "--sanitize=thread" name: Build and Test on ${{ matrix.image }} runs-on: ubuntu-latest container: @@ -85,16 +79,6 @@ jobs: MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 186000 MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 193000 MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 193000 - - image: swift:5.3-focal - env: - MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 460000 - MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 190000 - MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_10_small_requests: 110000 - MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_1_small_request: 65000 - MAX_ALLOCS_ALLOWED_embedded_server_unary_1k_rpcs_1_small_request: 61000 - MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 187000 - MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 194000 - MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 194000 name: Performance Tests on ${{ matrix.image }} runs-on: ubuntu-latest container: @@ -113,8 +97,6 @@ jobs: - image: swift:5.6-focal - image: swift:5.5-focal - image: swift:5.4-focal - - image: swift:5.3-focal - - image: swift:5.2-bionic name: Integration Tests on ${{ matrix.image }} runs-on: ubuntu-latest container: @@ -129,7 +111,7 @@ jobs: - name: Test without NIOSSL # Skip tests on 5.6: https://bugs.swift.org/browse/SR-15955 if: ${{ matrix.image != 'swift:5.6-focal' }} - run: swift test --enable-test-discovery + run: swift test env: GRPC_NO_NIO_SSL: 1 timeout-minutes: 20 diff --git a/FuzzTesting/Package.swift b/FuzzTesting/Package.swift index cadcef113..e00186986 100644 --- a/FuzzTesting/Package.swift +++ b/FuzzTesting/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.4 /* * Copyright 2021, gRPC Authors All rights reserved. * @@ -23,7 +23,7 @@ let package = Package( .package(url: "https://github.com/apple/swift-nio.git", from: "2.27.0"), ], targets: [ - .target( + .executableTarget( name: "ServerFuzzer", dependencies: [ .product(name: "GRPC", package: "grpc-swift"), @@ -35,6 +35,9 @@ let package = Package( name: "EchoModel", dependencies: [ .product(name: "GRPC", package: "grpc-swift"), + ], + exclude: [ + "echo.proto" ] ), .target( diff --git a/Package.swift b/Package.swift index 11410d96f..857009f76 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.2 +// swift-tools-version:5.4 /* * Copyright 2017, gRPC Authors All rights reserved. * @@ -149,11 +149,14 @@ extension Target { ] ) - static let protocGenGRPCSwift: Target = .target( + static let protocGenGRPCSwift: Target = .executableTarget( name: "protoc-gen-grpc-swift", dependencies: [ .protobuf, .protobufPluginLibrary, + ], + exclude: [ + "README.md" ] ) @@ -178,7 +181,10 @@ extension Target { .logging, ].appending( .nioSSL, if: includeNIOSSL - ) + ), + exclude: [ + "Codegen/Normalization/normalization.proto" + ] ) static let interopTestModels: Target = .target( @@ -187,6 +193,15 @@ extension Target { .grpc, .nio, .protobuf, + ], + exclude: [ + "README.md", + "generate.sh", + "src/proto/grpc/testing/empty.proto", + "src/proto/grpc/testing/empty_service.proto", + "src/proto/grpc/testing/messages.proto", + "src/proto/grpc/testing/test.proto", + "unimplemented_call.patch" ] ) @@ -204,7 +219,7 @@ extension Target { ) ) - static let interopTests: Target = .target( + static let interopTests: Target = .executableTarget( name: "GRPCInteroperabilityTests", dependencies: [ .grpc, @@ -216,7 +231,7 @@ extension Target { ] ) - static let backoffInteropTest: Target = .target( + static let backoffInteropTest: Target = .executableTarget( name: "GRPCConnectionBackoffInteropTest", dependencies: [ .grpc, @@ -225,10 +240,13 @@ extension Target { .nioPosix, .logging, .argumentParser, + ], + exclude: [ + "README.md" ] ) - static let perfTests: Target = .target( + static let perfTests: Target = .executableTarget( name: "GRPCPerformanceTests", dependencies: [ .grpc, @@ -243,7 +261,10 @@ extension Target { static let grpcSampleData: Target = .target( name: "GRPCSampleData", - dependencies: includeNIOSSL ? [.nioSSL] : [] + dependencies: includeNIOSSL ? [.nioSSL] : [], + exclude: [ + "bundle.p12" + ] ) static let echoModel: Target = .target( @@ -253,7 +274,10 @@ extension Target { .nio, .protobuf, ], - path: "Sources/Examples/Echo/Model" + path: "Sources/Examples/Echo/Model", + exclude: [ + "echo.proto" + ] ) static let echoImplementation: Target = .target( @@ -268,7 +292,7 @@ extension Target { path: "Sources/Examples/Echo/Implementation" ) - static let echo: Target = .target( + static let echo: Target = .executableTarget( name: "Echo", dependencies: [ .grpc, @@ -292,10 +316,13 @@ extension Target { .nio, .protobuf, ], - path: "Sources/Examples/HelloWorld/Model" + path: "Sources/Examples/HelloWorld/Model", + exclude: [ + "helloworld.proto" + ] ) - static let helloWorldClient: Target = .target( + static let helloWorldClient: Target = .executableTarget( name: "HelloWorldClient", dependencies: [ .grpc, @@ -307,7 +334,7 @@ extension Target { path: "Sources/Examples/HelloWorld/Client" ) - static let helloWorldServer: Target = .target( + static let helloWorldServer: Target = .executableTarget( name: "HelloWorldServer", dependencies: [ .grpc, @@ -326,10 +353,13 @@ extension Target { .nio, .protobuf, ], - path: "Sources/Examples/RouteGuide/Model" + path: "Sources/Examples/RouteGuide/Model", + exclude: [ + "route_guide.proto" + ] ) - static let routeGuideClient: Target = .target( + static let routeGuideClient: Target = .executableTarget( name: "RouteGuideClient", dependencies: [ .grpc, @@ -341,7 +371,7 @@ extension Target { path: "Sources/Examples/RouteGuide/Client" ) - static let routeGuideServer: Target = .target( + static let routeGuideServer: Target = .executableTarget( name: "RouteGuideServer", dependencies: [ .grpc, @@ -354,7 +384,7 @@ extension Target { path: "Sources/Examples/RouteGuide/Server" ) - static let packetCapture: Target = .target( + static let packetCapture: Target = .executableTarget( name: "PacketCapture", dependencies: [ .grpc, @@ -365,7 +395,10 @@ extension Target { .logging, .argumentParser, ], - path: "Sources/Examples/PacketCapture" + path: "Sources/Examples/PacketCapture", + exclude: [ + "README.md" + ] ) } diff --git a/Performance/QPSBenchmark/Package.swift b/Performance/QPSBenchmark/Package.swift index ca8625beb..cbdb3ce59 100644 --- a/Performance/QPSBenchmark/Package.swift +++ b/Performance/QPSBenchmark/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.2 +// swift-tools-version:5.4 /* * Copyright 2020, gRPC Authors All rights reserved. * @@ -38,7 +38,7 @@ let package = Package( ), ], targets: [ - .target( + .executableTarget( name: "QPSBenchmark", dependencies: [ .product(name: "GRPC", package: "grpc-swift"), @@ -50,6 +50,15 @@ let package = Package( .product(name: "Lifecycle", package: "swift-service-lifecycle"), .product(name: "SwiftProtobuf", package: "SwiftProtobuf"), .target(name: "BenchmarkUtils"), + ], + exclude: [ + "Model/benchmark_service.proto", + "Model/control.proto", + "Model/core_stats.proto", + "Model/messages.proto", + "Model/payloads.proto", + "Model/stats.proto", + "Model/worker_service.proto" ] ), .target( diff --git a/README.md b/README.md index e1149afa8..631ab6e54 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ servers are described in [`docs/plugin.md`][docs-plugin]. gRPC Swift's platform support is identical to the [platform support of Swift NIO][swift-nio-platforms]. -Note that gRPC Swift uses NIO 2 and requires Swift to be version 5.2 or higher. +The earliest supported Swift version for gRPC Swift 1.8.x and newer is 5.4. +For 1.7.x and earlier the oldest supported Swift version is 5.2. ## Getting gRPC Swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 99785309b..000000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2020, gRPC Authors All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -fatalError("Use --enable-test-discovery to run tests on Linux") diff --git a/scripts/build_podspecs.py b/scripts/build_podspecs.py index 34bb7f254..dac880b62 100755 --- a/scripts/build_podspecs.py +++ b/scripts/build_podspecs.py @@ -68,7 +68,7 @@ def as_podspec(self): podspec += indent + "s.homepage = 'https://www.grpc.io'\n" podspec += indent + "s.authors = { 'The gRPC contributors' => \'grpc-packages@google.com' }\n\n" - podspec += indent + "s.swift_version = '5.2'\n" + podspec += indent + "s.swift_version = '5.4'\n" podspec += indent + "s.ios.deployment_target = '10.0'\n" podspec += indent + "s.osx.deployment_target = '10.12'\n" podspec += indent + "s.tvos.deployment_target = '10.0'\n" From f74b2e5a13ffe2a3e5aaddd59ef60b43ae91b09f Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 4 May 2022 10:18:56 +0100 Subject: [PATCH 2/2] make the formatter happy --- FuzzTesting/Package.swift | 2 +- Package.swift | 18 +++++++++--------- Performance/QPSBenchmark/Package.swift | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/FuzzTesting/Package.swift b/FuzzTesting/Package.swift index e00186986..8daed6018 100644 --- a/FuzzTesting/Package.swift +++ b/FuzzTesting/Package.swift @@ -37,7 +37,7 @@ let package = Package( .product(name: "GRPC", package: "grpc-swift"), ], exclude: [ - "echo.proto" + "echo.proto", ] ), .target( diff --git a/Package.swift b/Package.swift index 857009f76..2f67947af 100644 --- a/Package.swift +++ b/Package.swift @@ -156,7 +156,7 @@ extension Target { .protobufPluginLibrary, ], exclude: [ - "README.md" + "README.md", ] ) @@ -183,7 +183,7 @@ extension Target { .nioSSL, if: includeNIOSSL ), exclude: [ - "Codegen/Normalization/normalization.proto" + "Codegen/Normalization/normalization.proto", ] ) @@ -201,7 +201,7 @@ extension Target { "src/proto/grpc/testing/empty_service.proto", "src/proto/grpc/testing/messages.proto", "src/proto/grpc/testing/test.proto", - "unimplemented_call.patch" + "unimplemented_call.patch", ] ) @@ -242,7 +242,7 @@ extension Target { .argumentParser, ], exclude: [ - "README.md" + "README.md", ] ) @@ -263,7 +263,7 @@ extension Target { name: "GRPCSampleData", dependencies: includeNIOSSL ? [.nioSSL] : [], exclude: [ - "bundle.p12" + "bundle.p12", ] ) @@ -276,7 +276,7 @@ extension Target { ], path: "Sources/Examples/Echo/Model", exclude: [ - "echo.proto" + "echo.proto", ] ) @@ -318,7 +318,7 @@ extension Target { ], path: "Sources/Examples/HelloWorld/Model", exclude: [ - "helloworld.proto" + "helloworld.proto", ] ) @@ -355,7 +355,7 @@ extension Target { ], path: "Sources/Examples/RouteGuide/Model", exclude: [ - "route_guide.proto" + "route_guide.proto", ] ) @@ -397,7 +397,7 @@ extension Target { ], path: "Sources/Examples/PacketCapture", exclude: [ - "README.md" + "README.md", ] ) } diff --git a/Performance/QPSBenchmark/Package.swift b/Performance/QPSBenchmark/Package.swift index cbdb3ce59..df37985fa 100644 --- a/Performance/QPSBenchmark/Package.swift +++ b/Performance/QPSBenchmark/Package.swift @@ -58,7 +58,7 @@ let package = Package( "Model/messages.proto", "Model/payloads.proto", "Model/stats.proto", - "Model/worker_service.proto" + "Model/worker_service.proto", ] ), .target(