Ver Fonte

Raise minimum supported Swift version to 5.4 (#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
George Barnett há 3 anos atrás
pai
commit
edcd6b944c

+ 4 - 22
.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

+ 5 - 2
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(

+ 50 - 17
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",
+    ]
   )
 }
 

+ 11 - 2
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(

+ 2 - 1
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
 

+ 0 - 16
Tests/LinuxMain.swift

@@ -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")

+ 1 - 1
scripts/build_podspecs.py

@@ -68,7 +68,7 @@ class Pod:
         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"