aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Naresh <ghostwriternr@gmail.com>2018-10-09 17:04:11 +0000
committerGravatar Naresh <ghostwriternr@gmail.com>2018-10-09 17:04:11 +0000
commit873e0757cb841288d48514b0fe2e50b870171f61 (patch)
tree85a6d8df12b2fa3361717ce85d3b66d23f716680
parent912b8ab4d49cd6cde76675d37c896e5edcf67487 (diff)
Bazel rules for Python grpcio_health_checking
Add Bazel rules for building and testing grpcio_health_checking. An unofficial fork for rules_protobuf is used for now as it incorporates a change (#196 by duduko on the upstream repo pubref/rules_protobuf) which allows the protoc compiler to compile generated protos too. This was not merged because the change was failing for golang, but works as expected for Python. This is needed because grpcio_health_checking fetches it's proto file from a different directory (previously achived through setup.py) and thus needs to be moved to the required location within bazel-genfiles using a genrule.
-rw-r--r--WORKSPACE5
-rw-r--r--src/proto/grpc/health/v1/BUILD8
-rw-r--r--src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel33
-rw-r--r--src/python/grpcio_tests/tests/health_check/BUILD.bazel15
4 files changed, 59 insertions, 2 deletions
diff --git a/WORKSPACE b/WORKSPACE
index 9a0c41977f..a547c24cbe 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -34,10 +34,11 @@ pip_import(
load("@grpc_python_dependencies//:requirements.bzl", "pip_install")
pip_install()
+# NOTE(https://github.com/pubref/rules_protobuf/pull/196): Switch to upstream repo after this gets merged.
git_repository(
name="org_pubref_rules_protobuf",
- remote="https://github.com/pubref/rules_protobuf",
- tag="v0.8.2",
+ remote="https://github.com/ghostwriternr/rules_protobuf",
+ tag="v0.8.2.1-alpha",
)
load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_repositories")
diff --git a/src/proto/grpc/health/v1/BUILD b/src/proto/grpc/health/v1/BUILD
index d234842883..97642985c9 100644
--- a/src/proto/grpc/health/v1/BUILD
+++ b/src/proto/grpc/health/v1/BUILD
@@ -22,3 +22,11 @@ grpc_proto_library(
name = "health_proto",
srcs = ["health.proto"],
)
+
+filegroup(
+ name = "health_proto_file",
+ srcs = [
+ "health.proto",
+ ],
+)
+
diff --git a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel
new file mode 100644
index 0000000000..ce3121fa90
--- /dev/null
+++ b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel
@@ -0,0 +1,33 @@
+load("@grpc_python_dependencies//:requirements.bzl", "requirement")
+load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library")
+
+package(default_visibility = ["//visibility:public"])
+
+genrule(
+ name = "mv_health_proto",
+ srcs = [
+ "//src/proto/grpc/health/v1:health_proto_file",
+ ],
+ outs = ["health.proto",],
+ cmd = "cp $< $@",
+)
+
+py_proto_library(
+ name = "py_health_proto",
+ protos = [":mv_health_proto",],
+ with_grpc = True,
+ deps = [
+ requirement('protobuf'),
+ ],
+)
+
+py_library(
+ name = "grpc_health",
+ srcs = ["health.py",],
+ deps = [
+ ":py_health_proto",
+ "//src/python/grpcio/grpc:grpcio",
+ ],
+ imports=["../../",],
+)
+
diff --git a/src/python/grpcio_tests/tests/health_check/BUILD.bazel b/src/python/grpcio_tests/tests/health_check/BUILD.bazel
new file mode 100644
index 0000000000..19e1e1b2e1
--- /dev/null
+++ b/src/python/grpcio_tests/tests/health_check/BUILD.bazel
@@ -0,0 +1,15 @@
+package(default_visibility = ["//visibility:public"])
+
+py_test(
+ name = "health_servicer_test",
+ srcs = ["_health_servicer_test.py"],
+ main = "_health_servicer_test.py",
+ size = "small",
+ deps = [
+ "//src/python/grpcio/grpc:grpcio",
+ "//src/python/grpcio_health_checking/grpc_health/v1:grpc_health",
+ "//src/python/grpcio_tests/tests/unit:test_common",
+ ],
+ imports = ["../../",],
+)
+