Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #699 from fejta/ugh
Browse files Browse the repository at this point in the history
Support 5.2.0
  • Loading branch information
fejta authored Jun 10, 2022
2 parents 64268c4 + 3036d4f commit 8b96841
Show file tree
Hide file tree
Showing 26 changed files with 290 additions and 141 deletions.
18 changes: 18 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# In case you only have ipv6, you may need this:
# https://github.com/bazelbuild/bazel/issues/2486#issuecomment-657932374
#startup --host_jvm_args=-Djava.net.preferIPv6Addresses=true

build --workspace_status_command=./hack/print-workspace-status.sh
build --verbose_failures
build --define=TAG=staging

run --workspace_status_command=./hack/print-workspace-status.sh

# https://docs.bazel.build/versions/main/bazel-and-java.html#hermetic-testing-and-compilation
build --java_runtime_version=remotejdk_11
run --java_runtime_version=remotejdk_11
test --java_runtime_version=remotejdk_11

# https://github.com/bazelbuild/rules_jvm_external/issues/445
build --repo_env=JAVA_HOME=../bazel_tools/jdk

test --test_output=errors

# Taken from https://github.com/grpc/grpc/blob/66b045636018505dfa2654e62003d9596733076b/tools/bazel.rc
# Builds fail on MacOS otherwise
build --copt=-DGRPC_BAZEL_BUILD



# https://github.com/bazelbuild/rules_docker/issues/2016
# https://github.com/bazelbuild/rules_docker/issues/2078
# ERICK ERICK ERICK
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.0
5.2.0
199 changes: 145 additions & 54 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ load("//k8s:k8s.bzl", "k8s_defaults", "k8s_repositories")
# Tell Gazelle to use @io_bazel_rules_docker as the external repository for rules_docker go packages
# gazelle:repository go_repository name=io_bazel_rules_docker importpath=github.com/bazelbuild/rules_docker

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_python",
sha256 = "cdf6b84084aad8f10bf20b46b77cb48d83c319ebe6458a18e9d2cebf57807cdd",
strip_prefix = "rules_python-0.8.1",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.1.tar.gz",
)

#load("@rules_python//python:repositories.bzl", "python_register_toolchains")
#
#python_register_toolchains(
# name = "python3_9",
# python_version = "3.9",
#)
#
#load("@python3_9//:defs.bzl", "interpreter")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# ERICK
#load("@rules_python//python:pip.bzl", "pip_parse")
#
#pip_parse(
# python_interpreter_target = interpreter,
#)

k8s_repositories()

load("@io_bazel_rules_docker//repositories:repositories.bzl", _rules_docker_repos = "repositories")
Expand All @@ -30,6 +56,18 @@ load("//k8s:k8s_go_deps.bzl", k8s_go_deps = "deps")

k8s_go_deps()

http_archive(
name = "rules_cc",
sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.1/rules_cc-0.0.1.tar.gz"],
)

load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")

rules_cc_dependencies()

rules_cc_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "0cbdc9adda01f6d2facc65a22a2be5cecefbefe5a09e5382ee8879b522c04441",
Expand All @@ -46,26 +84,16 @@ protobuf_deps()
# can be removed once other dependencies are updated.
git_repository(
name = "subpar",
commit = "9fae6b63cfeace2e0fb93c9c1ebdc28d3991b16f",
remote = "https://github.com/google/subpar.git",
tag = "2.0.0",
)

