Browse Source

Update license check and generated code (#858)

Motivation:

SwiftProtobuf 1.9 has added an extra line to the headers of its
generated code, our license checker didn't like this.

The Makefile also does not specify Package.resolved as a depenendcy for
the SwiftProtobuf protoc plugin target so the plugin is not always
up-to-date.

Modifications:

- Update the license checker to allow for the extra line
- Allow the license checker to complete before exiting so that all
  invalid files are listed
- Update the protoc-gen-swift Makefile target to depenend on
  Package.resolved
- Regenerate code

Result:

Happier license checks.
George Barnett 5 years ago
parent
commit
4be0ed1959

+ 1 - 1
Makefile

@@ -28,7 +28,7 @@ all:
 plugins: ${PROTOC_GEN_SWIFT} ${PROTOC_GEN_GRPC_SWIFT}
 	cp $^ .
 
-${PROTOC_GEN_SWIFT}:
+${PROTOC_GEN_SWIFT}: Package.resolved
 	${SWIFT_BUILD_RELEASE} --product protoc-gen-swift
 
 ${PROTOC_GEN_GRPC_SWIFT}: Sources/protoc-gen-grpc-swift/*.swift

+ 1 - 0
Sources/Examples/Echo/Model/echo.pb.swift

@@ -1,4 +1,5 @@
 // DO NOT EDIT.
+// swift-format-ignore-file
 //
 // Generated by the Swift generator plugin for the protocol buffer compiler.
 // Source: echo.proto

+ 1 - 0
Sources/Examples/RouteGuide/Model/route_guide.pb.swift

@@ -1,4 +1,5 @@
 // DO NOT EDIT.
+// swift-format-ignore-file
 //
 // Generated by the Swift generator plugin for the protocol buffer compiler.
 // Source: route_guide.proto

+ 32 - 0
Sources/GRPCInteroperabilityTestModels/Generated/empty.grpc.swift

@@ -0,0 +1,32 @@
+//
+// DO NOT EDIT.
+//
+// Generated by the protocol buffer compiler.
+// Source: src/proto/grpc/testing/empty.proto
+//
+
+//
+// Copyright 2018, 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.
+//
+import Foundation
+import GRPC
+import NIO
+import NIOHTTP1
+import SwiftProtobuf
+
+
+
+// Provides conformance to `GRPCPayload`
+extension Grpc_Testing_Empty: GRPCProtobufPayload {}

+ 1 - 0
Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift

@@ -1,4 +1,5 @@
 // DO NOT EDIT.
+// swift-format-ignore-file
 //
 // Generated by the Swift generator plugin for the protocol buffer compiler.
 // Source: src/proto/grpc/testing/empty.proto

+ 43 - 0
Sources/GRPCInteroperabilityTestModels/Generated/messages.grpc.swift

@@ -0,0 +1,43 @@
+//
+// DO NOT EDIT.
+//
+// Generated by the protocol buffer compiler.
+// Source: src/proto/grpc/testing/messages.proto
+//
+
+//
+// Copyright 2018, 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.
+//
+import Foundation
+import GRPC
+import NIO
+import NIOHTTP1
+import SwiftProtobuf
+
+
+
+// Provides conformance to `GRPCPayload`
+extension Grpc_Testing_BoolValue: GRPCProtobufPayload {}
+extension Grpc_Testing_Payload: GRPCProtobufPayload {}
+extension Grpc_Testing_EchoStatus: GRPCProtobufPayload {}
+extension Grpc_Testing_SimpleRequest: GRPCProtobufPayload {}
+extension Grpc_Testing_SimpleResponse: GRPCProtobufPayload {}
+extension Grpc_Testing_StreamingInputCallRequest: GRPCProtobufPayload {}
+extension Grpc_Testing_StreamingInputCallResponse: GRPCProtobufPayload {}
+extension Grpc_Testing_ResponseParameters: GRPCProtobufPayload {}
+extension Grpc_Testing_StreamingOutputCallRequest: GRPCProtobufPayload {}
+extension Grpc_Testing_StreamingOutputCallResponse: GRPCProtobufPayload {}
+extension Grpc_Testing_ReconnectParams: GRPCProtobufPayload {}
+extension Grpc_Testing_ReconnectInfo: GRPCProtobufPayload {}

+ 1 - 0
Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift

@@ -1,4 +1,5 @@
 // DO NOT EDIT.
+// swift-format-ignore-file
 //
 // Generated by the Swift generator plugin for the protocol buffer compiler.
 // Source: src/proto/grpc/testing/messages.proto

+ 99 - 60
Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift

@@ -59,10 +59,15 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   ///   - request: Request to send to EmptyCall.
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
-  public func emptyCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
-    return self.makeUnaryCall(path: "/grpc.testing.TestService/EmptyCall",
-                              request: request,
-                              callOptions: callOptions ?? self.defaultCallOptions)
+  public func emptyCall(
+    _ request: Grpc_Testing_Empty,
+    callOptions: CallOptions? = nil
+  ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
+    return self.makeUnaryCall(
+      path: "/grpc.testing.TestService/EmptyCall",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
 
   /// One request followed by one response.
@@ -71,10 +76,15 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   ///   - request: Request to send to UnaryCall.
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
-  public func unaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
-    return self.makeUnaryCall(path: "/grpc.testing.TestService/UnaryCall",
-                              request: request,
-                              callOptions: callOptions ?? self.defaultCallOptions)
+  public func unaryCall(
+    _ request: Grpc_Testing_SimpleRequest,
+    callOptions: CallOptions? = nil
+  ) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
+    return self.makeUnaryCall(
+      path: "/grpc.testing.TestService/UnaryCall",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
 
   /// One request followed by one response. Response has cache control
@@ -85,10 +95,15 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   ///   - request: Request to send to CacheableUnaryCall.
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
-  public func cacheableUnaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
-    return self.makeUnaryCall(path: "/grpc.testing.TestService/CacheableUnaryCall",
-                              request: request,
-                              callOptions: callOptions ?? self.defaultCallOptions)
+  public func cacheableUnaryCall(
+    _ request: Grpc_Testing_SimpleRequest,
+    callOptions: CallOptions? = nil
+  ) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
+    return self.makeUnaryCall(
+      path: "/grpc.testing.TestService/CacheableUnaryCall",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
 
   /// One request followed by a sequence of responses (streamed download).
@@ -99,11 +114,17 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   ///   - handler: A closure called when each response is received from the server.
   /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
-  public func streamingOutputCall(_ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
-    return self.makeServerStreamingCall(path: "/grpc.testing.TestService/StreamingOutputCall",
-                                        request: request,
-                                        callOptions: callOptions ?? self.defaultCallOptions,
-                                        handler: handler)
+  public func streamingOutputCall(
+    _ request: Grpc_Testing_StreamingOutputCallRequest,
+    callOptions: CallOptions? = nil,
+    handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
+  ) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
+    return self.makeServerStreamingCall(
+      path: "/grpc.testing.TestService/StreamingOutputCall",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions,
+      handler: handler
+    )
   }
 
   /// A sequence of requests followed by one response (streamed upload).
@@ -115,9 +136,13 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   /// - Parameters:
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
-  public func streamingInputCall(callOptions: CallOptions? = nil) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse> {
-    return self.makeClientStreamingCall(path: "/grpc.testing.TestService/StreamingInputCall",
-                                        callOptions: callOptions ?? self.defaultCallOptions)
+  public func streamingInputCall(
+    callOptions: CallOptions? = nil
+  ) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse> {
+    return self.makeClientStreamingCall(
+      path: "/grpc.testing.TestService/StreamingInputCall",
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
 
   /// A sequence of requests with each request served by the server immediately.
@@ -131,10 +156,15 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   ///   - handler: A closure called when each response is received from the server.
   /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
-  public func fullDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
-    return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/FullDuplexCall",
-                                               callOptions: callOptions ?? self.defaultCallOptions,
-                                               handler: handler)
+  public func fullDuplexCall(
+    callOptions: CallOptions? = nil,
+    handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
+  ) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
+    return self.makeBidirectionalStreamingCall(
+      path: "/grpc.testing.TestService/FullDuplexCall",
+      callOptions: callOptions ?? self.defaultCallOptions,
+      handler: handler
+    )
   }
 
   /// A sequence of requests followed by a sequence of responses.
@@ -149,10 +179,15 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   ///   - handler: A closure called when each response is received from the server.
   /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
-  public func halfDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
-    return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/HalfDuplexCall",
-                                               callOptions: callOptions ?? self.defaultCallOptions,
-                                               handler: handler)
+  public func halfDuplexCall(
+    callOptions: CallOptions? = nil,
+    handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
+  ) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
+    return self.makeBidirectionalStreamingCall(
+      path: "/grpc.testing.TestService/HalfDuplexCall",
+      callOptions: callOptions ?? self.defaultCallOptions,
+      handler: handler
+    )
   }
 
   /// The test server will not implement this method. It will be used
@@ -162,12 +197,16 @@ public final class Grpc_Testing_TestServiceClient: GRPCClient, Grpc_Testing_Test
   ///   - request: Request to send to UnimplementedCall.
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
-  public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
-    return self.makeUnaryCall(path: "/grpc.testing.TestService/UnimplementedCall",
-                              request: request,
-                              callOptions: callOptions ?? self.defaultCallOptions)
+  public func unimplementedCall(
+    _ request: Grpc_Testing_Empty,
+    callOptions: CallOptions? = nil
+  ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
+    return self.makeUnaryCall(
+      path: "/grpc.testing.TestService/UnimplementedCall",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
-
 }
 
 /// Usage: instantiate Grpc_Testing_UnimplementedServiceClient, then call methods of this protocol to make API calls.
@@ -195,12 +234,16 @@ public final class Grpc_Testing_UnimplementedServiceClient: GRPCClient, Grpc_Tes
   ///   - request: Request to send to UnimplementedCall.
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
-  public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
-    return self.makeUnaryCall(path: "/grpc.testing.UnimplementedService/UnimplementedCall",
-                              request: request,
-                              callOptions: callOptions ?? self.defaultCallOptions)
+  public func unimplementedCall(
+    _ request: Grpc_Testing_Empty,
+    callOptions: CallOptions? = nil
+  ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
+    return self.makeUnaryCall(
+      path: "/grpc.testing.UnimplementedService/UnimplementedCall",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
-
 }
 
 /// Usage: instantiate Grpc_Testing_ReconnectServiceClient, then call methods of this protocol to make API calls.
@@ -229,10 +272,15 @@ public final class Grpc_Testing_ReconnectServiceClient: GRPCClient, Grpc_Testing
   ///   - request: Request to send to Start.
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
-  public func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty> {
-    return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Start",
-                              request: request,
-                              callOptions: callOptions ?? self.defaultCallOptions)
+  public func start(
+    _ request: Grpc_Testing_ReconnectParams,
+    callOptions: CallOptions? = nil
+  ) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty> {
+    return self.makeUnaryCall(
+      path: "/grpc.testing.ReconnectService/Start",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
 
   /// Unary call to Stop
@@ -241,12 +289,16 @@ public final class Grpc_Testing_ReconnectServiceClient: GRPCClient, Grpc_Testing
   ///   - request: Request to send to Stop.
   ///   - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
   /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
-  public func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo> {
-    return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Stop",
-                              request: request,
-                              callOptions: callOptions ?? self.defaultCallOptions)
+  public func stop(
+    _ request: Grpc_Testing_Empty,
+    callOptions: CallOptions? = nil
+  ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo> {
+    return self.makeUnaryCall(
+      path: "/grpc.testing.ReconnectService/Stop",
+      request: request,
+      callOptions: callOptions ?? self.defaultCallOptions
+    )
   }
-
 }
 
 /// To build a server, implement a class that conforms to this protocol.
@@ -389,16 +441,3 @@ extension Grpc_Testing_ReconnectServiceProvider {
 }
 
 
-// Provides conformance to `GRPCPayload` for request and response messages
-extension Grpc_Testing_Empty: GRPCProtobufPayload {}
-extension Grpc_Testing_SimpleRequest: GRPCProtobufPayload {}
-extension Grpc_Testing_SimpleResponse: GRPCProtobufPayload {}
-extension Grpc_Testing_StreamingOutputCallRequest: GRPCProtobufPayload {}
-extension Grpc_Testing_StreamingOutputCallResponse: GRPCProtobufPayload {}
-extension Grpc_Testing_StreamingInputCallRequest: GRPCProtobufPayload {}
-extension Grpc_Testing_StreamingInputCallResponse: GRPCProtobufPayload {}
-
-
-extension Grpc_Testing_ReconnectParams: GRPCProtobufPayload {}
-extension Grpc_Testing_ReconnectInfo: GRPCProtobufPayload {}
-

+ 1 - 0
Sources/GRPCInteroperabilityTestModels/Generated/test.pb.swift

@@ -1,4 +1,5 @@
 // DO NOT EDIT.
+// swift-format-ignore-file
 //
 // Generated by the Swift generator plugin for the protocol buffer compiler.
 // Source: src/proto/grpc/testing/test.proto

+ 4 - 2
scripts/license-check.sh

@@ -110,7 +110,7 @@ check_copyright_headers() {
       ;;
     *.pb.swift)
       expected_sha="$SWIFT_GRPC_PB"
-      drop_first=8
+      drop_first=9
       expected_lines=13
       ;;
     */Package.swift)
@@ -131,11 +131,13 @@ check_copyright_headers() {
     | shasum \
     | awk '{print $1}')
 
+  rc=0
   if [ "$actual_sha" != "$expected_sha" ]; then
     printf "\033[0;31mMissing or invalid copyright headers in '$filename'\033[0m\n"
-    exit 1
+    rc=1
   fi
   done
+  exit $rc
 }
 
 check_copyright_headers