-
Notifications
You must be signed in to change notification settings - Fork 14
Integration tests for the build plugin #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
4e477a6
3c5b627
e2d4cab
7105fb7
658670f
d8dc444
63dc0bf
b8e1d21
6c3f38a
78620b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"config":[{"name":"Plugin tests (6.0)","swift_version":"6.0","runner":"ubuntu-latest","image":"swift:6.0-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl protobuf-compiler","command":"curl -s https://raw.githubusercontent.com/rnro/grpc-swift-protobuf/refs/heads/build_plugin_integration_tests/dev/plugin-tests.sh| GITHUB_ACTIONS=true bash","command_arguments":""},{"name":"Plugin tests (nightly-6.1)","swift_version":"nightly-6.1","runner":"ubuntu-latest","image":"swiftlang/swift:nightly-6.1-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl protobuf-compiler","command":"curl -s https://raw.githubusercontent.com/rnro/grpc-swift-protobuf/refs/heads/build_plugin_integration_tests/dev/plugin-tests.sh| GITHUB_ACTIONS=true bash","command_arguments":""},{"name":"Plugin tests (nightly-main)","swift_version":"nightly-main","runner":"ubuntu-latest","image":"swiftlang/swift:nightly-main-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl protobuf-compiler","command":"curl -s https://raw.githubusercontent.com/rnro/grpc-swift-protobuf/refs/heads/build_plugin_integration_tests/dev/plugin-tests.sh| GITHUB_ACTIONS=true bash","command_arguments":""}]} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Leading trivia. | ||
syntax = "proto3"; | ||
|
||
package foo; | ||
|
||
message FooInput {} | ||
message FooOutput {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
|
||
import "Foo/foo-messages.proto"; | ||
|
||
package foo; | ||
|
||
service FooService1 { | ||
rpc Foo (FooInput) returns (FooOutput) {} | ||
} | ||
|
||
service FooService2 { | ||
rpc Foo (FooInput) returns (FooOutput) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright 2024, 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 GRPCCore | ||
import GRPCInProcessTransport | ||
import GRPCProtobuf | ||
|
||
@main | ||
struct PluginAdopter { | ||
static func main() async throws { | ||
let inProcess = InProcessTransport() | ||
try await withGRPCServer(transport: inProcess.server, services: [Greeter()]) { server in | ||
try await withGRPCClient(transport: inProcess.client) { client in | ||
try await Self.doRPC(Helloworld_Greeter.Client(wrapping: client)) | ||
} | ||
} | ||
|
||
try await withGRPCServer(transport: inProcess.server, services: [FooService1()]) { server in | ||
try await withGRPCClient(transport: inProcess.client) { client in | ||
try await Self.doRPC(Foo_FooService1.Client(wrapping: client)) | ||
} | ||
} | ||
} | ||
|
||
static func doRPC<Transport>(_ greeter: Helloworld_Greeter.Client<Transport>) async throws { | ||
do { | ||
let reply = try await greeter.sayHello(.with { $0.name = "(ignored)" }) | ||
print("Reply: \(reply.message)") | ||
} catch { | ||
print("Error: \(error)") | ||
} | ||
} | ||
|
||
static func doRPC<Transport>(_ fooService1: Foo_FooService1.Client<Transport>) async throws { | ||
do { | ||
let reply = try await fooService1.foo(.with { _ in () }) | ||
print("Reply: \(reply.hashValue)") | ||
} catch { | ||
print("Error: \(error)") | ||
} | ||
} | ||
} | ||
|
||
struct Greeter: Helloworld_Greeter.SimpleServiceProtocol { | ||
func sayHello( | ||
request: Helloworld_HelloRequest, | ||
context: ServerContext | ||
) async throws -> Helloworld_HelloReply { | ||
return .with { reply in | ||
reply.message = "Hello, world!" | ||
} | ||
} | ||
} | ||
|
||
struct FooService1: Foo_FooService1.SimpleServiceProtocol { | ||
func foo(request: Foo_FooInput, context: GRPCCore.ServerContext) async throws -> Foo_FooOutput { | ||
return .with { _ in | ||
() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2015, 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. | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.grpc.examples.helloworld"; | ||
option java_outer_classname = "HelloWorldProto"; | ||
option objc_class_prefix = "HLW"; | ||
|
||
package helloworld; | ||
|
||
// The greeting service definition. | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2015, 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. | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.grpc.examples.helloworld"; | ||
option java_outer_classname = "HelloWorldProto"; | ||
option objc_class_prefix = "HLW"; | ||
|
||
package helloworld; | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2015, 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. | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.grpc.examples.helloworld"; | ||
option java_outer_classname = "HelloWorldProto"; | ||
option objc_class_prefix = "HLW"; | ||
|
||
package helloworld; | ||
|
||
import "Messages.proto"; | ||
|
||
// The greeting service definition. | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2024, 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 GRPCCore | ||
import GRPCInProcessTransport | ||
import GRPCProtobuf | ||
|
||
@main | ||
struct PluginAdopter { | ||
static func main() async throws { | ||
let inProcess = InProcessTransport() | ||
try await withGRPCServer(transport: inProcess.server, services: [Greeter()]) { server in | ||
try await withGRPCClient(transport: inProcess.client) { client in | ||
try await Self.doRPC(Helloworld_Greeter.Client(wrapping: client)) | ||
} | ||
} | ||
} | ||
|
||
static func doRPC<Transport>(_ greeter: Helloworld_Greeter.Client<Transport>) async throws { | ||
do { | ||
let reply = try await greeter.sayHello(.with { $0.name = "(ignored)" }) | ||
print("Reply: \(reply.message)") | ||
} catch { | ||
print("Error: \(error)") | ||
} | ||
} | ||
} | ||
|
||
struct Greeter: Helloworld_Greeter.SimpleServiceProtocol { | ||
func sayHello( | ||
request: Helloworld_HelloRequest, | ||
context: ServerContext | ||
) async throws -> Helloworld_HelloReply { | ||
return .with { reply in | ||
reply.message = "Hello, world!" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// swift-tools-version: 6.0 | ||
/* | ||
* Copyright 2024, 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 PackageDescription | ||
|
||
var package = Package( | ||
|
||
name: "grpc-adopter", | ||
platforms: [ | ||
.macOS(.v15), | ||
.iOS(.v18), | ||
.tvOS(.v18), | ||
.watchOS(.v11), | ||
.visionOS(.v2), | ||
], | ||
dependencies: [ | ||
// Dependency on grpc-swift-protobuf to be added by setup-plugin-tests.sh script | ||
|
||
.package( | ||
url: "https://github.com/grpc/grpc-swift.git", | ||
branch: "main" | ||
) | ||
], | ||
targets: [ | ||
.executableTarget( | ||
name: "grpc-adopter", | ||
dependencies: [ | ||
.product(name: "GRPCCore", package: "grpc-swift"), | ||
.product(name: "GRPCInProcessTransport", package: "grpc-swift"), | ||
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), | ||
], | ||
plugins: [ | ||
.plugin(name: "GRPCProtobufGenerator", package: "grpc-swift-protobuf") | ||
] | ||
) | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"generatedSource": { | ||
"accessLevel": "internal" | ||
}, | ||
"protoc": { | ||
"importPaths": [ | ||
".", | ||
"../directory_1" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"generatedSource": { | ||
"accessLevel": "internal" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"generatedSource": { | ||
"accessLevel": "public" | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.