Przeglądaj źródła

Raise minimum Swift version to 5.2 (#1106)

Motivation:

We recently raised the minimum Swift version to 5.1; the community are
okay with us raising this further. Raising the supported version lowers
our support burden and unlocks new language features.

Modifications:

- Use swift-tools-version:5.2, and update package description
- Update .swiftformat
- Update README
- Drop 5.1 CI

Result:

Resolves #1072
George Barnett 5 lat temu
rodzic
commit
7dc32169b2
6 zmienionych plików z 114 dodań i 112 usunięć
  1. 4 1
      .swiftformat
  2. 0 7
      .travis.yml
  3. 8 2
      Examples/PCAPExample/Package.swift
  4. 67 67
      Package.swift
  5. 31 18
      Performance/QPSBenchmark/Package.swift
  6. 4 17
      README.md

+ 4 - 1
.swiftformat

@@ -1,5 +1,5 @@
 # Language version.
 # Language version.
---swiftversion 5.1
+--swiftversion 5.2
 
 
 # Ignore generated files.
 # Ignore generated files.
 --exclude **/LinuxMain.swift,**/XCTestManifests.swift,**/*.grpc.swift,**/*.pb.swift
 --exclude **/LinuxMain.swift,**/XCTestManifests.swift,**/*.grpc.swift,**/*.pb.swift
@@ -31,3 +31,6 @@
 # We used to support 5.0 and return is redundant in more places in 5.1: enabling
 # We used to support 5.0 and return is redundant in more places in 5.1: enabling
 # this rule creates a large (and unnecessary) diff.
 # this rule creates a large (and unnecessary) diff.
 --disable redundantReturn
 --disable redundantReturn
+
+# Don't prefer using key paths for trivial closures.
+--disable preferKeyPath

+ 0 - 7
.travis.yml

@@ -40,10 +40,6 @@ jobs:
       name: "Unit Tests: Ubuntu 18.04 (Swift 5.2)"
       name: "Unit Tests: Ubuntu 18.04 (Swift 5.2)"
       script: ./.travis-script.sh
       script: ./.travis-script.sh
       env: SWIFT_VERSION=5.2.5
       env: SWIFT_VERSION=5.2.5
-    - <<: *tests
-      name: "Unit Tests: Ubuntu 18.04 (Swift 5.1)"
-      script: ./.travis-script.sh
-      env: SWIFT_VERSION=5.1.5
     - <<: *tests
     - <<: *tests
       name: "Unit Tests: Xcode 12.2"
       name: "Unit Tests: Xcode 12.2"
       os: osx
       os: osx
@@ -65,9 +61,6 @@ jobs:
     - <<: *interop_tests
     - <<: *interop_tests
       name: "Interoperability Tests: Ubuntu 18.04 (Swift 5.2)"
       name: "Interoperability Tests: Ubuntu 18.04 (Swift 5.2)"
       env: SWIFT_VERSION=5.2.5
       env: SWIFT_VERSION=5.2.5
-    - <<: *interop_tests
-      name: "Interoperability Tests: Ubuntu 18.04 (Swift 5.1)"
-      env: SWIFT_VERSION=5.1.5
     - <<: *interop_tests
     - <<: *interop_tests
       name: "Interoperability Tests: Xcode 12.2"
       name: "Interoperability Tests: Xcode 12.2"
       os: osx
       os: osx

+ 8 - 2
Examples/PCAPExample/Package.swift

@@ -1,4 +1,4 @@
-// swift-tools-version:5.1
+// swift-tools-version:5.2
 /*
 /*
  * Copyright 2020, gRPC Authors All rights reserved.
  * Copyright 2020, gRPC Authors All rights reserved.
  *
  *
@@ -23,6 +23,12 @@ let package = Package(
     .package(url: "https://github.com/apple/swift-nio-extras", from: "1.4.0"),
     .package(url: "https://github.com/apple/swift-nio-extras", from: "1.4.0"),
   ],
   ],
   targets: [
   targets: [
-    .target(name: "PCAPExample", dependencies: ["GRPC", "NIOExtras"]),
+    .target(
+      name: "PCAPExample",
+      dependencies: [
+        .product(name: "GRPC", package: "grpc-swift"),
+        .product(name: "NIOExtras", package: "swift-nio-extras"),
+      ]
+    ),
   ]
   ]
 )
 )

+ 67 - 67
Package.swift

@@ -1,4 +1,4 @@
-// swift-tools-version:5.1
+// swift-tools-version:5.2
 /*
 /*
  * Copyright 2017, gRPC Authors All rights reserved.
  * Copyright 2017, gRPC Authors All rights reserved.
  *
  *
@@ -37,7 +37,11 @@ let package = Package(
     .package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.4.0"),
     .package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.4.0"),
 
 
     // Official SwiftProtobuf library, for [de]serializing data to send on the wire.
     // Official SwiftProtobuf library, for [de]serializing data to send on the wire.
-    .package(url: "https://github.com/apple/swift-protobuf.git", from: "1.9.0"),
+    .package(
+      name: "SwiftProtobuf",
+      url: "https://github.com/apple/swift-protobuf.git",
+      from: "1.9.0"
+    ),
 
 
     // Logging API.
     // Logging API.
     .package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
     .package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
@@ -47,27 +51,27 @@ let package = Package(
     .target(
     .target(
       name: "GRPC",
       name: "GRPC",
       dependencies: [
       dependencies: [
-        "NIO",
-        "NIOFoundationCompat",
-        "NIOTransportServices",
-        "NIOHTTP1",
-        "NIOHTTP2",
-        "NIOExtras",
-        "NIOSSL",
-        "CGRPCZlib",
-        "SwiftProtobuf",
-        "Logging",
+        .product(name: "NIO", package: "swift-nio"),
+        .product(name: "NIOFoundationCompat", package: "swift-nio"),
+        .product(name: "NIOTransportServices", package: "swift-nio-transport-services"),
+        .product(name: "NIOHTTP1", package: "swift-nio"),
+        .product(name: "NIOHTTP2", package: "swift-nio-http2"),
+        .product(name: "NIOExtras", package: "swift-nio-extras"),
+        .product(name: "NIOSSL", package: "swift-nio-ssl"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
+        .product(name: "Logging", package: "swift-log"),
+        .target(name: "CGRPCZlib"),
       ]
       ]
     ), // and its tests.
     ), // and its tests.
     .testTarget(
     .testTarget(
       name: "GRPCTests",
       name: "GRPCTests",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "EchoModel",
-        "EchoImplementation",
-        "GRPCSampleData",
-        "GRPCInteroperabilityTestsImplementation",
-        "HelloWorldModel",
+        .target(name: "GRPC"),
+        .target(name: "EchoModel"),
+        .target(name: "EchoImplementation"),
+        .target(name: "GRPCSampleData"),
+        .target(name: "GRPCInteroperabilityTestsImplementation"),
+        .target(name: "HelloWorldModel"),
       ]
       ]
     ),
     ),
 
 
@@ -82,9 +86,8 @@ let package = Package(
     .target(
     .target(
       name: "protoc-gen-grpc-swift",
       name: "protoc-gen-grpc-swift",
       dependencies: [
       dependencies: [
-        "SwiftProtobuf",
-        "SwiftProtobufPluginLibrary",
-        "protoc-gen-swift",
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
+        .product(name: "SwiftProtobufPluginLibrary", package: "SwiftProtobuf"),
       ]
       ]
     ),
     ),
 
 
@@ -92,8 +95,8 @@ let package = Package(
     .target(
     .target(
       name: "GRPCInteroperabilityTestsImplementation",
       name: "GRPCInteroperabilityTestsImplementation",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "GRPCInteroperabilityTestModels",
+        .target(name: "GRPC"),
+        .target(name: "GRPCInteroperabilityTestModels"),
       ]
       ]
     ),
     ),
 
 
@@ -101,10 +104,10 @@ let package = Package(
     .target(
     .target(
       name: "GRPCInteroperabilityTestModels",
       name: "GRPCInteroperabilityTestModels",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "NIO",
-        "NIOHTTP1",
-        "SwiftProtobuf",
+        .target(name: "GRPC"),
+        .product(name: "NIO", package: "swift-nio"),
+        .product(name: "NIOHTTP1", package: "swift-nio"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
       ]
       ]
     ),
     ),
 
 
@@ -112,8 +115,7 @@ let package = Package(
     .target(
     .target(
       name: "GRPCInteroperabilityTests",
       name: "GRPCInteroperabilityTests",
       dependencies: [
       dependencies: [
-        "GRPCInteroperabilityTestsImplementation",
-        "Logging",
+        .target(name: "GRPCInteroperabilityTestsImplementation"),
       ]
       ]
     ),
     ),
 
 
@@ -121,9 +123,9 @@ let package = Package(
     .target(
     .target(
       name: "GRPCConnectionBackoffInteropTest",
       name: "GRPCConnectionBackoffInteropTest",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "GRPCInteroperabilityTestModels",
-        "Logging",
+        .target(name: "GRPC"),
+        .target(name: "GRPCInteroperabilityTestModels"),
+        .product(name: "Logging", package: "swift-log"),
       ]
       ]
     ),
     ),
 
 
@@ -131,28 +133,29 @@ let package = Package(
     .target(
     .target(
       name: "GRPCPerformanceTests",
       name: "GRPCPerformanceTests",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "EchoModel",
-        "NIO",
-        "NIOSSL",
+        .target(name: "GRPC"),
+        .target(name: "EchoModel"),
+        .product(name: "NIO", package: "swift-nio"),
       ]
       ]
     ),
     ),
 
 
     // Sample data, used in examples and tests.
     // Sample data, used in examples and tests.
     .target(
     .target(
       name: "GRPCSampleData",
       name: "GRPCSampleData",
-      dependencies: ["NIOSSL"]
+      dependencies: [
+        .product(name: "NIOSSL", package: "swift-nio-ssl"),
+      ]
     ),
     ),
 
 
     // Echo example CLI.
     // Echo example CLI.
     .target(
     .target(
       name: "Echo",
       name: "Echo",
       dependencies: [
       dependencies: [
-        "EchoModel",
-        "EchoImplementation",
-        "GRPC",
-        "GRPCSampleData",
-        "SwiftProtobuf",
+        .target(name: "EchoModel"),
+        .target(name: "EchoImplementation"),
+        .target(name: "GRPC"),
+        .target(name: "GRPCSampleData"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
       ],
       ],
       path: "Sources/Examples/Echo/Runtime"
       path: "Sources/Examples/Echo/Runtime"
     ),
     ),
@@ -161,9 +164,9 @@ let package = Package(
     .target(
     .target(
       name: "EchoImplementation",
       name: "EchoImplementation",
       dependencies: [
       dependencies: [
-        "EchoModel",
-        "GRPC",
-        "SwiftProtobuf",
+        .target(name: "EchoModel"),
+        .target(name: "GRPC"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
       ],
       ],
       path: "Sources/Examples/Echo/Implementation"
       path: "Sources/Examples/Echo/Implementation"
     ),
     ),
@@ -172,10 +175,9 @@ let package = Package(
     .target(
     .target(
       name: "EchoModel",
       name: "EchoModel",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "NIO",
-        "NIOHTTP1",
-        "SwiftProtobuf",
+        .target(name: "GRPC"),
+        .product(name: "NIO", package: "swift-nio"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
       ],
       ],
       path: "Sources/Examples/Echo/Model"
       path: "Sources/Examples/Echo/Model"
     ),
     ),
@@ -184,10 +186,9 @@ let package = Package(
     .target(
     .target(
       name: "HelloWorldModel",
       name: "HelloWorldModel",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "NIO",
-        "NIOHTTP1",
-        "SwiftProtobuf",
+        .target(name: "GRPC"),
+        .product(name: "NIO", package: "swift-nio"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
       ],
       ],
       path: "Sources/Examples/HelloWorld/Model"
       path: "Sources/Examples/HelloWorld/Model"
     ),
     ),
@@ -196,8 +197,8 @@ let package = Package(
     .target(
     .target(
       name: "HelloWorldClient",
       name: "HelloWorldClient",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "HelloWorldModel",
+        .target(name: "GRPC"),
+        .target(name: "HelloWorldModel"),
       ],
       ],
       path: "Sources/Examples/HelloWorld/Client"
       path: "Sources/Examples/HelloWorld/Client"
     ),
     ),
@@ -206,9 +207,9 @@ let package = Package(
     .target(
     .target(
       name: "HelloWorldServer",
       name: "HelloWorldServer",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "NIO",
-        "HelloWorldModel",
+        .target(name: "GRPC"),
+        .product(name: "NIO", package: "swift-nio"),
+        .target(name: "HelloWorldModel"),
       ],
       ],
       path: "Sources/Examples/HelloWorld/Server"
       path: "Sources/Examples/HelloWorld/Server"
     ),
     ),
@@ -217,10 +218,9 @@ let package = Package(
     .target(
     .target(
       name: "RouteGuideModel",
       name: "RouteGuideModel",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "NIO",
-        "NIOHTTP1",
-        "SwiftProtobuf",
+        .target(name: "GRPC"),
+        .product(name: "NIO", package: "swift-nio"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
       ],
       ],
       path: "Sources/Examples/RouteGuide/Model"
       path: "Sources/Examples/RouteGuide/Model"
     ),
     ),
@@ -229,8 +229,8 @@ let package = Package(
     .target(
     .target(
       name: "RouteGuideClient",
       name: "RouteGuideClient",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "RouteGuideModel",
+        .target(name: "GRPC"),
+        .target(name: "RouteGuideModel"),
       ],
       ],
       path: "Sources/Examples/RouteGuide/Client"
       path: "Sources/Examples/RouteGuide/Client"
     ),
     ),
@@ -239,9 +239,9 @@ let package = Package(
     .target(
     .target(
       name: "RouteGuideServer",
       name: "RouteGuideServer",
       dependencies: [
       dependencies: [
-        "GRPC",
-        "NIO",
-        "RouteGuideModel",
+        .target(name: "GRPC"),
+        .product(name: "NIO", package: "swift-nio"),
+        .target(name: "RouteGuideModel"),
       ],
       ],
       path: "Sources/Examples/RouteGuide/Server"
       path: "Sources/Examples/RouteGuide/Server"
     ),
     ),

+ 31 - 18
Performance/QPSBenchmark/Package.swift

@@ -1,4 +1,4 @@
-// swift-tools-version:5.1
+// swift-tools-version:5.2
 /*
 /*
  * Copyright 2020, gRPC Authors All rights reserved.
  * Copyright 2020, gRPC Authors All rights reserved.
  *
  *
@@ -32,24 +32,37 @@ let package = Package(
       url: "https://github.com/swift-server/swift-service-lifecycle.git",
       url: "https://github.com/swift-server/swift-service-lifecycle.git",
       from: "1.0.0-alpha"
       from: "1.0.0-alpha"
     ),
     ),
-    .package(url: "https://github.com/apple/swift-protobuf.git", from: "1.9.0"),
+    .package(
+      name: "SwiftProtobuf",
+      url: "https://github.com/apple/swift-protobuf.git",
+      from: "1.9.0"
+    ),
   ],
   ],
   targets: [
   targets: [
-    .target(name: "QPSBenchmark", dependencies: [
-      "GRPC",
-      "NIO",
-      "ArgumentParser",
-      "Logging",
-      "Lifecycle",
-      "SwiftProtobuf",
-      "BenchmarkUtils",
-    ]),
-    .target(name: "BenchmarkUtils", dependencies: [
-      "GRPC",
-    ]),
-    .testTarget(name: "BenchmarkUtilsTests", dependencies: [
-      "GRPC",
-      "BenchmarkUtils",
-    ]),
+    .target(
+      name: "QPSBenchmark",
+      dependencies: [
+        .product(name: "GRPC", package: "grpc-swift"),
+        .product(name: "NIO", package: "swift-nio"),
+        .product(name: "ArgumentParser", package: "swift-argument-parser"),
+        .product(name: "Logging", package: "swift-log"),
+        .product(name: "Lifecycle", package: "swift-service-lifecycle"),
+        .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
+        .target(name: "BenchmarkUtils"),
+      ]
+    ),
+    .target(
+      name: "BenchmarkUtils",
+      dependencies: [
+        .product(name: "GRPC", package: "grpc-swift"),
+      ]
+    ),
+    .testTarget(
+      name: "BenchmarkUtilsTests",
+      dependencies: [
+        .product(name: "GRPC", package: "grpc-swift"),
+        .target(name: "BenchmarkUtils"),
+      ]
+    ),
   ]
   ]
 )
 )

+ 4 - 17
README.md

@@ -34,7 +34,7 @@ The remainder of this README refers to the 1.x version of gRPC Swift.
 gRPC Swift's platform support is identical to the [platform support of Swift
 gRPC Swift's platform support is identical to the [platform support of Swift
 NIO][swift-nio-platforms].
 NIO][swift-nio-platforms].
 
 
-Note that gRPC Swift uses NIO 2 and requires Swift to be version 5.1 or higher.
+Note that gRPC Swift uses NIO 2 and requires Swift to be version 5.2 or higher.
 
 
 ## Getting gRPC Swift
 ## Getting gRPC Swift
 
 
@@ -45,8 +45,7 @@ There are two parts to gRPC Swift: the gRPC library and an API code generator.
 #### Swift Package Manager
 #### Swift Package Manager
 
 
 The Swift Package Manager is the preferred way to get gRPC Swift. Simply add the
 The Swift Package Manager is the preferred way to get gRPC Swift. Simply add the
-package dependency to your `Package.swift` and depend on `"GRPC"` in the
-necessary targets:
+package dependency to your `Package.swift`:
 
 
 ```swift
 ```swift
 dependencies: [
 dependencies: [
@@ -54,25 +53,13 @@ dependencies: [
 ]
 ]
 ```
 ```
 
 
-The syntax for target dependencies changed in Swift 5.2 and requires the package
-of each dependency to be specified.
-
-For Swift 5.2 (`swift-tools-version:5.2`) and later:
+...and depend on `"GRPC"` in the necessary targets:
 
 
 ```swift
 ```swift
 .target(
 .target(
   name: ...,
   name: ...,
   dependencies: [.product(name: "GRPC", package: "grpc-swift")]
   dependencies: [.product(name: "GRPC", package: "grpc-swift")]
-)
-```
-
-For Swift 5.1 (`swift-tools-version:5.1`):
-
-```swift
-.target(
-  name: ...,
-  dependencies: ["GRPC"]
-)
+]
 ```
 ```
 
 
 ##### Xcode
 ##### Xcode