http_archive(
name = "rules_python",
sha256 = "778197e26c5fbeb07ac2a2c5ae405b30f6cb7ad1f5510ea6fdac03bded96cc6f",
strip_prefix = "rules_python-0.2.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.2.0/rules_python-0.2.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

# Only needed if using the packaging rules.
load("@rules_python//python:pip.bzl", "pip_install")

pip_install(
name = "py_deps",
#python_interpreter_target = interpreter,
requirements = "//:requirements.txt",
)

Expand Down Expand Up @@ -168,32 +196,99 @@ k8s_defaults(
# rules_python is a transitive dep of build_stack_rules_proto, so place it
# first if we're going to explicitly mention it at all

# https://rules-proto-grpc.com/en/latest/#installation
http_archive(
name = "build_stack_rules_proto",
patch_args = ["-p1"],
patches = [
"//third_party/build_stack_rules_proto:stackb.patch",
],
sha256 = "2c62ecc133ee0400d969750a5591909a9b3839af402f9c9d148cffb0ce9b374b",
strip_prefix = "rules_proto-6b334ece48828fb8e45052976d3516f808819ac7",
urls = ["https://github.com/stackb/rules_proto/archive/6b334ece48828fb8e45052976d3516f808819ac7.tar.gz"],
name = "rules_proto_grpc",
sha256 = "507e38c8d95c7efa4f3b1c0595a8e8f139c885cb41a76cab7e20e4e67ae87731",
strip_prefix = "rules_proto_grpc-4.1.1",
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.1.1.tar.gz"],
)

load("@build_stack_rules_proto//:deps.bzl", "io_grpc_grpc_java")
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")

io_grpc_grpc_java()
rules_proto_grpc_toolchains()

load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
rules_proto_grpc_repos()

grpc_java_repositories()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

load("@rules_proto_grpc//go:repositories.bzl", rules_proto_grpc_go_repos = "go_repos")

rules_proto_grpc_go_repos()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "4.2"

RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"

http_archive(
name = "rules_jvm_external",
sha256 = RULES_JVM_EXTERNAL_SHA,
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@build_stack_rules_proto//java:deps.bzl", "java_grpc_library")
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

java_grpc_library()
rules_jvm_external_setup()

load("@build_stack_rules_proto//go:deps.bzl", "go_grpc_library")
load("@rules_jvm_external//:defs.bzl", "maven_install")

#maven_install(
# artifacts = [
# "junit:junit:4.12",
# "androidx.test.espresso:espresso-core:3.1.1",
# "org.hamcrest:hamcrest-library:1.3",
# ],
# repositories = [
# # Private repositories are supported through HTTP Basic auth
# "http://username:password@localhost:8081/artifactory/my-repository",
# "https://maven.google.com",
# "https://repo1.maven.org/maven2",
# ],
#)

load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos = "java_repos")

rules_proto_grpc_java_repos()

load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")

#artifacts = [
# "com.google.errorprone:error_prone_annotations:2.3.2",
#],
#repositories = [
# "https://jcenter.bintray.com",
# "https://repo1.maven.org/maven2",
#],
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
generate_compat_repositories = True,
override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS,
repositories = [
"https://repo.maven.apache.org/maven2/",
],
)

go_grpc_library()
load("@maven//:compat.bzl", "compat_repositories")

compat_repositories()

grpc_java_repositories()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

gazelle_dependencies()

# We use java_image to build a sample service
load(
Expand All @@ -211,23 +306,39 @@ load(

_go_image_repos()

git_repository(
http_archive(
name = "io_bazel_rules_jsonnet",
commit = "12979862ab51358a8a5753f5a4aa0658fec9d4af",
remote = "https://github.com/bazelbuild/rules_jsonnet.git",
shallow_since = "1574670556 +0100",
sha256 = "d20270872ba8d4c108edecc9581e2bb7f320afab71f8caa2f6394b5202e8a2c3",
strip_prefix = "rules_jsonnet-0.4.0",
urls = ["https://github.com/bazelbuild/rules_jsonnet/archive/0.4.0.tar.gz"],
)

load("@io_bazel_rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_repositories")

jsonnet_repositories()

load("@google_jsonnet_go//bazel:repositories.bzl", "jsonnet_go_repositories")

jsonnet_go_repositories()

load("@google_jsonnet_go//bazel:deps.bzl", "jsonnet_go_dependencies")

jsonnet_go_dependencies()

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "9d93d4e1340c43dbf6b2fd66b683d89630a6310bf8be3bf40ec96685dcacc26c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.3.3/rules_nodejs-2.3.3.tar.gz"],
sha256 = "0fad45a9bda7dc1990c47b002fd64f55041ea751fafc00cd34efb96107675778",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.0/rules_nodejs-5.5.0.tar.gz"],
)

load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")

build_bazel_rules_nodejs_dependencies()

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")

node_repositories()

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")

# We use nodejs_image to build a sample service
Expand All @@ -245,26 +356,6 @@ yarn_install(
yarn_lock = "//examples:yarn.lock",
)

http_archive(
name = "rules_jvm_external",
sha256 = "e5b97a31a3e8feed91636f42e19b11c49487b85e5de2f387c999ea14d77c7f45",
strip_prefix = "rules_jvm_external-2.9",
url = "https://github.com/bazelbuild/rules_jvm_external/archive/2.9.zip",
)

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
name = "maven",
artifacts = [
"com.google.errorprone:error_prone_annotations:2.3.2",
],
repositories = [
"https://jcenter.bintray.com",
"https://repo1.maven.org/maven2",
],
)

# error_prone_annotations required by protobuf 3.7.1
bind(
name = "error_prone_annotations",
Expand Down
3 changes: 2 additions & 1 deletion examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ jsonnet_library(
srcs = ["container.libsonnet"],
)

par_binary(
py_binary(
name = "e2e_gc",
srcs = ["e2e_gc.py"],
main = "e2e_gc.py",
python_version = "PY3",
srcs_version = "PY3",
)
2 changes: 1 addition & 1 deletion examples/hellogrpc/deployment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DeploymentTest(unittest.TestCase):

def test_things_match(self):
with open(TestData('examples/hellogrpc/deployment.yaml'), 'r') as f:
static = yaml.load(f.read())
static = yaml.safe_load(f.read())
with open(TestData('examples/hellogrpc/deployment.json'), 'r') as f:
generated = json.loads(f.read())

Expand Down
2 changes: 1 addition & 1 deletion examples/hellogrpc/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -o pipefail
source ./examples/util.sh

validate_args "$@"
shift 2
shift 1

fail() {
echo "FAILURE: $@"
Expand Down
4 changes: 3 additions & 1 deletion examples/hellogrpc/go/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func main() {
}
}

type server struct{}
type server struct {
pb.UnimplementedSimpleServer
}

func (s *server) Foo(ctx context.Context, req *pb.FooRequest) (*pb.FooReply, error) {
return &pb.FooReply{
Expand Down
2 changes: 1 addition & 1 deletion examples/hellogrpc/java/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ java_binary(
main_class = "io.bazel.rules_k8s.examples.helloworld.java.client.HelloClient",
deps = [
"//examples/hellogrpc/proto:simple_java_grpc",
"@build_stack_rules_proto//java:grpc_netty",
#"@build_stack_rules_proto//java:grpc_netty",
],
)
2 changes: 1 addition & 1 deletion examples/hellogrpc/java/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ java_image(
main_class = "io.bazel.rules_k8s.examples.helloworld.java.server.HelloServer",
deps = [
"//examples/hellogrpc/proto:simple_java_grpc",
"@build_stack_rules_proto//java:grpc_netty",
#"@build_stack_rules_proto//java:grpc_netty",
],
)

Expand Down
15 changes: 5 additions & 10 deletions examples/hellogrpc/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@build_stack_rules_proto//go:go_grpc_library.bzl", "go_grpc_library")
load("@build_stack_rules_proto//java:java_grpc_library.bzl", "java_grpc_library")
load("@rules_proto_grpc//go:go_grpc_library.bzl", "go_grpc_library")
load("@rules_proto_grpc//java:defs.bzl", "java_grpc_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
name = "simple_proto",
Expand All @@ -25,18 +26,12 @@ proto_library(
java_grpc_library(
name = "simple_java_grpc",
visibility = ["//examples/hellogrpc/java:__subpackages__"],
deps = [":simple_proto"],
protos = [":simple_proto"],
)

go_grpc_library(
name = "simple_go_grpc",
go_deps = [
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library",
"@org_golang_google_protobuf//runtime/protoimpl:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
],
importpath = "github.com/bazelbuild/rules_k8s/examples/hellogrpc/proto/go",
visibility = ["//examples/hellogrpc/go:__subpackages__"],
deps = [":simple_proto"],
protos = [":simple_proto"],
)
Loading

0 comments on commit 8b96841

Please sign in to comment.