Skip to content

Commit

Permalink
Add proto_build_test rule that tests building the protos defined in t…
Browse files Browse the repository at this point in the history
…he workspace. (#460)
  • Loading branch information
Ankur19 authored Oct 19, 2023
1 parent aac3859 commit 7e267bb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-build-proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
sudo mv $BAZEL /usr/local/bin/bazel
- name: Build proto/
run: cd proto && bazel build //...
run: cd proto && bazel build //... && bazel test //...

- name: Build bazel/example/
run: cd bazel/example/ && bazel build //...
33 changes: 28 additions & 5 deletions proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
package(
default_visibility = ["//visibility:public"],
licenses = ["notice"], # Apache 2.0
)

load("@rules_proto//proto:defs.bzl", "proto_library")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_license//rules:license.bzl", "license")
load("@rules_proto//proto:defs.bzl", "proto_library")

package(
default_visibility = ["//visibility:public"],
default_applicable_licenses = [":license"],
)

license(
name = "license",
license_kinds = ["@rules_license//licenses/generic:notice"],
license_text = "LICENSE",
)

exports_files(["LICENSE"])

proto_library(
name = "p4types_proto",
Expand Down Expand Up @@ -126,3 +137,15 @@ py_grpc_library(
srcs = [":p4runtime_proto"],
deps = [":p4runtime_py_proto"],
)

build_test(
name = "proto_build_test",
targets = [
":p4data_proto",
":p4info_proto",
":p4runtime_cc_grpc",
":p4runtime_proto",
":p4runtime_py_grpc",
":p4types_proto",
],
)
1 change: 1 addition & 0 deletions proto/LICENSE
3 changes: 3 additions & 0 deletions proto/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ pip_parse(

load("@grpc_python_dependencies//:requirements.bzl", "install_deps")
install_deps()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
18 changes: 18 additions & 0 deletions proto/p4runtime_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,21 @@ def p4runtime_deps():
strip_prefix = "grpc-1.51.1",
sha256 = "b55696fb249669744de3e71acc54a9382bea0dce7cd5ba379b356b12b82d4229",
)
if not native.existing_rule("bazel_skylib"):
http_archive(
name = "bazel_skylib",
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
],
)
if not native.existing_rule("rules_license"):
http_archive(
name = "rules_license",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
"https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
],
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
)

0 comments on commit 7e267bb

Please sign in to comment.