-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement the Bazel build rules for gapic-generator-ruby (#486)
* Ruby rules implemented
- Loading branch information
1 parent
028bb43
commit e1b96e2
Showing
39 changed files
with
1,837 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ Gemfile.lock | |
/spec/reports/ | ||
/tmp/ | ||
Gemfile.lock | ||
/bazel-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
""" | ||
A workspace file for the gapic-generator-ruby | ||
""" | ||
workspace(name = "gapic_generator_ruby") | ||
|
||
## | ||
# Import gapic-generator-ruby specific dependencies | ||
# | ||
load("//rules_ruby_gapic:repositories.bzl", "gapic_generator_ruby_repositories") | ||
gapic_generator_ruby_repositories() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bazel-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
An example of the gapic-generator-ruby bazel rules usage. | ||
Contains separate examples for vanilla gapic-generator usage building a small example library | ||
and a gapic-generator-cloud usage building one of the cloud libraries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
""" | ||
A workspace file for the example usage of the gapic-generator-ruby | ||
""" | ||
workspace(name = "gapic_generator_ruby_example") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
## | ||
# googleapis for the common protos | ||
# | ||
http_archive( | ||
name = "com_google_googleapis", | ||
strip_prefix = "googleapis-cf41866c6f14f10a07aa1e2a1260fc0a2727d889", | ||
urls = ["https://github.com/googleapis/googleapis/archive/cf41866c6f14f10a07aa1e2a1260fc0a2727d889.zip"], | ||
sha256 = "943602b1e91621f282c1e790eb46d9a70e202fe65091b7d41415a43973cebec4" | ||
) | ||
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") | ||
switched_rules_by_language(name = "com_google_googleapis_imports", gapic = True) | ||
|
||
## | ||
# protobuf | ||
# | ||
http_archive( | ||
name = "com_google_protobuf", | ||
sha256 = "e5265d552e12c1f39c72842fa91d84941726026fa056d914ea6a25cd58d7bbf8", | ||
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.12.3.zip"], | ||
strip_prefix = "protobuf-3.12.3", | ||
) | ||
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") | ||
protobuf_deps() | ||
|
||
## | ||
# grpc | ||
# | ||
http_archive( | ||
name = "com_github_grpc_grpc", | ||
strip_prefix = "grpc-1.29.1", | ||
sha256 = "2afd3e20fd1d52d3d1a605a74befcdcb048a9213a4903880d9267856b063ae60", | ||
urls = ["https://github.com/grpc/grpc/archive/v1.29.1.zip"], | ||
) | ||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") | ||
grpc_deps() | ||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") | ||
grpc_extra_deps() | ||
|
||
## | ||
# rules_proto | ||
# | ||
http_archive( | ||
name = "rules_proto", | ||
sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208", | ||
strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz", | ||
"https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz", | ||
], | ||
) | ||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") | ||
rules_proto_dependencies() | ||
rules_proto_toolchains() | ||
|
||
## | ||
# gapic_generator_ruby | ||
# (either from github or local) | ||
# | ||
|
||
# use the following to get a consistent external version from github | ||
# http_archive( | ||
# name = "gapic_generator_ruby", | ||
# urls = ["https://github.com/googleapis/gapic-generator-ruby/archive/8333c9365ad9930097a1df76060f1a8492cce369.zip"], | ||
# strip_prefix = "gapic-generator-ruby-8333c9365ad9930097a1df76060f1a8492cce369", | ||
# ) | ||
|
||
# use the following to use the bazel rules defined locally, rather than fetched from github (great for development) | ||
local_repository( | ||
name = "gapic_generator_ruby", | ||
path = "../", | ||
) | ||
|
||
load("@gapic_generator_ruby//rules_ruby_gapic:repositories.bzl", "gapic_generator_ruby_repositories") | ||
gapic_generator_ruby_repositories() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
""" | ||
Defines the targets for the google cloud language library to be built | ||
with gapic-generator-ruby cloud flavor | ||
""" | ||
load("@gapic_generator_ruby//rules_ruby_gapic:ruby_gapic.bzl", | ||
"ruby_gapic_cloud_library", | ||
"ruby_proto_library", | ||
"ruby_grpc_library") | ||
|
||
load("@gapic_generator_ruby//rules_ruby_gapic:ruby_gapic_pkg.bzl", | ||
"ruby_gapic_assembly_pkg") | ||
|
||
## | ||
# completed google-cloud language library combined from | ||
# * protoc ruby output | ||
# * grpc-ruby protoc plugin output | ||
# * gapic-generator-ruby cloud flavor output | ||
# | ||
ruby_gapic_assembly_pkg( | ||
name = "google-cloud-language-v1-ruby", | ||
deps = [ | ||
":language_ruby_gapic", | ||
":language_ruby_grpc", | ||
":language_ruby_proto", | ||
], | ||
) | ||
|
||
## | ||
# just the gapic-generator-ruby cloud flavor output | ||
# | ||
ruby_gapic_cloud_library( | ||
name = "language_ruby_gapic", | ||
srcs = ["@com_google_googleapis//google/cloud/language/v1:language_proto_with_info"], | ||
ruby_cloud_params = { | ||
":gem.:name": "google-cloud-language-v1", | ||
":gem.:title": "Natural Language V1", | ||
":gem.:description": "Provides natural language understanding technologies, such as sentiment analysis, entity recognition, entity sentiment analysis, and other text annotations.", | ||
":gem.:env_prefix": "LANGUAGE", | ||
":gem.:product_documentation_url": "https://cloud.google.com/natural-language", | ||
":gem.:api_id": "language.googleapis.com", | ||
":gem.:api_shortname": "language", | ||
}, | ||
# we have to have a local copy here since @com_google_googleapis does not export individual grpc configs | ||
grpc_service_config = ":language_grpc_service_config.json" | ||
) | ||
|
||
## | ||
# just the protoc ruby output | ||
# | ||
ruby_proto_library( | ||
name = "language_ruby_proto", | ||
deps = ["@com_google_googleapis//google/cloud/language/v1:language_proto"], | ||
) | ||
|
||
## | ||
# just the grpc-ruby protoc plugin output | ||
# | ||
ruby_grpc_library( | ||
name = "language_ruby_grpc", | ||
srcs = ["@com_google_googleapis//google/cloud/language/v1:language_proto"], | ||
deps = [":language_ruby_proto"], | ||
) |
42 changes: 42 additions & 0 deletions
42
bazel_example/gapic-generator-cloud/language_grpc_service_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"methodConfig": [ | ||
{ | ||
"name": [ | ||
{ | ||
"service": "google.cloud.language.v1.LanguageService", | ||
"method": "AnalyzeSentiment" | ||
}, | ||
{ | ||
"service": "google.cloud.language.v1.LanguageService", | ||
"method": "AnalyzeEntities" | ||
}, | ||
{ | ||
"service": "google.cloud.language.v1.LanguageService", | ||
"method": "AnalyzeEntitySentiment" | ||
}, | ||
{ | ||
"service": "google.cloud.language.v1.LanguageService", | ||
"method": "AnalyzeSyntax" | ||
}, | ||
{ | ||
"service": "google.cloud.language.v1.LanguageService", | ||
"method": "ClassifyText" | ||
}, | ||
{ | ||
"service": "google.cloud.language.v1.LanguageService", | ||
"method": "AnnotateText" | ||
} | ||
], | ||
"timeout": "600s", | ||
"retryPolicy": { | ||
"initialBackoff": "0.100s", | ||
"maxBackoff": "60s", | ||
"backoffMultiplier": 1.3, | ||
"retryableStatusCodes": [ | ||
"DEADLINE_EXCEEDED", | ||
"UNAVAILABLE" | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
""" | ||
Defines the targets for the google cloud language library to be built | ||
with gapic-generator-ruby cloud flavor | ||
""" | ||
load("@gapic_generator_ruby//rules_ruby_gapic:ruby_gapic.bzl", | ||
"ruby_gapic_library", | ||
"ruby_proto_library", | ||
"ruby_grpc_library") | ||
|
||
load("@gapic_generator_ruby//rules_ruby_gapic:ruby_gapic_pkg.bzl", | ||
"ruby_gapic_assembly_pkg") | ||
|
||
## | ||
# the proto files wrapped with dependencies | ||
# | ||
proto_library( | ||
name = "example_proto", | ||
srcs = ["example.proto"], | ||
deps = ["@com_google_googleapis//google/api:client_proto"] | ||
) | ||
|
||
## | ||
# just the protoc ruby output | ||
# | ||
ruby_proto_library( | ||
name = "example_ruby_proto", | ||
deps = [":example_proto"], | ||
) | ||
|
||
## | ||
# just the grpc-ruby plugin output | ||
# | ||
ruby_grpc_library( | ||
name = "example_ruby_grpc", | ||
srcs = [":example_proto"], | ||
deps = [":example_ruby_proto"] | ||
) | ||
|
||
## | ||
# just the gapic-generator-ruby vanilla flavor output | ||
# | ||
ruby_gapic_library( | ||
name = "example_ruby_gapic", | ||
srcs = [":example_proto",], | ||
yml_configs = ["//gapic-generator:example.yml"] | ||
) | ||
|
||
## | ||
# completed example client library combined from | ||
# * protoc ruby output | ||
# * grpc-ruby protoc plugin output | ||
# * gapic-generator-ruby vanilla flavor output | ||
# | ||
ruby_gapic_assembly_pkg( | ||
name = "example_ruby_library", | ||
deps = [ | ||
":example_ruby_gapic", | ||
":example_ruby_proto", | ||
":example_ruby_grpc", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
// An example proto library | ||
syntax = "proto3"; | ||
|
||
package google.example; | ||
option ruby_package = "Google::Bazel::Example"; | ||
|
||
import "google/api/client.proto"; | ||
|
||
service TestService { | ||
option (google.api.default_host) = "google.bazel.example.com"; | ||
rpc TestCall(Request) returns(Response); | ||
} | ||
|
||
message Request { | ||
string name = 1; | ||
} | ||
|
||
message Response { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
:skip_credentials: true | ||
:gem: | ||
:name: google-bazel-example |
Oops, something went wrong.