From 92e008d428b4c4e13286962728d7aa4a46b4f5be Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 11:43:19 -0500 Subject: [PATCH 01/73] chore: Maven PoC (phase 1) --- BUILD.bazel | 40 +-- ad-hoc-compile-proto-files.sh | 70 ++++++ pom.xml | 228 ++++++++++++++++++ .../java/com/google/api/generator/BUILD.bazel | 39 --- .../google/api/generator/debug/BUILD.bazel | 18 -- .../google/api/generator/engine/BUILD.bazel | 11 - .../api/generator/engine/ast/BUILD.bazel | 18 -- .../api/generator/engine/escaper/BUILD.bazel | 11 - .../api/generator/engine/lexicon/BUILD.bazel | 11 - .../api/generator/engine/writer/BUILD.bazel | 13 - .../google/api/generator/gapic/BUILD.bazel | 26 -- .../api/generator/gapic/composer/BUILD.bazel | 45 ---- .../gapic/composer/comment/BUILD.bazel | 15 -- .../gapic/composer/common/BUILD.bazel | 46 ---- .../gapic/composer/defaultvalue/BUILD.bazel | 19 -- .../generator/gapic/composer/grpc/BUILD.bazel | 44 ---- .../gapic/composer/grpcrest/BUILD.bazel | 48 ---- .../gapic/composer/resourcename/BUILD.bazel | 18 -- .../generator/gapic/composer/rest/BUILD.bazel | 45 ---- .../gapic/composer/samplecode/BUILD.bazel | 19 -- .../gapic/composer/store/BUILD.bazel | 31 --- .../gapic/composer/utils/BUILD.bazel | 12 - .../api/generator/gapic/model/BUILD.bazel | 23 -- .../generator/gapic/protoparser/BUILD.bazel | 34 --- .../generator/gapic/protowriter/BUILD.bazel | 16 -- .../api/generator/gapic/utils/BUILD.bazel | 13 - .../com/google/api/generator/util/BUILD.bazel | 8 - .../google/api/generator/engine/BUILD.bazel | 33 --- .../api/generator/engine/ast/BUILD.bazel | 58 ----- .../api/generator/engine/lexicon/BUILD.bazel | 19 -- .../api/generator/engine/writer/BUILD.bazel | 21 -- .../api/generator/gapic/composer/BUILD.bazel | 78 +----- .../gapic/composer/common/BUILD.bazel | 95 -------- .../gapic/composer/defaultvalue/BUILD.bazel | 38 --- .../generator/gapic/composer/grpc/BUILD.bazel | 87 ------- .../gapic/composer/resourcename/BUILD.bazel | 68 ------ .../generator/gapic/composer/rest/BUILD.bazel | 84 ------- .../gapic/composer/samplecode/BUILD.bazel | 29 --- .../gapic/composer/utils/BUILD.bazel | 23 -- .../api/generator/gapic/model/BUILD.bazel | 31 --- .../generator/gapic/protoparser/BUILD.bazel | 51 ---- .../api/generator/gapic/testdata/BUILD.bazel | 17 -- .../api/generator/gapic/utils/BUILD.bazel | 17 -- .../api/generator/test/framework/BUILD.bazel | 30 --- .../api/generator/testutils/BUILD.bazel | 8 - .../com/google/api/generator/util/BUILD.bazel | 20 -- 46 files changed, 310 insertions(+), 1418 deletions(-) create mode 100755 ad-hoc-compile-proto-files.sh create mode 100644 pom.xml delete mode 100644 src/main/java/com/google/api/generator/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/debug/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/engine/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/engine/ast/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/engine/escaper/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/engine/lexicon/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/engine/writer/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/comment/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/common/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/grpcrest/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/store/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/model/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/protoparser/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/protowriter/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/gapic/utils/BUILD.bazel delete mode 100644 src/main/java/com/google/api/generator/util/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/engine/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/engine/ast/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/engine/lexicon/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/engine/writer/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/common/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/model/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/protoparser/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/utils/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/test/framework/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/testutils/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/util/BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel index 0d58feb8c5..a871b19e96 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -6,25 +6,21 @@ package(default_visibility = ["//visibility:public"]) java_proto_library( name = "service_config_java_proto", - visibility = ["//:__subpackages__"], - deps = [ - "@io_grpc_proto//:service_config_proto", - ], + deps = ["@io_grpc_proto//:service_config_proto"], ) # ============= Binary targets ================ +java_import( + name = "gapic_generator_java", + # You can also pull from remote filesystem, GCS bucket, Maven repositories, etc. + jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], +) + java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", - runtime_deps = [ - "//src/main/java/com/google/api/generator", - "//src/main/java/com/google/api/generator/gapic", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - ], + runtime_deps = ["gapic_generator_java"], ) # Request dumper binary, which dumps the CodeGeneratorRequest to a file on disk @@ -46,15 +42,7 @@ java_binary( java_binary( name = "protoc-gen-code_generator_request_dumper", main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper", - runtime_deps = [ - "//src/main/java/com/google/api/generator", - "//src/main/java/com/google/api/generator/debug", - "//src/main/java/com/google/api/generator/gapic", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - ], + runtime_deps = ["gapic_generator_java"], ) # A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest @@ -67,15 +55,7 @@ java_binary( java_binary( name = "code_generator_request_file_to_gapic_main", main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", - runtime_deps = [ - "//src/main/java/com/google/api/generator", - "//src/main/java/com/google/api/generator/debug", - "//src/main/java/com/google/api/generator/gapic", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - ], + runtime_deps = ["gapic_generator_java"], ) # google-java-format diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh new file mode 100755 index 0000000000..ee6ba2c03d --- /dev/null +++ b/ad-hoc-compile-proto-files.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +set -o errexit + +# Some auto-generated Java proto library code for .proto files are not published anywhere, +# so currently, we need to build them using `java_proto_library()` to generate .jar files. +# +# Many of these are needed due to our usage in tests. +# +# 1. from grpc/grpc-proto: service_config.proto +# +# 2. from googleapis/googleapis: +# - gapic_metadata.proto +# - common_resources.proto +# - pubsub.proto (v2) +# - logging.proto (v1) +# +# 2. local testdata .protos in src/test/java/com/google/api/generator/gapic/testdata: +# - deprecated_service: deprecated_service.proto +# - bookshop: bookshop.proto +# - showcase: compliance.proto, echo.proto, identity.proto, testing.proto and messaging.proto +# - testgapic: bad_message_resname_def.proto, locker.proto, and nested_message.proto +# - explicit_dynamic_routing_headers_testing: +# - routing_rule_parser_testing.proto +# - explicit_dynamic_routing_header_testing.proto + +bazel build service_config_java_proto +bazel build @com_google_googleapis//gapic/metadata:metadata_java_proto +bazel build src/test/java/com/google/api/generator/gapic/composer:common_resources_java_proto +bazel build @com_google_googleapis//google/pubsub/v1:pubsub_java_proto +bazel build @com_google_googleapis//google/logging/v2:logging_java_proto + +bazel build src/test/java/com/google/api/generator/gapic/testdata:deprecated_service_java_proto +bazel build src/test/java/com/google/api/generator/gapic/testdata:bookshop_java_proto +bazel build src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto +bazel build src/test/java/com/google/api/generator/gapic/testdata:testgapic_java_proto +bazel build src/test/java/com/google/api/generator/gapic/testdata:explicit_dynamic_routing_headers_testing_java_proto + + +mvn install:install-file -Dfile=bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar \ + -DgroupId=io.grpc -DartifactId=serviceconfig-proto -Dversion=0.0.0 -Dpackaging=jar + + +mvn install:install-file -Dfile=bazel-bin/external/com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar \ + -DgroupId=com.google.api -DartifactId=metadata-proto -Dversion=0.0.0 -Dpackaging=jar + +mvn install:install-file -Dfile=bazel-bin/external/com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar \ + -DgroupId=com.google.api -DartifactId=common-resources-proto -Dversion=0.0.0 -Dpackaging=jar + +mvn install:install-file -Dfile=bazel-bin/external/com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar \ + -DgroupId=com.google.api -DartifactId=pubsub-proto -Dversion=0.0.0 -Dpackaging=jar + +mvn install:install-file -Dfile=bazel-bin/external/com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar \ + -DgroupId=com.google.api -DartifactId=logging-proto -Dversion=0.0.0 -Dpackaging=jar + + +mvn install:install-file -Dfile=bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libdeprecated_service_proto-speed.jar \ + -DgroupId=testdata -DartifactId=deprecated-service-proto -Dversion=0.0.0 -Dpackaging=jar + +mvn install:install-file -Dfile=bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libbookshop_proto-speed.jar \ + -DgroupId=testdata -DartifactId=bookshop-proto -Dversion=0.0.0 -Dpackaging=jar + +mvn install:install-file -Dfile=bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libshowcase_proto-speed.jar \ + -DgroupId=testdata -DartifactId=showcase-proto -Dversion=0.0.0 -Dpackaging=jar + +mvn install:install-file -Dfile=bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libtestgapic_proto-speed.jar \ + -DgroupId=testdata -DartifactId=testgapic-proto -Dversion=0.0.0 -Dpackaging=jar + +mvn install:install-file -Dfile=bazel-bin//src/test/java/com/google/api/generator/gapic/testdata/libexplicit_dynamic_routing_headers_testing_proto-speed.jar \ + -DgroupId=testdata -DartifactId=explicit-dynamic-routing-headers-testing-proto -Dversion=0.0.0 -Dpackaging=jar diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000..b7551222ba --- /dev/null +++ b/pom.xml @@ -0,0 +1,228 @@ + + 4.0.0 + com.google.api + gapic-generator-java + 0.0.1-SNAPSHOT + + + UTF-8 + + + + + + maven-compiler-plugin + 3.8.1 + + 8 + 8 + + + com.google.auto.value + auto-value + 1.7.2 + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + + com.google.guava + guava + 30.1.1-jre + + + com.google.api + api-common + 1.9.3 + + + com.google.api + gax + 2.12.0 + + + com.google.api + gax + 2.12.0 + testlib + + + com.google.api + gax-grpc + 2.12.0 + + + com.google.api + gax-grpc + 2.12.0 + testlib + + + com.google.api + gax-httpjson + 0.95.0 + + + com.google.api + gax-httpjson + 0.95.0 + testlib + + + + com.google.auto.value + auto-value-annotations + 1.7.2 + + + com.google.code.findbugs + jsr305 + 3.0.0 + + + com.google.code.gson + gson + 2.8.6 + + + com.google.protobuf + protobuf-java + 3.19.1 + + + com.google.protobuf + protobuf-java-util + 3.19.1 + + + io.grpc + grpc-stub + 1.42.1 + + + io.grpc + grpc-protobuf + 1.42.1 + + + org.yaml + snakeyaml + 1.26 + + + com.google.googlejavaformat + google-java-format + 1.7 + + + + junit + junit + 4.13.1 + + + + + com.google.truth + truth + 1.1.2 + test + + + io.github.java-diff-utils + java-diff-utils + 4.0 + test + + + + io.grpc + serviceconfig-proto + 0.0.0 + + + + com.google.api + metadata-proto + 0.0.0 + + + com.google.api + common-resources-proto + 0.0.0 + + + com.google.api + logging-proto + 0.0.0 + + + com.google.api + pubsub-proto + 0.0.0 + + + + testdata + deprecated-service-proto + 0.0.0 + + + testdata + bookshop-proto + 0.0.0 + + + testdata + showcase-proto + 0.0.0 + + + testdata + testgapic-proto + 0.0.0 + + + testdata + explicit-dynamic-routing-headers-testing-proto + 0.0.0 + + + + diff --git a/src/main/java/com/google/api/generator/BUILD.bazel b/src/main/java/com/google/api/generator/BUILD.bazel deleted file mode 100644 index 8c01845671..0000000000 --- a/src/main/java/com/google/api/generator/BUILD.bazel +++ /dev/null @@ -1,39 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library", "java_plugin") - -package(default_visibility = ["//:__subpackages__"]) - -java_plugin( - name = "autovalue_plugin", - processor_class = "com.google.auto.value.processor.AutoValueProcessor", - deps = [ - "@com_google_auto_value_auto_value//jar", - ], -) - -java_library( - name = "autovalue", - exported_plugins = [ - ":autovalue_plugin", - ], - neverlink = 1, - exports = [ - "@com_google_auto_value_auto_value//jar", - ], -) - -java_library( - name = "generator", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/util", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/cloud:extended_operations_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - ], -) diff --git a/src/main/java/com/google/api/generator/debug/BUILD.bazel b/src/main/java/com/google/api/generator/debug/BUILD.bazel deleted file mode 100644 index f7e58d49cf..0000000000 --- a/src/main/java/com/google/api/generator/debug/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "debug", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator", - "//src/main/java/com/google/api/generator/engine", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/util", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - ], -) diff --git a/src/main/java/com/google/api/generator/engine/BUILD.bazel b/src/main/java/com/google/api/generator/engine/BUILD.bazel deleted file mode 100644 index 32bb9c75ac..0000000000 --- a/src/main/java/com/google/api/generator/engine/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "engine", - runtime_deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/lexicon", - ], -) diff --git a/src/main/java/com/google/api/generator/engine/ast/BUILD.bazel b/src/main/java/com/google/api/generator/engine/ast/BUILD.bazel deleted file mode 100644 index fde63de2c9..0000000000 --- a/src/main/java/com/google/api/generator/engine/ast/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "ast", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator:autovalue", - "//src/main/java/com/google/api/generator/engine/escaper", - "//src/main/java/com/google/api/generator/engine/lexicon", - "@com_google_auto_value_auto_value//jar", - "@com_google_auto_value_auto_value_annotations//jar", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - ], -) diff --git a/src/main/java/com/google/api/generator/engine/escaper/BUILD.bazel b/src/main/java/com/google/api/generator/engine/escaper/BUILD.bazel deleted file mode 100644 index 62af8ba4a1..0000000000 --- a/src/main/java/com/google/api/generator/engine/escaper/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "escaper", - srcs = glob(["*.java"]), - deps = [ - "@com_google_guava_guava//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/engine/lexicon/BUILD.bazel b/src/main/java/com/google/api/generator/engine/lexicon/BUILD.bazel deleted file mode 100644 index fc63740131..0000000000 --- a/src/main/java/com/google/api/generator/engine/lexicon/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "lexicon", - srcs = glob(["*.java"]), - deps = [ - "@com_google_guava_guava//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/engine/writer/BUILD.bazel b/src/main/java/com/google/api/generator/engine/writer/BUILD.bazel deleted file mode 100644 index 3b90a9d243..0000000000 --- a/src/main/java/com/google/api/generator/engine/writer/BUILD.bazel +++ /dev/null @@ -1,13 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "writer", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "@com_google_guava_guava//jar", - "@google_java_format_all_deps//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/BUILD.bazel deleted file mode 100644 index 301af41da1..0000000000 --- a/src/main/java/com/google/api/generator/gapic/BUILD.bazel +++ /dev/null @@ -1,26 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library", "java_proto_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_proto_library( - name = "status_java_proto", - visibility = [ - "//src/main/java/com/google/api/generator/gapic:__subpackages__", - "//src/test/java/com/google/api/generator/gapic:__subpackages__", - ], - deps = [ - "@com_google_googleapis//google/rpc:status_proto", - ], -) - -java_library( - name = "gapic", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/gapic/composer", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/main/java/com/google/api/generator/gapic/protowriter", - "@com_google_protobuf//:protobuf_java", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel deleted file mode 100644 index 4a344b44cd..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel +++ /dev/null @@ -1,45 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "composer", - srcs = glob(["*.java"]), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic:status_java_proto", - "//src/main/java/com/google/api/generator/gapic/composer/comment", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/main/java/com/google/api/generator/gapic/composer/grpc", - "//src/main/java/com/google/api/generator/gapic/composer/grpcrest", - "//src/main/java/com/google/api/generator/gapic/composer/resourcename", - "//src/main/java/com/google/api/generator/gapic/composer/rest", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/main/java/com/google/api/generator/gapic/composer/store", - "//src/main/java/com/google/api/generator/gapic/composer/utils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "//src/main/java/com/google/api/generator/util", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax-grpc:gax_grpc", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_protobuf//java/core", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/comment/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/comment/BUILD.bazel deleted file mode 100644 index 6ccf05f29e..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/comment/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "comment", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic/composer/utils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_guava_guava//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/common/BUILD.bazel deleted file mode 100644 index 36d0e1d8fe..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/common/BUILD.bazel +++ /dev/null @@ -1,46 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "common", - srcs = glob(["*.java"]), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator:autovalue", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic:status_java_proto", - "//src/main/java/com/google/api/generator/gapic/composer/comment", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/main/java/com/google/api/generator/gapic/composer/resourcename", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/main/java/com/google/api/generator/gapic/composer/store", - "//src/main/java/com/google/api/generator/gapic/composer/utils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "//src/main/java/com/google/api/generator/util", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax:gax_testlib", - "@com_google_api_gax_java//gax-grpc:gax_grpc", - "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", - "@com_google_auto_value_auto_value//jar", - "@com_google_auto_value_auto_value_annotations//jar", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_protobuf//java/core", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel deleted file mode 100644 index df6d0134be..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "defaultvalue", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic/composer/resourcename", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_api_api_common", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//java/core", - "@google_java_format_all_deps//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel deleted file mode 100644 index b8c9b06a88..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel +++ /dev/null @@ -1,44 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "grpc", - srcs = glob(["*.java"]), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic:status_java_proto", - "//src/main/java/com/google/api/generator/gapic/composer/comment", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/main/java/com/google/api/generator/gapic/composer/resourcename", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/main/java/com/google/api/generator/gapic/composer/store", - "//src/main/java/com/google/api/generator/gapic/composer/utils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "//src/main/java/com/google/api/generator/util", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax:gax_testlib", - "@com_google_api_gax_java//gax-grpc:gax_grpc", - "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_protobuf//java/core", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/grpcrest/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/grpcrest/BUILD.bazel deleted file mode 100644 index 8bb0c716a0..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/grpcrest/BUILD.bazel +++ /dev/null @@ -1,48 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "grpcrest", - srcs = glob(["*.java"]), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic:status_java_proto", - "//src/main/java/com/google/api/generator/gapic/composer/comment", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/main/java/com/google/api/generator/gapic/composer/resourcename", - "//src/main/java/com/google/api/generator/gapic/composer/rest", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/main/java/com/google/api/generator/gapic/composer/store", - "//src/main/java/com/google/api/generator/gapic/composer/utils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "//src/main/java/com/google/api/generator/util", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax:gax_testlib", - "@com_google_api_gax_java//gax-grpc:gax_grpc", - "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson_testlib", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava//jar", - "@com_google_http_client_google_http_client//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_protobuf//java/core", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel deleted file mode 100644 index 1c862d3bd8..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "resourcename", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic/composer/comment", - "//src/main/java/com/google/api/generator/gapic/composer/store", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_api_api_common", - "@com_google_guava_guava", - "@javax_annotation_javax_annotation_api", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel deleted file mode 100644 index cf15bbb574..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel +++ /dev/null @@ -1,45 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "rest", - srcs = glob(["*.java"]), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic:status_java_proto", - "//src/main/java/com/google/api/generator/gapic/composer/comment", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/main/java/com/google/api/generator/gapic/composer/resourcename", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/main/java/com/google/api/generator/gapic/composer/store", - "//src/main/java/com/google/api/generator/gapic/composer/utils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "//src/main/java/com/google/api/generator/util", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax:gax_testlib", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson_testlib", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava//jar", - "@com_google_http_client_google_http_client//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_protobuf//java/core", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel deleted file mode 100644 index d95264837e..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "samplecode", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_api_api_common", - "@com_google_api_gax_java//gax", - "@com_google_api_grpc_proto_google_common_protos", - "@google_java_format_all_deps//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/store/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/store/BUILD.bazel deleted file mode 100644 index 35848b1784..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/store/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "store", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic:status_java_proto", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax-grpc:gax_grpc", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_protobuf//java/core", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel deleted file mode 100644 index 99762a15d9..0000000000 --- a/src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "utils", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/gapic/model", - "@com_google_guava_guava//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/model/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/model/BUILD.bazel deleted file mode 100644 index 80fcb22e19..0000000000 --- a/src/main/java/com/google/api/generator/gapic/model/BUILD.bazel +++ /dev/null @@ -1,23 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "model", - srcs = glob(["*.java"]), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator:autovalue", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_api_api_common//jar", - "@com_google_auto_value_auto_value//jar", - "@com_google_auto_value_auto_value_annotations//jar", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/protoparser/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/protoparser/BUILD.bazel deleted file mode 100644 index 3d60f713ba..0000000000 --- a/src/main/java/com/google/api/generator/gapic/protoparser/BUILD.bazel +++ /dev/null @@ -1,34 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library", "java_proto_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_proto_library( - name = "client_java_proto", - visibility = ["//visibility:private"], - deps = [ - "@com_google_googleapis//google/api:client_proto", - ], -) - -java_library( - name = "protoparser", - srcs = glob(["*.java"]), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic/composer/grpc", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_api_api_common//jar", - "@com_google_api_grpc_proto_google_common_protos", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_code_gson//jar", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/cloud:extended_operations_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_guava_guava//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@org_yaml_snakeyaml//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/protowriter/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/protowriter/BUILD.bazel deleted file mode 100644 index a139ebb4fb..0000000000 --- a/src/main/java/com/google/api/generator/gapic/protowriter/BUILD.bazel +++ /dev/null @@ -1,16 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "protowriter", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/model", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - ], -) diff --git a/src/main/java/com/google/api/generator/gapic/utils/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/utils/BUILD.bazel deleted file mode 100644 index ff02f10c4f..0000000000 --- a/src/main/java/com/google/api/generator/gapic/utils/BUILD.bazel +++ /dev/null @@ -1,13 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "utils", - srcs = glob(["*.java"]), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "@com_google_guava_guava//jar", - "@google_java_format_all_deps//jar", - ], -) diff --git a/src/main/java/com/google/api/generator/util/BUILD.bazel b/src/main/java/com/google/api/generator/util/BUILD.bazel deleted file mode 100644 index 7ccecc59c7..0000000000 --- a/src/main/java/com/google/api/generator/util/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "util", - srcs = glob(["*.java"]), -) diff --git a/src/test/java/com/google/api/generator/engine/BUILD.bazel b/src/test/java/com/google/api/generator/engine/BUILD.bazel deleted file mode 100644 index 05f4939564..0000000000 --- a/src/test/java/com/google/api/generator/engine/BUILD.bazel +++ /dev/null @@ -1,33 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "JavaCodeGeneratorTest", -] - -TEST_DEPS = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/test/java/com/google/api/generator/test/framework:asserts", - "//src/test/java/com/google/api/generator/test/framework:utils", - "@junit_junit//jar", -] - -[java_test( - name = test_name, - srcs = ["%s.java" % test_name], - data = ["//src/test/java/com/google/api/generator/engine/goldens:goldens_files"], - test_class = "com.google.api.generator.engine.%s" % test_name, - deps = TEST_DEPS, -) for test_name in TESTS] - -# Run `bazel run src/test/java/com/google/api/generator/engine:JavaCodeGeneratorTest_update` -# to update goldens as expected generated code. -[java_binary( - name = "%s_update" % test_name, - srcs = ["%s.java" % test_name], - data = ["//src/test/java/com/google/api/generator/engine/goldens:goldens_files"], - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = ["com.google.api.generator.engine.%s" % test_name], - deps = TEST_DEPS, - runtime_deps = ["//src/test/java/com/google/api/generator/test/framework:junit_runner"], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/engine/ast/BUILD.bazel b/src/test/java/com/google/api/generator/engine/ast/BUILD.bazel deleted file mode 100644 index dfd452b7f8..0000000000 --- a/src/test/java/com/google/api/generator/engine/ast/BUILD.bazel +++ /dev/null @@ -1,58 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -package(default_visibility = ["//visibility:public"]) - -TESTS = [ - "AnonymousClassExprTest", - "AssignmentExprTest", - "CastExprTest", - "ClassDefinitionTest", - "ConcreteReferenceTest", - "EnumRefExprTest", - "ExprStatementTest", - "ForStatementTest", - "GeneralForStatementTest", - "IdentifierNodeTest", - "IfStatementTest", - "InstanceofExprTest", - "JavaDocCommentTest", - "LambdaExprTest", - "MethodDefinitionTest", - "NewObjectExprTest", - "NullObjectValueTest", - "PrimitiveValueTest", - "ReferenceTest", - "ReturnExprTest", - "StringObjectValueTest", - "SynchronizedStatementTest", - "TernaryExprTest", - "ThrowExprTest", - "TryCatchStatementTest", - "TypeNodeTest", - "VariableExprTest", - "VariableTest", - "VaporReferenceTest", - "MethodInvocationExprTest", - "ReferenceConstructorExprTest", - "ThisObjectValueTest", - "SuperObjectValueTest", - "WhileStatementTest", - "ArithmeticOperationExprTest", - "UnaryOperationExprTest", - "RelationalOperationExprTest", - "LogicalOperationExprTest", - "AssignmentOperationExprTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - test_class = "com.google.api.generator.engine.ast.{0}".format(test_name), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/test/java/com/google/api/generator/testutils", - "@com_google_guava_guava//jar", - "@com_google_truth_truth//jar", - "@junit_junit//jar", - ], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/engine/lexicon/BUILD.bazel b/src/test/java/com/google/api/generator/engine/lexicon/BUILD.bazel deleted file mode 100644 index a60c15b890..0000000000 --- a/src/test/java/com/google/api/generator/engine/lexicon/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "InvalidSymbolTest", - "KeywordTest", - "LiteralTest", - "OperatorTest", - "SeparatorTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - test_class = "com.google.api.generator.engine.lexicon.{0}".format(test_name), - deps = [ - "//src/main/java/com/google/api/generator/engine/lexicon", - "@com_google_truth_truth//jar", - ], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/engine/writer/BUILD.bazel b/src/test/java/com/google/api/generator/engine/writer/BUILD.bazel deleted file mode 100644 index b19be9e49d..0000000000 --- a/src/test/java/com/google/api/generator/engine/writer/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "ImportWriterVisitorTest", - "JavaWriterVisitorTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - test_class = "com.google.api.generator.engine.writer.{0}".format(test_name), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/test/java/com/google/api/generator/testutils", - "@com_google_guava_guava//jar", - "@com_google_truth_truth//jar", - "@javax_annotation_javax_annotation_api", - "@junit_junit//jar", - ], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel index 344ecf182e..0c0fe0236a 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel +++ b/src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel @@ -1,80 +1,6 @@ -load("@rules_java//java:defs.bzl", "java_proto_library", "java_test") - -TESTS = [ - "ComposerTest", -] - -TEST_DEPS = [ - ":common_resources_java_proto", - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/test/java/com/google/api/generator/test/framework:asserts", - "//src/test/java/com/google/api/generator/test/framework:utils", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/test/java/com/google/api/generator/testutils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/test/java/com/google/api/generator/gapic/testdata:deprecated_service_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:testgapic_java_proto", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_api_common", - "@com_google_googleapis//google/logging/v2:logging_java_proto", - "@com_google_googleapis//google/pubsub/v1:pubsub_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", -] - -java_proto_library( - name = "pubsub_java_proto", - deps = [ - "@com_google_googleapis//google/pubsub/v1:pubsub_proto", - ], -) +load("@rules_java//java:defs.bzl", "java_proto_library") java_proto_library( name = "common_resources_java_proto", - deps = [ - "@com_google_googleapis//google/cloud:common_resources_proto", - ], + deps = ["@com_google_googleapis//google/cloud:common_resources_proto"], ) - -[java_test( - name = test_name, - srcs = [ - "%s.java" % test_name, - ], - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - test_class = "com.google.api.generator.gapic.composer.%s" % test_name, - deps = TEST_DEPS, -) for test_name in TESTS] - -# Run `bazel run src/test/java/com/google/api/generator/gapic/composer:testTargetName_update` -# to update goldens as expected generated code. -# `ServiceClient*` tests are not supported now since they are still in active development. - -[java_binary( - name = "%s_update" % test_name, - srcs = ["%s.java" % test_name], - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = ["com.google.api.generator.gapic.composer.%s" % test_name], - deps = TEST_DEPS, - runtime_deps = ["//src/test/java/com/google/api/generator/test/framework:junit_runner"], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/common/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/common/BUILD.bazel deleted file mode 100644 index bb904ce38d..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/common/BUILD.bazel +++ /dev/null @@ -1,95 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_proto_library", "java_test") - -package(default_visibility = ["//:__subpackages__"]) - -UPDATE_GOLDENS_TESTS = [ - "BatchingDescriptorComposerTest", -] - -TESTS = UPDATE_GOLDENS_TESTS + [ - "RetrySettingsComposerTest", -] - -TEST_DEPS = [ - ":common_resources_java_proto", - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/main/java/com/google/api/generator/gapic/composer/grpc", - "//src/test/java/com/google/api/generator/test/framework:asserts", - "//src/test/java/com/google/api/generator/test/framework:utils", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/test/java/com/google/api/generator/testutils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/test/java/com/google/api/generator/gapic/testdata:deprecated_service_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:bookshop_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:explicit_dynamic_routing_headers_testing_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:testgapic_java_proto", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_api_common", - "@com_google_googleapis//google/logging/v2:logging_java_proto", - "@com_google_googleapis//google/pubsub/v1:pubsub_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", -] - -java_library( - name = "common", - srcs = ["TestProtoLoader.java"], - deps = TEST_DEPS, -) - -java_proto_library( - name = "pubsub_java_proto", - deps = [ - "@com_google_googleapis//google/pubsub/v1:pubsub_proto", - ], -) - -java_proto_library( - name = "common_resources_java_proto", - deps = [ - "@com_google_googleapis//google/cloud:common_resources_proto", - ], -) - -[java_test( - name = test_name, - srcs = [ - "%s.java" % test_name, - ], - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/common/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - test_class = "com.google.api.generator.gapic.composer.common.%s" % test_name, - deps = TEST_DEPS + [":common"], -) for test_name in TESTS] - -# Run `bazel run src/test/java/com/google/api/generator/gapic/composer/common:testTargetName_update` -# to update goldens as expected generated code. -# `ServiceClient*` tests are not supported now since they are still in active development. - -[java_binary( - name = "%s_update" % test_name, - srcs = ["%s.java" % test_name], - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/common/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = ["com.google.api.generator.gapic.composer.common.%s" % test_name], - deps = TEST_DEPS + [":common"], - runtime_deps = ["//src/test/java/com/google/api/generator/test/framework:junit_runner"], -) for test_name in UPDATE_GOLDENS_TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel deleted file mode 100644 index b601574e6b..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/BUILD.bazel +++ /dev/null @@ -1,38 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_proto_library", "java_test") - -TESTS = [ - "DefaultValueComposerTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - test_class = "com.google.api.generator.gapic.composer.defaultvalue.{0}".format(test_name), - deps = [ - ":common_resources_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:testgapic_java_proto", - "//src/test/java/com/google/api/generator/test/framework:asserts", - "//src/test/java/com/google/api/generator/test/framework:utils", - "//src/test/java/com/google/api/generator/testutils", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", - ], -) for test_name in TESTS] - -java_proto_library( - name = "common_resources_java_proto", - deps = [ - "@com_google_googleapis//google/cloud:common_resources_proto", - ], -) diff --git a/src/test/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel deleted file mode 100644 index a3760c2a71..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/grpc/BUILD.bazel +++ /dev/null @@ -1,87 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_proto_library", "java_test") - -TESTS = [ - "GrpcServiceCallableFactoryClassComposerTest", - "GrpcServiceStubClassComposerTest", - "MockServiceClassComposerTest", - "MockServiceImplClassComposerTest", - "ServiceClientClassComposerTest", - "ServiceClientTestClassComposerTest", - "ServiceSettingsClassComposerTest", - "ServiceStubClassComposerTest", - "ServiceStubSettingsClassComposerTest", -] - -COMMON_SRCS = [ - "GrpcTestProtoLoader.java", -] - -TEST_DEPS = [ - ":common_resources_java_proto", - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/main/java/com/google/api/generator/gapic/composer/grpc", - "//src/test/java/com/google/api/generator/gapic/composer/common", - "//src/test/java/com/google/api/generator/test/framework:asserts", - "//src/test/java/com/google/api/generator/test/framework:utils", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/test/java/com/google/api/generator/testutils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:explicit_dynamic_routing_headers_testing_java_proto", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_api_common", - "@com_google_googleapis//google/logging/v2:logging_java_proto", - "@com_google_googleapis//google/pubsub/v1:pubsub_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", -] - -java_proto_library( - name = "common_resources_java_proto", - deps = [ - "@com_google_googleapis//google/cloud:common_resources_proto", - ], -) - -[java_test( - name = test_name, - size = "medium", - srcs = [ - "%s.java" % test_name, - ] + COMMON_SRCS, - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/grpc/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - test_class = "com.google.api.generator.gapic.composer.grpc.%s" % test_name, - deps = TEST_DEPS, -) for test_name in TESTS] - -# Run `bazel run src/test/java/com/google/api/generator/gapic/composer/grpc:testTargetName_update` -# to update goldens as expected generated code. -# `ServiceClient*` tests are not supported now since they are still in active development. - -[java_binary( - name = "%s_update" % test_name, - srcs = ["%s.java" % test_name] + COMMON_SRCS, - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/grpc/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = ["com.google.api.generator.gapic.composer.grpc.%s" % test_name], - deps = TEST_DEPS, - runtime_deps = ["//src/test/java/com/google/api/generator/test/framework:junit_runner"], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel deleted file mode 100644 index 903ed07710..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/resourcename/BUILD.bazel +++ /dev/null @@ -1,68 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_proto_library", "java_test") - -UPDATE_GOLDENS_TESTS = [ - "ResourceNameHelperClassComposerTest", -] - -TESTS = UPDATE_GOLDENS_TESTS + [ - "ResourceNameTokenizerTest", -] - -TEST_DEPS = [ - ":common_resources_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer/resourcename", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/test/java/com/google/api/generator/gapic/composer/common", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/test/framework:asserts", - "//src/test/java/com/google/api/generator/test/framework:utils", - "//src/test/java/com/google/api/generator/testutils", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_googleapis//google/logging/v2:logging_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", -] - -[java_test( - name = test_name, - srcs = ["%s.java" % test_name], - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/resourcename/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - test_class = "com.google.api.generator.gapic.composer.resourcename.%s" % test_name, - deps = TEST_DEPS, -) for test_name in TESTS] - -java_proto_library( - name = "common_resources_java_proto", - deps = [ - "@com_google_googleapis//google/cloud:common_resources_proto", - ], -) - -# Run `bazel run src/test/java/com/google/api/generator/gapic/composer/resourcename:testTargetName_update` -# to update goldens as expected generated code. -# `ServiceClient*` tests are not supported now since they are still in active development. - -[java_binary( - name = "%s_update" % test_name, - srcs = ["%s.java" % test_name], - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/resourcename/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = ["com.google.api.generator.gapic.composer.resourcename.%s" % test_name], - deps = TEST_DEPS, - runtime_deps = ["//src/test/java/com/google/api/generator/test/framework:junit_runner"], -) for test_name in UPDATE_GOLDENS_TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel deleted file mode 100644 index 99f324acde..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/rest/BUILD.bazel +++ /dev/null @@ -1,84 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_proto_library", "java_test") - -TESTS = [ - "HttpJsonServiceCallableFactoryClassComposerTest", - "HttpJsonServiceStubClassComposerTest", - "ServiceClientTestClassComposerTest", - "ServiceSettingsClassComposerTest", - "ServiceStubSettingsClassComposerTest", -] - -COMMON_SRCS = [ - "RestTestProtoLoader.java", -] - -TEST_DEPS = [ - ":common_resources_java_proto", - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer", - "//src/main/java/com/google/api/generator/gapic/composer/common", - "//src/main/java/com/google/api/generator/gapic/composer/rest", - "//src/test/java/com/google/api/generator/gapic/composer/common", - "//src/test/java/com/google/api/generator/test/framework:asserts", - "//src/test/java/com/google/api/generator/test/framework:utils", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/test/java/com/google/api/generator/testutils", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/main/java/com/google/api/generator/gapic/composer/defaultvalue", - "//src/test/java/com/google/api/generator/gapic/testdata:deprecated_service_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:testgapic_java_proto", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_api_common", - "@com_google_googleapis//google/logging/v2:logging_java_proto", - "@com_google_googleapis//google/pubsub/v1:pubsub_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", -] - -java_proto_library( - name = "common_resources_java_proto", - deps = [ - "@com_google_googleapis//google/cloud:common_resources_proto", - ], -) - -[java_test( - name = test_name, - size = "medium", - srcs = [ - "%s.java" % test_name, - ] + COMMON_SRCS, - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/rest/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - test_class = "com.google.api.generator.gapic.composer.rest.%s" % test_name, - deps = TEST_DEPS, -) for test_name in TESTS] - -# Run `bazel run src/test/java/com/google/api/generator/gapic/composer/rest:testTargetName_update` -# to update goldens as expected generated code. -# `ServiceClient*` tests are not supported now since they are still in active development. - -[java_binary( - name = "%s_update" % test_name, - srcs = ["%s.java" % test_name] + COMMON_SRCS, - data = [ - "//src/test/java/com/google/api/generator/gapic/composer/rest/goldens:goldens_files", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = ["com.google.api.generator.gapic.composer.rest.%s" % test_name], - deps = TEST_DEPS, - runtime_deps = ["//src/test/java/com/google/api/generator/test/framework:junit_runner"], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel deleted file mode 100644 index 401802cd1a..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/samplecode/BUILD.bazel +++ /dev/null @@ -1,29 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "SampleCodeJavaFormatterTest", - "SampleCodeWriterTest", - "ServiceClientSampleCodeComposerTest", - "SettingsSampleCodeComposerTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - test_class = "com.google.api.generator.gapic.composer.samplecode.{0}".format(test_name), - deps = [ - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/engine/writer", - "//src/main/java/com/google/api/generator/gapic/composer/samplecode", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/testutils", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", - ], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel deleted file mode 100644 index 4539469c3f..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel +++ /dev/null @@ -1,23 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "PackageCheckerTest", -] - -TEST_DEPS = [ - "//src/main/java/com/google/api/generator/gapic/composer/utils", - "@com_google_guava_guava", - "@com_google_protobuf//:protobuf_java", - "@com_google_truth_truth//jar", - "@junit_junit//jar", -] - -[java_test( - name = test_name, - testonly = True, - srcs = [ - "{0}.java".format(test_name), - ], - test_class = "com.google.api.generator.gapic.composer.utils.{0}".format(test_name), - deps = TEST_DEPS, -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/model/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/model/BUILD.bazel deleted file mode 100644 index e5c109e82f..0000000000 --- a/src/test/java/com/google/api/generator/gapic/model/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "GapicServiceConfigTest", - "MethodArgumentTest", - "MethodTest", - "MessageTest", - "RoutingHeaderParamTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - data = [ - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - ], - test_class = "com.google.api.generator.gapic.model.{0}".format(test_name), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator:autovalue", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_truth_truth//jar", - "@junit_junit//jar", - ], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/protoparser/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/protoparser/BUILD.bazel deleted file mode 100644 index 3ec8a5d2ec..0000000000 --- a/src/test/java/com/google/api/generator/gapic/protoparser/BUILD.bazel +++ /dev/null @@ -1,51 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "BatchingSettingsConfigParserTest", - "GapicLanguageSettingsParserTest", - "GapicLroRetrySettingsParserTest", - "HttpRuleParserTest", - "MethodSignatureParserTest", - "ParserTest", - "PluginArgumentParserTest", - "ResourceNameParserTest", - "ResourceReferenceParserTest", - "ServiceConfigParserTest", - "ServiceYamlParserTest", - "SourceCodeInfoParserTest", - "TypeParserTest", - "RoutingRuleParserTest", - "PatternParserTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - data = [ - "//src/test/java/com/google/api/generator/gapic/testdata:basic_proto_descriptor", - "//src/test/java/com/google/api/generator/gapic/testdata:gapic_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_config_files", - "//src/test/java/com/google/api/generator/gapic/testdata:service_yaml_files", - ], - test_class = "com.google.api.generator.gapic.protoparser.{0}".format(test_name), - deps = [ - "//:service_config_java_proto", - "//src/main/java/com/google/api/generator:autovalue", - "//src/main/java/com/google/api/generator/engine/ast", - "//src/main/java/com/google/api/generator/gapic:status_java_proto", - "//src/main/java/com/google/api/generator/gapic/model", - "//src/main/java/com/google/api/generator/gapic/protoparser", - "//src/main/java/com/google/api/generator/gapic/utils", - "//src/test/java/com/google/api/generator/gapic/testdata:bookshop_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:showcase_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:explicit_dynamic_routing_headers_testing_java_proto", - "//src/test/java/com/google/api/generator/gapic/testdata:testgapic_java_proto", - "@com_google_api_api_common//jar", - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@com_google_truth_truth//jar", - "@junit_junit//jar", - ], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel index 25516cdb84..6e0e948f8f 100644 --- a/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel +++ b/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel @@ -1,8 +1,6 @@ load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") -package(default_visibility = ["//visibility:public"]) - filegroup( name = "service_config_files", srcs = glob(["*.json"]), @@ -18,21 +16,6 @@ filegroup( srcs = ["logging.yaml"], ) -genrule( - name = "basic_proto_descriptor", - srcs = [ - "basic.proto", - ], - outs = ["basic_proto.descriptor"], - # CircleCI does not have protoc installed. - cmd = "$(location @com_google_protobuf//:protoc) " + - "--include_source_info --include_imports --descriptor_set_out=$@ $(SRCS)", - message = "Generating proto descriptor", - tools = [ - "@com_google_protobuf//:protoc", - ], -) - proto_library( name = "bookshop_proto", srcs = ["bookshop.proto"], diff --git a/src/test/java/com/google/api/generator/gapic/utils/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/utils/BUILD.bazel deleted file mode 100644 index 73250cb9a5..0000000000 --- a/src/test/java/com/google/api/generator/gapic/utils/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -TESTS = [ - "JavaStyleTest", - "ResourceReferenceUtilsTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - test_class = "com.google.api.generator.gapic.utils.{0}".format(test_name), - deps = [ - "//src/main/java/com/google/api/generator/gapic/utils", - "@com_google_truth_truth//jar", - "@junit_junit//jar", - ], -) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/test/framework/BUILD.bazel b/src/test/java/com/google/api/generator/test/framework/BUILD.bazel deleted file mode 100644 index 6640cd8b89..0000000000 --- a/src/test/java/com/google/api/generator/test/framework/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "asserts", - srcs = [ - "Assert.java", - "Differ.java", - ], - deps = [ - "@io_github_java_diff_utils//jar", - "@junit_junit//jar", - "@org_hamcrest_hamcrest_core//jar", - ], -) - -java_library( - name = "utils", - srcs = ["Utils.java"], -) - -java_library( - name = "junit_runner", - srcs = ["SingleJUnitTestRunner.java"], - deps = [ - ":utils", - "@junit_junit//jar", - ], -) diff --git a/src/test/java/com/google/api/generator/testutils/BUILD.bazel b/src/test/java/com/google/api/generator/testutils/BUILD.bazel deleted file mode 100644 index dd370496da..0000000000 --- a/src/test/java/com/google/api/generator/testutils/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -package(default_visibility = ["//:__subpackages__"]) - -java_library( - name = "testutils", - srcs = glob(["*.java"]), -) diff --git a/src/test/java/com/google/api/generator/util/BUILD.bazel b/src/test/java/com/google/api/generator/util/BUILD.bazel deleted file mode 100644 index f9a26ff91e..0000000000 --- a/src/test/java/com/google/api/generator/util/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_test") - -package(default_visibility = ["//:__subpackages__"]) - -TESTS = [ - "TrieTest", -] - -[java_test( - name = test_name, - srcs = ["{0}.java".format(test_name)], - test_class = "com.google.api.generator.util.{0}".format(test_name), - deps = [ - "//src/main/java/com/google/api/generator/util", - "//src/test/java/com/google/api/generator/testutils", - "@com_google_guava_guava//jar", - "@com_google_truth_truth//jar", - "@junit_junit//jar", - ], -) for test_name in TESTS] From 0c89c219e94fd1e827a03d12ed69ed2a5bdd8a96 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 11:43:57 -0500 Subject: [PATCH 02/73] chore: add target/ to .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a484993351..913a2a8e6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -# Bazel. bazel-* .gradle/ +target/ # IDE .idea From 8068a624be53706f77775c7b161d14ac02689545 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 11:47:30 -0500 Subject: [PATCH 03/73] chore: add comment --- BUILD.bazel | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index a871b19e96..170418773e 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -13,10 +13,10 @@ java_proto_library( java_import( name = "gapic_generator_java", - # You can also pull from remote filesystem, GCS bucket, Maven repositories, etc. + # Note referring to target/ is only for local development; you can also pull from remote + # filesystem, GCS bucket, Maven repositories, etc. jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], ) - java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", From 80115afa90c26a9279dc7ea723cc5c9c73a296df Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 16:59:16 -0500 Subject: [PATCH 04/73] chore: clean up Bazel --- WORKSPACE | 20 ++---- ad-hoc-compile-proto-files.sh | 2 +- pom.xml | 31 ++++------ repositories.bzl | 113 ---------------------------------- 4 files changed, 17 insertions(+), 149 deletions(-) delete mode 100644 repositories.bzl diff --git a/WORKSPACE b/WORKSPACE index 1b5ed1b3db..240a23d896 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,18 +3,6 @@ workspace(name = "gapic_generator_java") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") -# DO NOT REMOVE. -# This is needed to clobber any transitively-pulled in versions of bazel_skylib so that packages -# like protobuf will build. -http_archive( - name = "bazel_skylib", - sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", - ], -) - jvm_maven_import_external( name = "google_java_format_all_deps", artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:1.7", @@ -52,9 +40,11 @@ load("@com_google_api_gax_java//:repositories.bzl", "com_google_api_gax_java_rep com_google_api_gax_java_repositories() -load("//:repositories.bzl", "gapic_generator_java_repositories") - -gapic_generator_java_repositories() +http_archive( + name = "com_google_googleapis", + strip_prefix = "googleapis-0899ba0f4c053a4487ccf0b699df5f850e39a45f", + urls = ["https://github.com/googleapis/googleapis/archive/0899ba0f4c053a4487ccf0b699df5f850e39a45f.zip"], +) # protobuf RULES_JVM_EXTERNAL_TAG = "4.2" diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh index ee6ba2c03d..864dc357db 100755 --- a/ad-hoc-compile-proto-files.sh +++ b/ad-hoc-compile-proto-files.sh @@ -5,7 +5,7 @@ set -o errexit # Some auto-generated Java proto library code for .proto files are not published anywhere, # so currently, we need to build them using `java_proto_library()` to generate .jar files. # -# Many of these are needed due to our usage in tests. +# Most of these are needed only for compiling test source files. # # 1. from grpc/grpc-proto: service_config.proto # diff --git a/pom.xml b/pom.xml index b7551222ba..42072c632f 100644 --- a/pom.xml +++ b/pom.xml @@ -59,11 +59,6 @@ guava 30.1.1-jre - - com.google.api - api-common - 1.9.3 - com.google.api gax @@ -110,21 +105,6 @@ auto-value-annotations 1.7.2 - - com.google.code.findbugs - jsr305 - 3.0.0 - - - com.google.code.gson - gson - 2.8.6 - - - com.google.protobuf - protobuf-java - 3.19.1 - com.google.protobuf protobuf-java-util @@ -182,46 +162,57 @@ metadata-proto 0.0.0 + + com.google.api common-resources-proto 0.0.0 + test + com.google.api logging-proto 0.0.0 + test com.google.api pubsub-proto 0.0.0 + test testdata deprecated-service-proto 0.0.0 + test testdata bookshop-proto 0.0.0 + test testdata showcase-proto 0.0.0 + test testdata testgapic-proto 0.0.0 + test testdata explicit-dynamic-routing-headers-testing-proto 0.0.0 + test diff --git a/repositories.bzl b/repositories.bzl deleted file mode 100644 index 5febdb273e..0000000000 --- a/repositories.bzl +++ /dev/null @@ -1,113 +0,0 @@ -# Copyright 2019 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. - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") -load("//:PROPERTIES.bzl", "PROPERTIES") - -def gapic_generator_java_repositories(): - # Import dependencies shared between Gradle and Bazel (i.e. maven dependencies) - for name, artifact in PROPERTIES.items(): - _maybe( - jvm_maven_import_external, - name = name, - strip_repo_prefix = "maven.", - artifact = _fix_bazel_artifact_format(artifact), - server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"], - licenses = ["notice", "reciprocal"], - ) - - # Import Bazel-only dependencies (Gradle version will import maven artifacts of same - # version, while Bazel will depend on Bazel workspaces). The versions are shared in the - # properties file. - _protobuf_version = PROPERTIES["version.com_google_protobuf"] - _maybe( - http_archive, - name = "com_google_protobuf", - urls = ["https://github.com/protocolbuffers/protobuf/archive/v%s.zip" % _protobuf_version], - strip_prefix = "protobuf-%s" % _protobuf_version, - ) - - _maybe( - jvm_maven_import_external, - name = "google_java_format_all_deps", - artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:%s" % PROPERTIES["version.google_java_format"], - server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"], - licenses = ["notice", "reciprocal"], - ) - - _maybe( - http_archive, - name = "bazel_skylib", - sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d", - strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b", - urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"], - ) - - _maybe( - http_archive, - name = "com_google_googleapis", - strip_prefix = "googleapis-0899ba0f4c053a4487ccf0b699df5f850e39a45f", - urls = [ - "https://github.com/googleapis/googleapis/archive/0899ba0f4c053a4487ccf0b699df5f850e39a45f.zip", - ], - ) - - _maybe( - native.bind, - name = "guava", - actual = "@com_google_guava_guava//jar", - ) - - _maybe( - native.bind, - name = "gson", - actual = "@com_google_code_gson_gson//jar", - ) - - _api_common_java_version = PROPERTIES["version.com_google_api_common_java"] - _maybe( - jvm_maven_import_external, - name = "com_google_api_api_common", - artifact = "com.google.api:api-common:%s" % _api_common_java_version, - server_urls = ["https://repo.maven.apache.org/maven2/"], - ) - - # grpc-proto doesn't have releases, so we use hashes instead. - _io_grpc_proto_prefix = "8e3fec8612bc0708e857950dccadfd5063703e04" # Nov. 6, 2021. - _maybe( - http_archive, - name = "io_grpc_proto", - urls = ["https://github.com/grpc/grpc-proto/archive/%s.zip" % _io_grpc_proto_prefix], - strip_prefix = "grpc-proto-%s" % _io_grpc_proto_prefix, - ) - -def _maybe(repo_rule, name, strip_repo_prefix = "", **kwargs): - if not name.startswith(strip_repo_prefix): - return - repo_name = name[len(strip_repo_prefix):] - if repo_name in native.existing_rules(): - return - repo_rule(name = repo_name, **kwargs) - -def _fix_bazel_artifact_format(artifact_id): - # Fix the artifact id format discrepancy between Bazel & Gradle. - # This is relevant only when classifier is specified explicitly. - # Bazel format: groupId:artifactId:jar:classifier:version - # Gradle format: groupId:artifactId:version:classifier - ids = artifact_id.split(":") - if len(ids) != 4: - return artifact_id - return "%s:%s:%s:%s:%s" % (ids[0], ids[1], "jar", ids[3], ids[2]) From 7d0aa1434241e8d03868883538250b8cb2b3bbfd Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 17:18:31 -0500 Subject: [PATCH 05/73] chore: clean up Bazel --- PROPERTIES.bzl | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 PROPERTIES.bzl diff --git a/PROPERTIES.bzl b/PROPERTIES.bzl deleted file mode 100644 index 035eb12647..0000000000 --- a/PROPERTIES.bzl +++ /dev/null @@ -1,32 +0,0 @@ -PROPERTIES = { - "version.com_google_protobuf": "3.19.1", - # Version of google-java-format is downgraded from 1.8 to 1.7, because 1.8 supports java 11 minimum, while our JRE is java 8. - "version.google_java_format": "1.7", - "version.com_google_api_common_java": "1.9.3", - "version.io_grpc_java": "1.42.1", - - # Common deps. - "maven.com_google_guava_guava": "com.google.guava:guava:30.1-android", - "maven.com_google_code_findbugs_jsr305": "com.google.code.findbugs:jsr305:3.0.0", - "maven.com_google_auto_value_auto_value": "com.google.auto.value:auto-value:1.7.2", - "maven.com_google_auto_value_auto_value_annotations": "com.google.auto.value:auto-value-annotations:1.7.2", - "maven.com_google_code_gson": "com.google.code.gson:gson:2.8.6", - "maven.com_google_protobuf_protobuf_java": "com.google.protobuf:protobuf-java:3.19.1", - "maven.io_github_java_diff_utils": "io.github.java-diff-utils:java-diff-utils:4.0", - "maven.javax_annotation_javax_annotation_api": "javax.annotation:javax.annotation-api:1.3.2", - - # Gapic YAML parsing for batching settings. - "maven.org_yaml_snakeyaml": "org.yaml:snakeyaml:1.26", - - # ServiceStubSettings class. Used only in generated code. - "maven.org_threeten_threetenbp": "org.threeten:threetenbp:1.3.3", - - # Testing. - "maven.junit_junit": "junit:junit:4.13.1", - # This hamcrest-core dependency is for running JUnit test manually, before JUnit 4.11 it's wrapped along with JUnit package. - # But now it has to be explicitly added. - "maven.org_hamcrest_hamcrest_core": "org.hamcrest:hamcrest-core:1.3", - "maven.org_mockito_mockito_core": "org.mockito:mockito-core:2.21.0", - # Keep in sync with gax-java. - "maven.com_google_truth_truth": "com.google.truth:truth:1.1.2", -} From c04b87baaffc96d6799303d2d9a2b9d6203d5096 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 17:37:03 -0500 Subject: [PATCH 06/73] chore: migrate google-java-format --- BUILD.bazel | 20 -------------------- pom.xml | 5 +++++ 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 170418773e..64f970c3e1 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -65,23 +65,3 @@ java_binary( main_class = "com.google.googlejavaformat.java.Main", runtime_deps = ["@google_java_format_all_deps//jar"], ) - -genrule( - name = "google_java_format", - outs = ["google_java_format.sh"], - cmd = "echo 'find src test -name \'*.java\' | grep -v /goldens/ | xargs $(execpath :google_java_format_binary) --replace' > $(OUTS)", - executable = 1, - tools = [":google_java_format_binary"], - local = 1, -) - -# Run `bazel build //:google_java_format_verification` to verify that gapic-generator-java sources -# are formatted correctly. -genrule( - name = "google_java_format_verification", - outs = ["google_java_format_verification.sh"], - cmd = "echo 'find src test -name \'*.java\' | grep -v /goldens/ | xargs $(execpath :google_java_format_binary) --dry-run --set-exit-if-changed' > $(OUTS)", - executable = 1, - tools = [":google_java_format_binary"], - local = 1, -) diff --git a/pom.xml b/pom.xml index 42072c632f..ecd75b53dc 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,11 @@ + + com.coveo + fmt-maven-plugin + 2.9.1 + org.apache.maven.plugins maven-shade-plugin From 7c3635302648c6f963a0552e88c179a5953bdd63 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 21:03:35 -0500 Subject: [PATCH 07/73] chore: make test work / more cleanups --- WORKSPACE | 31 ++++++------------- ad-hoc-compile-proto-files.sh | 20 +++++++++--- .../protoparser/SourceCodeInfoParserTest.java | 4 ++- .../api/generator/gapic/testdata/BUILD.bazel | 15 +++++++++ 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 240a23d896..92c7895968 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -41,33 +41,20 @@ load("@com_google_api_gax_java//:repositories.bzl", "com_google_api_gax_java_rep com_google_api_gax_java_repositories() http_archive( - name = "com_google_googleapis", - strip_prefix = "googleapis-0899ba0f4c053a4487ccf0b699df5f850e39a45f", - urls = ["https://github.com/googleapis/googleapis/archive/0899ba0f4c053a4487ccf0b699df5f850e39a45f.zip"], + name = "com_google_googleapis", + urls = ["https://github.com/googleapis/googleapis/archive/0899ba0f4c053a4487ccf0b699df5f850e39a45f.zip"], + strip_prefix = "googleapis-0899ba0f4c053a4487ccf0b699df5f850e39a45f", ) -# protobuf -RULES_JVM_EXTERNAL_TAG = "4.2" -RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca" - http_archive( - name = "rules_jvm_external", - strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, - sha256 = RULES_JVM_EXTERNAL_SHA, - url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, + name = "io_grpc_proto", + # Nov. 6, 2021. + urls = ["https://github.com/grpc/grpc-proto/archive/8e3fec8612bc0708e857950dccadfd5063703e04.zip"], + strip_prefix = "grpc-proto-8e3fec8612bc0708e857950dccadfd5063703e04", ) -load("@com_google_protobuf//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps") - -load("@rules_jvm_external//:defs.bzl", "maven_install") - -maven_install( - artifacts = PROTOBUF_MAVEN_ARTIFACTS, - generate_compat_repositories = True, - repositories = [ - "https://repo.maven.apache.org/maven2/", - ], -) +# protobuf +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh index 864dc357db..50cab2bb37 100755 --- a/ad-hoc-compile-proto-files.sh +++ b/ad-hoc-compile-proto-files.sh @@ -2,8 +2,9 @@ set -o errexit -# Some auto-generated Java proto library code for .proto files are not published anywhere, -# so currently, we need to build them using `java_proto_library()` to generate .jar files. +# Some auto-generated Java proto library code for .proto files are not published +# anywhere, so currently, we need to build them using `java_proto_library()` to +# generate .jar files. # # Most of these are needed only for compiling test source files. # @@ -15,7 +16,7 @@ set -o errexit # - pubsub.proto (v2) # - logging.proto (v1) # -# 2. local testdata .protos in src/test/java/com/google/api/generator/gapic/testdata: +# 3. local testdata .protos in src/test/java/com/google/api/generator/gapic/testdata: # - deprecated_service: deprecated_service.proto # - bookshop: bookshop.proto # - showcase: compliance.proto, echo.proto, identity.proto, testing.proto and messaging.proto @@ -23,6 +24,15 @@ set -o errexit # - explicit_dynamic_routing_headers_testing: # - routing_rule_parser_testing.proto # - explicit_dynamic_routing_header_testing.proto +# +# +# In addition to this, there is one special .proto in testdata that doesn't +# require compiled Java library but .descriptor generated by the protobuf +# copmiler: basic.proto +# +# Currently, the Bazel target runs the following command to gerenrate this: +# protoc --include_source_info --include_imports --descriptor_set_out=basic_proto.descriptor basic.proto + bazel build service_config_java_proto bazel build @com_google_googleapis//gapic/metadata:metadata_java_proto @@ -36,11 +46,12 @@ bazel build src/test/java/com/google/api/generator/gapic/testdata:showcase_java_ bazel build src/test/java/com/google/api/generator/gapic/testdata:testgapic_java_proto bazel build src/test/java/com/google/api/generator/gapic/testdata:explicit_dynamic_routing_headers_testing_java_proto +bazel build src/test/java/com/google/api/generator/gapic/testdata:basic_proto_descriptor + mvn install:install-file -Dfile=bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar \ -DgroupId=io.grpc -DartifactId=serviceconfig-proto -Dversion=0.0.0 -Dpackaging=jar - mvn install:install-file -Dfile=bazel-bin/external/com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar \ -DgroupId=com.google.api -DartifactId=metadata-proto -Dversion=0.0.0 -Dpackaging=jar @@ -53,7 +64,6 @@ mvn install:install-file -Dfile=bazel-bin/external/com_google_googleapis/google/ mvn install:install-file -Dfile=bazel-bin/external/com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar \ -DgroupId=com.google.api -DartifactId=logging-proto -Dversion=0.0.0 -Dpackaging=jar - mvn install:install-file -Dfile=bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libdeprecated_service_proto-speed.jar \ -DgroupId=testdata -DartifactId=deprecated-service-proto -Dversion=0.0.0 -Dpackaging=jar diff --git a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java index 4be6c37fe4..512cb4169f 100644 --- a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java +++ b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java @@ -32,8 +32,10 @@ import org.junit.Test; public class SourceCodeInfoParserTest { + // TODO: this file should be generated during the generate-test-resources or + // process-test-resources lifecycle and fetched as a resource. private static final String TEST_PROTO_FILE = - "src/test/java/com/google/api/generator/gapic/testdata/basic_proto.descriptor"; + "bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/basic_proto.descriptor"; private SourceCodeInfoParser parser; private FileDescriptor protoFile; diff --git a/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel index 6e0e948f8f..48ecd4a539 100644 --- a/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel +++ b/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel @@ -16,6 +16,21 @@ filegroup( srcs = ["logging.yaml"], ) +genrule( + name = "basic_proto_descriptor", + srcs = [ + "basic.proto", + ], + outs = ["basic_proto.descriptor"], + # CircleCI does not have protoc installed. + cmd = "$(location @com_google_protobuf//:protoc) " + + "--include_source_info --include_imports --descriptor_set_out=$@ $(SRCS)", + message = "Generating proto descriptor", + tools = [ + "@com_google_protobuf//:protoc", + ], +) + proto_library( name = "bookshop_proto", srcs = ["bookshop.proto"], From 1318db43706195256c1c8200933189b836f67b4d Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 2 Feb 2022 21:11:04 -0500 Subject: [PATCH 08/73] chore: fix generation --- WORKSPACE | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 92c7895968..95ba9326d2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -54,7 +54,24 @@ http_archive( ) # protobuf -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") +RULES_JVM_EXTERNAL_TAG = "4.2" +RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca" + +http_archive( + name = "rules_jvm_external", + strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, + sha256 = RULES_JVM_EXTERNAL_SHA, + url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, +) + +load("@com_google_protobuf//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps") + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +maven_install( + artifacts = PROTOBUF_MAVEN_ARTIFACTS, + repositories = ["https://repo.maven.apache.org/maven2/"], +) protobuf_deps() From be52ba653804d3a1d08e62cfba4a84218ca5bc92 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 8 Feb 2022 17:39:08 -0500 Subject: [PATCH 09/73] chore: fix things after merge with main --- BUILD.bazel | 104 ++---------------- ad-hoc-compile-proto-files.sh | 33 ++---- pom.xml | 29 +---- .../protoparser/SourceCodeInfoParserTest.java | 2 +- 4 files changed, 24 insertions(+), 144 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index d06f6cf1b6..c8475b7258 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -2,64 +2,6 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_proto_library") package(default_visibility = ["//visibility:public"]) -java_import( - name = "gapic_generator_java", - # Note referring to target/ is only for local development; you can also pull from remote - # filesystem, GCS bucket, Maven repositories, etc. - jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], -) -java_binary( - name = "protoc-gen-java_gapic", - srcs = glob(["src/main/java/**/*.java"]), - main_class = "com.google.api.generator.Main", - runtime_deps = ["gapic_generator_java"], -) - -# TODO: some dependencies may be runtime only. -MAIN_DEPS = [ - ":service_config_java_proto", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax:gax_testlib", - "@com_google_api_gax_java//gax-grpc:gax_grpc", - "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson_testlib", - "@com_google_api_grpc_proto_google_common_protos", - "@com_google_auto_value_auto_value_annotations//jar", # Ideally should be compile-time only, but this is OK. - "@com_google_code_gson//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_guava_guava", - "@com_google_http_client_google_http_client//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@google_java_format_all_deps//jar", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - "@org_yaml_snakeyaml//jar", -] - -MAIN_DEPS_DEBUG_RUNTIME_ONLY = [ - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/cloud:extended_operations_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_protobuf//java/core", -] - -# Some dependencies are runtime only, but that's fine for tests. -TEST_DEPS = [ - ":test_java_protos", - "@com_google_googleapis//google/logging/v2:logging_java_proto", - "@com_google_googleapis//google/pubsub/v1:pubsub_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_truth_truth//jar", - "@io_github_java_diff_utils//jar", -] - java_proto_library( name = "service_config_java_proto", deps = ["@io_grpc_proto//:service_config_proto"], @@ -92,18 +34,16 @@ java_proto_library( ], ) -java_plugin( - name = "autovalue_plugin", - processor_class = "com.google.auto.value.processor.AutoValueProcessor", - deps = ["@com_google_auto_value_auto_value//jar"], +java_import( + name = "gapic_generator_java", + # Note referring to target/ is only for local development; you can also pull from remote + # filesystem, GCS bucket, Maven repositories, etc. + jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], ) - java_binary( name = "protoc-gen-java_gapic", - srcs = glob(["src/main/java/**/*.java"]), main_class = "com.google.api.generator.Main", - plugins = [":autovalue_plugin"], - deps = MAIN_DEPS, + runtime_deps = ["gapic_generator_java"] ) # Request dumper binary, which dumps the CodeGeneratorRequest to a file on disk @@ -125,7 +65,7 @@ java_binary( java_binary( name = "protoc-gen-code_generator_request_dumper", main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper", - runtime_deps = ["protoc-gen-java_gapic"] + MAIN_DEPS_DEBUG_RUNTIME_ONLY, + runtime_deps = ["gapic_generator_java"], ) # A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest @@ -138,7 +78,7 @@ java_binary( java_binary( name = "code_generator_request_file_to_gapic_main", main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", - runtime_deps = ["protoc-gen-java_gapic"] + MAIN_DEPS_DEBUG_RUNTIME_ONLY, + runtime_deps = ["gapic_generator_java"], ) # another test resource @@ -152,19 +92,6 @@ genrule( tools = ["@com_google_protobuf//:protoc"], ) -# Unit tests. Run each test with, e.g., -# bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest -[java_test( - name = "unit_" + file[14:-5].replace('/', '_'), - srcs = glob(["src/test/java/**/*.java"]), - test_class = file[14:-5].replace('/', '.'), - deps = [":protoc-gen-java_gapic"] + MAIN_DEPS + TEST_DEPS, - data = [":basic_proto_descriptor"] + glob([ - "src/test/java/**/*.golden", - "src/test/resources/**", - ]), -) for file in glob(["src/test/java/**/*Test.java"])] - # Tests that generate and save unit golden (.golden) files. GOLDEN_UPDATING_UNIT_TESTS = [ "com.google.api.generator.engine.JavaCodeGeneratorTest", @@ -187,21 +114,6 @@ GOLDEN_UPDATING_UNIT_TESTS = [ "com.google.api.generator.gapic.composer.rest.ServiceStubSettingsClassComposerTest", ] -# Manually runs a single JUnit test for the tests that generate and save .golden -# files. To update .golden files, run with, e.g., -# bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest -[java_binary( - name = "update_%s" % test_class.replace('.', '_'), - srcs = glob(["src/test/java/**/*.java"]), - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = [test_class], - deps = [":protoc-gen-java_gapic"] + MAIN_DEPS + TEST_DEPS, - data = glob([ - "src/test/java/**/*.golden", - "src/test/resources/**", - ]), -) for test_class in GOLDEN_UPDATING_UNIT_TESTS] - # google-java-format java_binary( name = "google_java_format_binary", diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh index fe868499f2..2a415b8d92 100755 --- a/ad-hoc-compile-proto-files.sh +++ b/ad-hoc-compile-proto-files.sh @@ -40,24 +40,15 @@ function install_jar { mvn install:install-file -DgroupId=$1 -DartifactId=$2 -Dfile=$3 -Dversion=0.0.0 -Dpackaging=jar } -#install_jar io.grpc serviceconfig-proto bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar -#install_jar com.google.api metadata-proto bazel-bin/external/com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar -#install_jar com.google.api common-resources-proto bazel-bin/external/com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar -#install_jar com.google.api pubsub-proto bazel-bin/external/com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar -#install_jar com.google.api logging-proto bazel-bin/external/com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar -install_jar com.google.api gapic-generator-test-protos bazel-bin/libtest_protos-speed.jar - -#install_jar bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libdeprecated_service_proto-speed.jar \ -# testdata deprecated-service-proto - -#install_jar bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libbookshop_proto-speed.jar \ -# testdata bookshop-proto - -#install_jar bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libshowcase_proto-speed.jar \ -# testdata showcase-proto - -#install_jar bazel-bin/src/test/java/com/google/api/generator/gapic/testdata/libtestgapic_proto-speed.jar \ -# testdata testgapic-proto - -#install_jar bazel-bin//src/test/java/com/google/api/generator/gapic/testdata/libexplicit_dynamic_routing_headers_testing_proto-speed.jar \ -# testdata explicit-dynamic-routing-headers-testing-proto +install_jar io.grpc serviceconfig-proto \ + bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar +install_jar com.google.api metadata-proto \ + bazel-bin/external/com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar +install_jar com.google.api common-resources-proto \ + bazel-bin/external/com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar +install_jar com.google.api pubsub-proto \ + bazel-bin/external/com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar +install_jar com.google.api logging-proto \ + bazel-bin/external/com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar +install_jar com.google.api gapic-generator-test-protos \ + bazel-bin/libtest_protos-speed.jar diff --git a/pom.xml b/pom.xml index ecd75b53dc..3c5e7c9658 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ shade + false *:* @@ -190,32 +191,8 @@ - testdata - deprecated-service-proto - 0.0.0 - test - - - testdata - bookshop-proto - 0.0.0 - test - - - testdata - showcase-proto - 0.0.0 - test - - - testdata - testgapic-proto - 0.0.0 - test - - - testdata - explicit-dynamic-routing-headers-testing-proto + com.google.api + gapic-generator-test-protos 0.0.0 test diff --git a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java index 8bba0d03a6..25b15590d4 100644 --- a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java +++ b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java @@ -32,7 +32,7 @@ import org.junit.Test; public class SourceCodeInfoParserTest { - private static final String TEST_PROTO_FILE = "basic_proto.descriptor"; + private static final String TEST_PROTO_FILE = "bazel-bin/basic_proto.descriptor"; private SourceCodeInfoParser parser; private FileDescriptor protoFile; From 02585df4eaf285392cd58290088fb60d2e422686 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 8 Feb 2022 17:41:47 -0500 Subject: [PATCH 10/73] chore: wip --- BUILD.bazel | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index c8475b7258..ff63efb371 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -34,6 +34,17 @@ java_proto_library( ], ) +# another test resource +genrule( + name = "basic_proto_descriptor", + srcs = ["src/test/resources/basic.proto"], + outs = ["basic_proto.descriptor"], + cmd = "$(location @com_google_protobuf//:protoc) " + + "--include_source_info --include_imports --descriptor_set_out=$(OUTS) $(SRCS)", + message = "Generating proto descriptor", + tools = ["@com_google_protobuf//:protoc"], +) + java_import( name = "gapic_generator_java", # Note referring to target/ is only for local development; you can also pull from remote @@ -81,39 +92,6 @@ java_binary( runtime_deps = ["gapic_generator_java"], ) -# another test resource -genrule( - name = "basic_proto_descriptor", - srcs = ["src/test/resources/basic.proto"], - outs = ["basic_proto.descriptor"], - cmd = "$(location @com_google_protobuf//:protoc) " + - "--include_source_info --include_imports --descriptor_set_out=$(OUTS) $(SRCS)", - message = "Generating proto descriptor", - tools = ["@com_google_protobuf//:protoc"], -) - -# Tests that generate and save unit golden (.golden) files. -GOLDEN_UPDATING_UNIT_TESTS = [ - "com.google.api.generator.engine.JavaCodeGeneratorTest", - "com.google.api.generator.gapic.composer.ComposerTest", - "com.google.api.generator.gapic.composer.common.BatchingDescriptorComposerTest", - "com.google.api.generator.gapic.composer.grpc.GrpcServiceCallableFactoryClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.GrpcServiceStubClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.MockServiceClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.MockServiceImplClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceClientClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceClientTestClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceSettingsClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceStubClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceStubSettingsClassComposerTest", - "com.google.api.generator.gapic.composer.resourcename.ResourceNameHelperClassComposerTest", - "com.google.api.generator.gapic.composer.rest.HttpJsonServiceCallableFactoryClassComposerTest", - "com.google.api.generator.gapic.composer.rest.HttpJsonServiceStubClassComposerTest", - "com.google.api.generator.gapic.composer.rest.ServiceClientTestClassComposerTest", - "com.google.api.generator.gapic.composer.rest.ServiceSettingsClassComposerTest", - "com.google.api.generator.gapic.composer.rest.ServiceStubSettingsClassComposerTest", -] - # google-java-format java_binary( name = "google_java_format_binary", From cb542561d440b6c0be643b1e656e067ee4b9235b Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 8 Feb 2022 17:45:32 -0500 Subject: [PATCH 11/73] chore: wip --- .../api/generator/gapic/composer/BUILD.bazel | 6 - .../api/generator/gapic/testdata/BUILD.bazel | 147 ------------------ 2 files changed, 153 deletions(-) delete mode 100644 src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel delete mode 100644 src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel diff --git a/src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel deleted file mode 100644 index 0c0fe0236a..0000000000 --- a/src/test/java/com/google/api/generator/gapic/composer/BUILD.bazel +++ /dev/null @@ -1,6 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_proto_library") - -java_proto_library( - name = "common_resources_java_proto", - deps = ["@com_google_googleapis//google/cloud:common_resources_proto"], -) diff --git a/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel deleted file mode 100644 index 48ecd4a539..0000000000 --- a/src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel +++ /dev/null @@ -1,147 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_java//java:defs.bzl", "java_proto_library") - -filegroup( - name = "service_config_files", - srcs = glob(["*.json"]), -) - -filegroup( - name = "gapic_config_files", - srcs = glob(["*_gapic.yaml"]), -) - -filegroup( - name = "service_yaml_files", - srcs = ["logging.yaml"], -) - -genrule( - name = "basic_proto_descriptor", - srcs = [ - "basic.proto", - ], - outs = ["basic_proto.descriptor"], - # CircleCI does not have protoc installed. - cmd = "$(location @com_google_protobuf//:protoc) " + - "--include_source_info --include_imports --descriptor_set_out=$@ $(SRCS)", - message = "Generating proto descriptor", - tools = [ - "@com_google_protobuf//:protoc", - ], -) - -proto_library( - name = "bookshop_proto", - srcs = ["bookshop.proto"], - deps = [ - "@com_google_googleapis//google/api:annotations_proto", - "@com_google_googleapis//google/api:client_proto", - "@com_google_googleapis//google/api:field_behavior_proto", - ], -) - -proto_library( - name = "showcase_proto", - srcs = [ - "compliance.proto", - "echo.proto", - "identity.proto", - "testing.proto", - "messaging.proto", - ], - deps = [ - "@com_google_googleapis//google/api:annotations_proto", - "@com_google_googleapis//google/api:routing_proto", - "@com_google_googleapis//google/api:client_proto", - "@com_google_googleapis//google/api:field_behavior_proto", - "@com_google_googleapis//google/api:resource_proto", - "@com_google_googleapis//google/cloud:extended_operations_proto", - "@com_google_googleapis//google/longrunning:operations_proto", - "@com_google_googleapis//google/rpc:error_details_proto", - "@com_google_googleapis//google/rpc:status_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:field_mask_proto", - "@com_google_protobuf//:timestamp_proto", - ], -) - -proto_library( - name = "explicit_dynamic_routing_headers_testing_proto", - srcs = [ - "routing_rule_parser_testing.proto", - "explicit_dynamic_routing_header_testing.proto", - ], - deps = [ - "@com_google_googleapis//google/api:annotations_proto", - "@com_google_googleapis//google/api:routing_proto", - "@com_google_googleapis//google/api:client_proto", - "@com_google_protobuf//:empty_proto", - ], -) - -proto_library( - name = "deprecated_service_proto", - srcs = [ - "deprecated_service.proto", - ], - deps = [ - "@com_google_googleapis//google/api:annotations_proto", - "@com_google_googleapis//google/api:client_proto", - "@com_google_googleapis//google/api:field_behavior_proto", - "@com_google_googleapis//google/api:resource_proto", - "@com_google_googleapis//google/longrunning:operations_proto", - "@com_google_googleapis//google/rpc:error_details_proto", - "@com_google_googleapis//google/rpc:status_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - ], -) - -proto_library( - name = "testgapic_proto", - srcs = [ - "bad_message_resname_def.proto", - "locker.proto", - "nested_message.proto", - ], - deps = [ - "@com_google_googleapis//google/api:annotations_proto", - "@com_google_googleapis//google/api:client_proto", - "@com_google_googleapis//google/api:field_behavior_proto", - "@com_google_googleapis//google/api:resource_proto", - "@com_google_googleapis//google/longrunning:operations_proto", - "@com_google_googleapis//google/rpc:error_details_proto", - "@com_google_googleapis//google/rpc:status_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:field_mask_proto", - "@com_google_protobuf//:timestamp_proto", - ], -) - -java_proto_library( - name = "deprecated_service_java_proto", - deps = [":deprecated_service_proto"], -) - -java_proto_library( - name = "bookshop_java_proto", - deps = [":bookshop_proto"], -) - -java_proto_library( - name = "showcase_java_proto", - deps = [":showcase_proto"], -) - -java_proto_library( - name = "testgapic_java_proto", - deps = [":testgapic_proto"], -) - -java_proto_library( - name = "explicit_dynamic_routing_headers_testing_java_proto", - deps = [":explicit_dynamic_routing_headers_testing_proto"], -) From ba0494a73d550e66c2fde34de5c52f16064d74da Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 8 Feb 2022 18:10:37 -0500 Subject: [PATCH 12/73] chore: enable updating unit golden files --- DEVELOPMENT.md | 15 +++++---------- .../api/generator/test/framework/Utils.java | 15 ++++++--------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index c52e41e4ac..74691e2b34 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -104,25 +104,20 @@ - Run all unit and integration tests. ```sh - bazel test //... + mvn test # unit tests + bazel test //... # integration tests ``` - Run all unit tests. ```sh - bazel test $(bazel query //... | grep ^//:unit_) + mvn test ``` -- Run a single unit test like `JavaCodeGeneratorTest.java` +- Update unit test golden files: ```sh - bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest - ``` - -- Update unit test golden files, for example `JavaCodeGeneratorTest.java`: - - ```sh - bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest + mvn test -DupdateUnitGoldens ``` - Run a single integration test for API like `Redis`, it generates Java source diff --git a/src/test/java/com/google/api/generator/test/framework/Utils.java b/src/test/java/com/google/api/generator/test/framework/Utils.java index 255bf3c949..d5d97c9118 100644 --- a/src/test/java/com/google/api/generator/test/framework/Utils.java +++ b/src/test/java/com/google/api/generator/test/framework/Utils.java @@ -26,22 +26,19 @@ public class Utils { * replace the original goldens. For example: * `src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java` will save the * generated code into a file called `ComposerTest.golden` at - * `$TEST_OUTPUT_HOME/com/google/api/generator/gapic/composer/goldens/ComposerTest.golden`. + * `src/test/java/com/google/api/generator/gapic/composer/goldens/ComposerTest.golden`. * * @param clazz the test class. * @param fileName the name of saved file, usually a test method name with suffix `.golden` * @param codegen the generated code from JUnit test */ public static void saveCodegenToFile(Class clazz, String fileName, String codegen) { - // This system environment variable `TEST_OUTPUT_HOME` is used to specify a folder - // which contains generated output from JUnit test. However, when running `bazel run - // testTarget_update` command, the environment variable will be ignored, and the correct - // folder in the workspace will be auto-detected. - String workspaceDir = System.getenv("BUILD_WORKSPACE_DIRECTORY"); - String testOutputHome = - workspaceDir != null ? workspaceDir + "/src/test/java" : System.getenv("TEST_OUTPUT_HOME"); + if (System.getProperty("updateUnitGoldens") == null) { + return; + } + String relativeGoldenDir = getTestoutGoldenDir(clazz); - Path testOutputDir = Paths.get(testOutputHome, relativeGoldenDir); + Path testOutputDir = Paths.get("src", "test", "java", relativeGoldenDir); testOutputDir.toFile().mkdirs(); try (FileWriter myWriter = new FileWriter(testOutputDir.resolve(fileName).toFile())) { myWriter.write(codegen); From 9e814a2c863698f74d30cd07376ee332bf06bace Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 12:13:54 -0500 Subject: [PATCH 13/73] chore: wip --- .githooks/pre-commit | 3 ++- .github/workflows/ci.yaml | 32 +++++++++++-------------------- ad-hoc-compile-proto-files.sh | 36 ++++++++++++++++------------------- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 746debcd9a..4f64914be7 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -96,7 +96,8 @@ fi if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ] then echo_status "Checking unit tests..." - bazel --batch test //:units --disk_cache="$BAZEL_CACHE_DIR" + ./ad-hoc-compile-proto-files.sh + mvn verify TEST_STATUS=$? if [ $TEST_STATUS != 0 ] then diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 511d074fd7..caad414a31 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,6 +18,14 @@ jobs: java-version: ${{ matrix.java }} - run: java -version + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Bazel File Cache Setup id: cache-bazel uses: actions/cache@v2 @@ -41,7 +49,9 @@ jobs: echo "The old one will disappear after 7 days." - name: Unit Tests - run: bazel --batch test //:units --noshow_progress --test_output=errors + run: | + ./ad-hoc-compile-proto-files.sh + mvn verify --batch-mode --no-transfer-progress - name: Integration Tests run: bazel --batch test //test/integration/... @@ -76,25 +86,6 @@ jobs: - name: Java Linter run: bazel --batch run //:google_java_format_verification - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - java-version: 8 - - run: java -version - - - name: Generate Code Coverage Report - # Run only test targets, and not golden_update targets. - run: bazel coverage //:units --combined_report=lcov - - - name: Upload Code Coverage Report - uses: codecov/codecov-action@v2 - with: - name: actions ${{ matrix.java }} - files: ./bazel-out/_coverage/_coverage_report.dat - license-header: runs-on: ubuntu-latest steps: @@ -106,4 +97,3 @@ jobs: run: | go get -u github.com/google/addlicense addlicense -c "Google LLC" -l apache -check $(find $PWD -type f -name '*.java' ! -iname '*PlaceholderFile.java') - diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh index 2a415b8d92..8266917574 100755 --- a/ad-hoc-compile-proto-files.sh +++ b/ad-hoc-compile-proto-files.sh @@ -16,7 +16,7 @@ set -o errexit # - pubsub.proto (v2) # - logging.proto (v1) # -# 3. local testdata .protos in src/test/java/com/google/api/generator/gapic/testdata: +# 3. local test resource .protos in src/test/resources: # - deprecated_service: deprecated_service.proto # - bookshop: bookshop.proto # - showcase: compliance.proto, echo.proto, identity.proto, testing.proto and messaging.proto @@ -26,29 +26,25 @@ set -o errexit # - explicit_dynamic_routing_header_testing.proto # # -# In addition to this, there is one special .proto in testdata that doesn't -# require compiled Java library but .descriptor generated by the protobuf -# copmiler: basic.proto -# -# Currently, the Bazel target runs the following command to gerenrate this: +# In addition to this, there is one special .proto in test resources that +# doesn't require compiled Java library but .descriptor generated by the +# protobuf copmiler: basic.proto. Currently, the Bazel target runs the +# following command to gerenrate this: # protoc --include_source_info --include_imports --descriptor_set_out=basic_proto.descriptor basic.proto -bazel build :service_config_java_proto :test_java_protos :basic_proto_descriptor +bazel build :service_config_java_proto :test_java_protos :basic_proto_descriptor \ + @com_google_googleapis//gapic/metadata:metadata_java_proto \ + @com_google_googleapis//google/logging/v2:logging_java_proto \ + @com_google_googleapis//google/pubsub/v1:pubsub_java_proto function install_jar { - mvn install:install-file -DgroupId=$1 -DartifactId=$2 -Dfile=$3 -Dversion=0.0.0 -Dpackaging=jar + mvn install:install-file -Dfile=$1 -DgroupId=$2 -DartifactId=$3 -Dversion=0.0.0 -Dpackaging=jar } -install_jar io.grpc serviceconfig-proto \ - bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar -install_jar com.google.api metadata-proto \ - bazel-bin/external/com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar -install_jar com.google.api common-resources-proto \ - bazel-bin/external/com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar -install_jar com.google.api pubsub-proto \ - bazel-bin/external/com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar -install_jar com.google.api logging-proto \ - bazel-bin/external/com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar -install_jar com.google.api gapic-generator-test-protos \ - bazel-bin/libtest_protos-speed.jar +install_jar bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar io.grpc serviceconfig-proto +install_jar bazel-bin/external/com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar com.google.api metadata-proto +install_jar bazel-bin/external/com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar com.google.api common-resources-proto +install_jar bazel-bin/external/com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar com.google.api pubsub-proto +install_jar bazel-bin/external/com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar com.google.api logging-proto +install_jar bazel-bin/libtest_protos-speed.jar com.google.api gapic-generator-test-protos From 9bee68712a2d706bf7702e7f527ed89ca93a1d69 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 12:14:20 -0500 Subject: [PATCH 14/73] chore: update SubscriberClientTest.golden --- .../composer/grpc/goldens/SubscriberClientTest.golden | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden index d9a1215708..62467289ae 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden @@ -88,7 +88,6 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) - .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -148,7 +147,6 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) - .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -208,7 +206,6 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) - .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -268,7 +265,6 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) - .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -328,7 +324,6 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) - .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -378,7 +373,6 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) - .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -428,7 +422,6 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) - .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -946,10 +939,6 @@ public class SubscriberClientTest { StreamingPullResponse expectedResponse = StreamingPullResponse.newBuilder() .addAllReceivedMessages(new ArrayList()) - .setAcknowlegeConfirmation( - StreamingPullResponse.AcknowledgeConfirmation.newBuilder().build()) - .setModifyAckDeadlineConfirmation( - StreamingPullResponse.ModifyAckDeadlineConfirmation.newBuilder().build()) .setSubscriptionProperties( StreamingPullResponse.SubscriptionProperties.newBuilder().build()) .build(); From 2ce3410ed11b2903aaf49c387ef98ede363a5b17 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 12:38:54 -0500 Subject: [PATCH 15/73] chore: migrate format --- .githooks/pre-commit | 4 ++-- .github/workflows/ci.yaml | 2 +- DEVELOPMENT.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 4f64914be7..8f63a2c40a 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -83,11 +83,11 @@ fi if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] then echo_status "Running Java linter..." - bazel --batch run --disk_cache="$BAZEL_CACHE_DIR" //:google_java_format_verification + mvn fmt:check FORMAT_STATUS=$? if [ $FORMAT_STATUS != 0 ] then - echo_error "Linting failed." "Please run :google_java_format and try again." + echo_error "Linting failed." "Please run mvn fmt:format try again." exit 1 fi fi diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index caad414a31..65607e15ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -84,7 +84,7 @@ jobs: retention-days: 5 - name: Java Linter - run: bazel --batch run //:google_java_format_verification + run: mvn fmt:check license-header: runs-on: ubuntu-latest diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 16caa1c66d..741d30e7d5 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -90,13 +90,13 @@ - Run linter checks without actually doing the formatting. ```sh - bazel run //:google_java_format_verification + mvn fmt:check ``` - Format files. ```sh - bazel run //:google_java_format + mvn fmt:format ``` ## Test Running From 6e5785e7bcc79adffa31217d8c9e9d92d7b3cad1 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 12:45:44 -0500 Subject: [PATCH 16/73] chore: wip --- WORKSPACE | 4 ++-- .../composer/grpc/goldens/SubscriberClientTest.golden | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index b8230763b7..7be21658d7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -42,8 +42,8 @@ com_google_api_gax_java_repositories() http_archive( name = "com_google_googleapis", - urls = ["https://github.com/googleapis/googleapis/archive/0899ba0f4c053a4487ccf0b699df5f850e39a45f.zip"], - strip_prefix = "googleapis-0899ba0f4c053a4487ccf0b699df5f850e39a45f", + urls = ["https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip"], + strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c", ) http_archive( diff --git a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden index 62467289ae..d9a1215708 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/SubscriberClientTest.golden @@ -88,6 +88,7 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) + .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -147,6 +148,7 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) + .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -206,6 +208,7 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) + .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -265,6 +268,7 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) + .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -324,6 +328,7 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) + .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -373,6 +378,7 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) + .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -422,6 +428,7 @@ public class SubscriberClientTest { .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) .setRetryPolicy(RetryPolicy.newBuilder().build()) .setDetached(true) + .setEnableExactlyOnceDelivery(true) .build(); mockSubscriber.addResponse(expectedResponse); @@ -939,6 +946,10 @@ public class SubscriberClientTest { StreamingPullResponse expectedResponse = StreamingPullResponse.newBuilder() .addAllReceivedMessages(new ArrayList()) + .setAcknowlegeConfirmation( + StreamingPullResponse.AcknowledgeConfirmation.newBuilder().build()) + .setModifyAckDeadlineConfirmation( + StreamingPullResponse.ModifyAckDeadlineConfirmation.newBuilder().build()) .setSubscriptionProperties( StreamingPullResponse.SubscriptionProperties.newBuilder().build()) .build(); From f617dc288e69181f39667f13e714ddcfe9287b38 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 12:49:47 -0500 Subject: [PATCH 17/73] chore: wip --- ad-hoc-compile-proto-files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh index 8266917574..be423e3683 100755 --- a/ad-hoc-compile-proto-files.sh +++ b/ad-hoc-compile-proto-files.sh @@ -38,7 +38,7 @@ bazel build :service_config_java_proto :test_java_protos :basic_proto_descriptor @com_google_googleapis//google/logging/v2:logging_java_proto \ @com_google_googleapis//google/pubsub/v1:pubsub_java_proto -function install_jar { +install_jar() { mvn install:install-file -Dfile=$1 -DgroupId=$2 -DartifactId=$3 -Dversion=0.0.0 -Dpackaging=jar } From 024e0fd68d58d65ee2b6d462368569c26a599069 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 13:37:41 -0500 Subject: [PATCH 18/73] chore: add javax.annotation-api for Java 11 build --- ad-hoc-compile-proto-files.sh | 5 +++-- pom.xml | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh index be423e3683..648386cd3f 100755 --- a/ad-hoc-compile-proto-files.sh +++ b/ad-hoc-compile-proto-files.sh @@ -33,13 +33,14 @@ set -o errexit # protoc --include_source_info --include_imports --descriptor_set_out=basic_proto.descriptor basic.proto -bazel build :service_config_java_proto :test_java_protos :basic_proto_descriptor \ +bazel --batch build :service_config_java_proto :test_java_protos :basic_proto_descriptor \ @com_google_googleapis//gapic/metadata:metadata_java_proto \ @com_google_googleapis//google/logging/v2:logging_java_proto \ @com_google_googleapis//google/pubsub/v1:pubsub_java_proto install_jar() { - mvn install:install-file -Dfile=$1 -DgroupId=$2 -DartifactId=$3 -Dversion=0.0.0 -Dpackaging=jar + mvn install:install-file -Dfile=$1 -DgroupId=$2 -DartifactId=$3 -Dversion=0.0.0 -Dpackaging=jar \ + --batch-mode --no-transfer-progress } install_jar bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar io.grpc serviceconfig-proto diff --git a/pom.xml b/pom.xml index 3c5e7c9658..50b76da41a 100644 --- a/pom.xml +++ b/pom.xml @@ -137,6 +137,16 @@ 1.7 + + + javax.annotation + javax.annotation-api + 1.3.2 + + junit junit From 45d68ebb731efbbc0c29d46c03adfc34466ce890 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 17:40:01 -0500 Subject: [PATCH 19/73] chore: re-work Bazel build infrastructure --- .github/workflows/ci.yaml | 25 + BUILD.bazel | 177 +++++- DEVELOPMENT.md | 27 +- PROPERTIES.bzl | 31 + WORKSPACE | 30 +- ad-hoc-compile-proto-files.sh | 44 +- pom.xml | 52 +- repositories.bzl | 96 +++ src/main/proto/service_config.proto | 594 ++++++++++++++++++ .../protoparser/SourceCodeInfoParserTest.java | 31 +- .../api/generator/test/framework/Utils.java | 11 +- .../bad_message_resname_def.proto | 0 src/test/{resources => proto}/basic.proto | 0 src/test/{resources => proto}/bookshop.proto | 0 .../{resources => proto}/compliance.proto | 0 .../deprecated_service.proto | 0 src/test/{resources => proto}/echo.proto | 0 ...licit_dynamic_routing_header_testing.proto | 0 src/test/{resources => proto}/identity.proto | 0 src/test/{resources => proto}/locker.proto | 0 src/test/{resources => proto}/messaging.proto | 0 .../{resources => proto}/nested_message.proto | 0 .../routing_rule_parser_testing.proto | 0 src/test/{resources => proto}/testing.proto | 0 24 files changed, 1024 insertions(+), 94 deletions(-) create mode 100644 PROPERTIES.bzl create mode 100644 repositories.bzl create mode 100644 src/main/proto/service_config.proto rename src/test/{resources => proto}/bad_message_resname_def.proto (100%) rename src/test/{resources => proto}/basic.proto (100%) rename src/test/{resources => proto}/bookshop.proto (100%) rename src/test/{resources => proto}/compliance.proto (100%) rename src/test/{resources => proto}/deprecated_service.proto (100%) rename src/test/{resources => proto}/echo.proto (100%) rename src/test/{resources => proto}/explicit_dynamic_routing_header_testing.proto (100%) rename src/test/{resources => proto}/identity.proto (100%) rename src/test/{resources => proto}/locker.proto (100%) rename src/test/{resources => proto}/messaging.proto (100%) rename src/test/{resources => proto}/nested_message.proto (100%) rename src/test/{resources => proto}/routing_rule_parser_testing.proto (100%) rename src/test/{resources => proto}/testing.proto (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 65607e15ae..968027e42c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,6 +49,9 @@ jobs: echo "The old one will disappear after 7 days." - name: Unit Tests + run: bazel --batch test //:units --noshow_progress --test_output=errors + + - name: Unit Tests (Maven) run: | ./ad-hoc-compile-proto-files.sh mvn verify --batch-mode --no-transfer-progress @@ -84,8 +87,30 @@ jobs: retention-days: 5 - name: Java Linter + run: bazel --batch run //:google_java_format_verification + + - name: Java Linter (Maven) run: mvn fmt:check + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + java-version: 8 + - run: java -version + + - name: Generate Code Coverage Report + # Run only test targets, and not golden_update targets. + run: bazel coverage //:units --combined_report=lcov + + - name: Upload Code Coverage Report + uses: codecov/codecov-action@v2 + with: + name: actions ${{ matrix.java }} + files: ./bazel-out/_coverage/_coverage_report.dat + license-header: runs-on: ubuntu-latest steps: diff --git a/BUILD.bazel b/BUILD.bazel index ff63efb371..9b9ff37e71 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -2,14 +2,69 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_proto_library") package(default_visibility = ["//visibility:public"]) +# TODO: some dependencies may be runtime only. +MAIN_DEPS = [ + ":service_config_java_proto", + "@com_google_api_api_common//jar", + "@com_google_api_gax_java//gax", + "@com_google_api_gax_java//gax:gax_testlib", + "@com_google_api_gax_java//gax-grpc:gax_grpc", + "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", + "@com_google_api_gax_java//gax-httpjson:gax_httpjson", + "@com_google_api_gax_java//gax-httpjson:gax_httpjson_testlib", + "@com_google_api_grpc_proto_google_common_protos", + "@com_google_auto_value_auto_value_annotations//jar", # Ideally should be compile-time only, but this is OK. + "@com_google_code_gson//jar", + "@com_google_googleapis//gapic/metadata:metadata_java_proto", + "@com_google_guava_guava", + "@com_google_http_client_google_http_client//jar", + "@com_google_protobuf//:protobuf_java", + "@com_google_protobuf//:protobuf_java_util", + "@google_java_format_all_deps//jar", + "@io_grpc_grpc_java//api", + "@io_grpc_grpc_java//protobuf", + "@io_grpc_grpc_java//stub", + "@javax_annotation_javax_annotation_api//jar", + "@junit_junit//jar", + "@org_threeten_threetenbp//jar", + "@org_yaml_snakeyaml//jar", +] + +MAIN_DEPS_DEBUG_RUNTIME_ONLY = [ + "@com_google_googleapis//google/api:api_java_proto", + "@com_google_googleapis//google/cloud:extended_operations_java_proto", + "@com_google_googleapis//google/longrunning:longrunning_java_proto", + "@com_google_protobuf//java/core", +] + +# Some dependencies are runtime only, but that's fine for tests. +TEST_DEPS = [ + ":test_java_protos", + "@com_google_googleapis//google/logging/v2:logging_java_proto", + "@com_google_googleapis//google/pubsub/v1:pubsub_java_proto", + "@com_google_googleapis//google/rpc:rpc_java_proto", + "@com_google_truth_truth//jar", + "@io_github_java_diff_utils//jar", +] + +proto_library( + name = "service_config_proto", + srcs = ["src/main/proto/service_config.proto"], + deps = [ + "@com_google_googleapis//google/rpc:code_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:wrappers_proto", + "@com_google_protobuf//:struct_proto", + ], +) java_proto_library( name = "service_config_java_proto", - deps = ["@io_grpc_proto//:service_config_proto"], + deps = [":service_config_proto"], ) proto_library( name = "test_protos", - srcs = glob(["src/test/resources/*.proto"]), + srcs = glob(["src/test/proto/*.proto"]), deps = [ "@com_google_googleapis//google/api:annotations_proto", "@com_google_googleapis//google/api:client_proto", @@ -34,27 +89,21 @@ java_proto_library( ], ) -# another test resource -genrule( - name = "basic_proto_descriptor", - srcs = ["src/test/resources/basic.proto"], - outs = ["basic_proto.descriptor"], - cmd = "$(location @com_google_protobuf//:protoc) " + - "--include_source_info --include_imports --descriptor_set_out=$(OUTS) $(SRCS)", - message = "Generating proto descriptor", - tools = ["@com_google_protobuf//:protoc"], +java_plugin( + name = "autovalue_plugin", + processor_class = "com.google.auto.value.processor.AutoValueProcessor", + deps = ["@com_google_auto_value_auto_value//jar"], ) - -java_import( - name = "gapic_generator_java", - # Note referring to target/ is only for local development; you can also pull from remote - # filesystem, GCS bucket, Maven repositories, etc. - jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], +java_library( + name = "gapic-generator-java", + srcs = glob(["src/main/java/**/*.java"]), + plugins = [":autovalue_plugin"], + deps = MAIN_DEPS, ) java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", - runtime_deps = ["gapic_generator_java"] + runtime_deps = [":gapic-generator-java"] + MAIN_DEPS, ) # Request dumper binary, which dumps the CodeGeneratorRequest to a file on disk @@ -76,7 +125,7 @@ java_binary( java_binary( name = "protoc-gen-code_generator_request_dumper", main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper", - runtime_deps = ["gapic_generator_java"], + runtime_deps = [":gapic-generator-java"] + MAIN_DEPS + MAIN_DEPS_DEBUG_RUNTIME_ONLY, ) # A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest @@ -89,8 +138,76 @@ java_binary( java_binary( name = "code_generator_request_file_to_gapic_main", main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", - runtime_deps = ["gapic_generator_java"], + runtime_deps = [":gapic-generator-java"] + MAIN_DEPS + MAIN_DEPS_DEBUG_RUNTIME_ONLY, +) + +# another test resource +genrule( + name = "basic_proto_descriptor", + srcs = ["src/test/proto/basic.proto"], + outs = ["test-proto.descriptorset"], + cmd = "$(location @com_google_protobuf//:protoc) " + + "--include_source_info --include_imports --descriptor_set_out=$(OUTS) $(SRCS)", + message = "Generating proto descriptor", + tools = ["@com_google_protobuf//:protoc"], +) + +# Unit tests. Run each test with, e.g., +# bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest +java_library( + name = "gapic-generator-java-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [":gapic-generator-java"] + MAIN_DEPS + TEST_DEPS, ) +[java_test( + name = "unit_" + file[14:-5].replace('/', '_'), + test_class = file[14:-5].replace('/', '.'), + runtime_deps = [":gapic-generator-java", ":gapic-generator-java-test"] + MAIN_DEPS + TEST_DEPS, + data = [":basic_proto_descriptor"] + glob([ + "src/test/java/**/*.golden", + "src/test/resources/**", + ]), + tags = ["small"], +) for file in glob(["src/test/java/**/*Test.java"])] + +test_suite(name = "units", tags = ["small"]) + +# Tests that generate and save unit golden (.golden) files. +GOLDEN_UPDATING_UNIT_TESTS = [ + "com.google.api.generator.engine.JavaCodeGeneratorTest", + "com.google.api.generator.gapic.composer.ComposerTest", + "com.google.api.generator.gapic.composer.common.BatchingDescriptorComposerTest", + "com.google.api.generator.gapic.composer.grpc.GrpcServiceCallableFactoryClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.GrpcServiceStubClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.MockServiceClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.MockServiceImplClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.ServiceClientClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.ServiceClientTestClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.ServiceSettingsClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.ServiceStubClassComposerTest", + "com.google.api.generator.gapic.composer.grpc.ServiceStubSettingsClassComposerTest", + "com.google.api.generator.gapic.composer.resourcename.ResourceNameHelperClassComposerTest", + "com.google.api.generator.gapic.composer.rest.HttpJsonServiceCallableFactoryClassComposerTest", + "com.google.api.generator.gapic.composer.rest.HttpJsonServiceStubClassComposerTest", + "com.google.api.generator.gapic.composer.rest.ServiceClientTestClassComposerTest", + "com.google.api.generator.gapic.composer.rest.ServiceSettingsClassComposerTest", + "com.google.api.generator.gapic.composer.rest.ServiceStubSettingsClassComposerTest", +] + +# Manually runs a single JUnit test for the tests that generate and save .golden +# files. To update .golden files, run with, e.g., +# bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest +[java_binary( + name = "update_%s" % test_class.replace('.', '_'), + srcs = glob(["src/test/java/**/*.java"]), + main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", + args = [test_class], + deps = [":protoc-gen-java_gapic"] + MAIN_DEPS + TEST_DEPS, + data = glob([ + "src/test/java/**/*.golden", + "src/test/resources/**", + ]), +) for test_class in GOLDEN_UPDATING_UNIT_TESTS] # google-java-format java_binary( @@ -99,3 +216,23 @@ java_binary( main_class = "com.google.googlejavaformat.java.Main", runtime_deps = ["@google_java_format_all_deps//jar"], ) + +genrule( + name = "google_java_format", + outs = ["google_java_format.sh"], + cmd = "echo 'find src test -name \'*.java\' | grep -v /goldens/ | xargs $(execpath :google_java_format_binary) --replace' > $(OUTS)", + executable = 1, + tools = [":google_java_format_binary"], + local = 1, +) + +# Run `bazel build //:google_java_format_verification` to verify that gapic-generator-java sources +# are formatted correctly. +genrule( + name = "google_java_format_verification", + outs = ["google_java_format_verification.sh"], + cmd = "echo 'find src test -name \'*.java\' | grep -v /goldens/ | xargs $(execpath :google_java_format_binary) --dry-run --set-exit-if-changed' > $(OUTS)", + executable = 1, + tools = [":google_java_format_binary"], + local = 1, +) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 741d30e7d5..17bab368bb 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -89,12 +89,20 @@ - Run linter checks without actually doing the formatting. + ```sh + bazel run //:google_java_format_verification + ``` + or ```sh mvn fmt:check ``` - Format files. + ```sh + bazel run //:google_java_format + ``` + or ```sh mvn fmt:format ``` @@ -104,16 +112,31 @@ - Run all unit and integration tests. ```sh - mvn test # unit tests - bazel test //... # integration tests + bazel test //... ``` - Run all unit tests. + ```sh + bazel test //:units + ``` + or ```sh mvn test ``` +- Run a single unit test like `JavaCodeGeneratorTest.java`: + + ```sh + bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest + ``` + +- Update unit test golden files, for example `JavaCodeGeneratorTest.java`: + + ```sh + bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest + ``` + - Update unit test golden files: ```sh diff --git a/PROPERTIES.bzl b/PROPERTIES.bzl new file mode 100644 index 0000000000..8abf2dd26f --- /dev/null +++ b/PROPERTIES.bzl @@ -0,0 +1,31 @@ +PROPERTIES = { + "version.com_google_protobuf": "3.19.1", + # Version of google-java-format is downgraded from 1.8 to 1.7, because 1.8 supports java 11 minimum, while our JRE is java 8. + "version.google_java_format": "1.7", + "version.io_grpc_java": "1.42.1", + + # Common deps. + "maven.com_google_guava_guava": "com.google.guava:guava:30.1-android", + "maven.com_google_code_findbugs_jsr305": "com.google.code.findbugs:jsr305:3.0.0", + "maven.com_google_auto_value_auto_value": "com.google.auto.value:auto-value:1.7.2", + "maven.com_google_auto_value_auto_value_annotations": "com.google.auto.value:auto-value-annotations:1.7.2", + "maven.com_google_code_gson": "com.google.code.gson:gson:2.8.6", + "maven.com_google_protobuf_protobuf_java": "com.google.protobuf:protobuf-java:3.19.1", + "maven.io_github_java_diff_utils": "io.github.java-diff-utils:java-diff-utils:4.0", + "maven.javax_annotation_javax_annotation_api": "javax.annotation:javax.annotation-api:1.3.2", + + # Gapic YAML parsing for batching settings. + "maven.org_yaml_snakeyaml": "org.yaml:snakeyaml:1.26", + + # ServiceStubSettings class. Used only in generated code. + "maven.org_threeten_threetenbp": "org.threeten:threetenbp:1.3.3", + + # Testing. + "maven.junit_junit": "junit:junit:4.13.1", + # This hamcrest-core dependency is for running JUnit test manually, before JUnit 4.11 it's wrapped along with JUnit package. + # But now it has to be explicitly added. + "maven.org_hamcrest_hamcrest_core": "org.hamcrest:hamcrest-core:1.3", + "maven.org_mockito_mockito_core": "org.mockito:mockito-core:2.21.0", + # Keep in sync with gax-java. + "maven.com_google_truth_truth": "com.google.truth:truth:1.1.2", +} diff --git a/WORKSPACE b/WORKSPACE index 7be21658d7..22744a67eb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,6 +3,18 @@ workspace(name = "gapic_generator_java") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") +# DO NOT REMOVE. +# This is needed to clobber any transitively-pulled in versions of bazel_skylib so that packages +# like protobuf will build. +http_archive( + name = "bazel_skylib", + sha256 = "af87959afe497dc8dfd4c6cb66e1279cb98ccc84284619ebfec27d9c09a903de", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz", + ], +) + jvm_maven_import_external( name = "google_java_format_all_deps", artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:1.7", @@ -40,18 +52,9 @@ load("@com_google_api_gax_java//:repositories.bzl", "com_google_api_gax_java_rep com_google_api_gax_java_repositories() -http_archive( - name = "com_google_googleapis", - urls = ["https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip"], - strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c", -) +load("//:repositories.bzl", "gapic_generator_java_repositories") -http_archive( - name = "io_grpc_proto", - # Nov. 6, 2021. - urls = ["https://github.com/grpc/grpc-proto/archive/8e3fec8612bc0708e857950dccadfd5063703e04.zip"], - strip_prefix = "grpc-proto-8e3fec8612bc0708e857950dccadfd5063703e04", -) +gapic_generator_java_repositories() # protobuf RULES_JVM_EXTERNAL_TAG = "4.2" @@ -70,7 +73,10 @@ load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = PROTOBUF_MAVEN_ARTIFACTS, - repositories = ["https://repo.maven.apache.org/maven2/"], + generate_compat_repositories = True, + repositories = [ + "https://repo.maven.apache.org/maven2/", + ], ) protobuf_deps() diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh index 648386cd3f..aaf44debad 100755 --- a/ad-hoc-compile-proto-files.sh +++ b/ad-hoc-compile-proto-files.sh @@ -6,46 +6,22 @@ set -o errexit # anywhere, so currently, we need to build them using `java_proto_library()` to # generate .jar files. # -# Most of these are needed only for compiling test source files. -# -# 1. from grpc/grpc-proto: service_config.proto -# -# 2. from googleapis/googleapis: -# - gapic_metadata.proto -# - common_resources.proto -# - pubsub.proto (v2) -# - logging.proto (v1) -# -# 3. local test resource .protos in src/test/resources: -# - deprecated_service: deprecated_service.proto -# - bookshop: bookshop.proto -# - showcase: compliance.proto, echo.proto, identity.proto, testing.proto and messaging.proto -# - testgapic: bad_message_resname_def.proto, locker.proto, and nested_message.proto -# - explicit_dynamic_routing_headers_testing: -# - routing_rule_parser_testing.proto -# - explicit_dynamic_routing_header_testing.proto -# -# -# In addition to this, there is one special .proto in test resources that -# doesn't require compiled Java library but .descriptor generated by the -# protobuf copmiler: basic.proto. Currently, the Bazel target runs the -# following command to gerenrate this: -# protoc --include_source_info --include_imports --descriptor_set_out=basic_proto.descriptor basic.proto - +# gapic_metadata.proto +# common_resources.proto +# pubsub.proto (v2) +# logging.proto (v1) -bazel --batch build :service_config_java_proto :test_java_protos :basic_proto_descriptor \ +bazel --batch build \ @com_google_googleapis//gapic/metadata:metadata_java_proto \ @com_google_googleapis//google/logging/v2:logging_java_proto \ @com_google_googleapis//google/pubsub/v1:pubsub_java_proto install_jar() { - mvn install:install-file -Dfile=$1 -DgroupId=$2 -DartifactId=$3 -Dversion=0.0.0 -Dpackaging=jar \ + mvn install:install-file -Dfile=bazel-bin/external/$1 -DgroupId=$2 -DartifactId=$3 -Dversion=0.0.0 -Dpackaging=jar \ --batch-mode --no-transfer-progress } -install_jar bazel-bin/external/io_grpc_proto/libservice_config_proto-speed.jar io.grpc serviceconfig-proto -install_jar bazel-bin/external/com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar com.google.api metadata-proto -install_jar bazel-bin/external/com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar com.google.api common-resources-proto -install_jar bazel-bin/external/com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar com.google.api pubsub-proto -install_jar bazel-bin/external/com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar com.google.api logging-proto -install_jar bazel-bin/libtest_protos-speed.jar com.google.api gapic-generator-test-protos +install_jar com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar com.google.api metadata-proto +install_jar com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar com.google.api common-resources-proto +install_jar com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar com.google.api pubsub-proto +install_jar com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar com.google.api logging-proto diff --git a/pom.xml b/pom.xml index 50b76da41a..526ac9b2cf 100644 --- a/pom.xml +++ b/pom.xml @@ -25,11 +25,50 @@ + com.coveo fmt-maven-plugin 2.9.1 + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + + protobuf-compile + + compile + + + + protobuf-test-compile + + test-compile + + + true + true + true + test-proto.descriptor + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + ${project.build.directory}/generated-test-resources/protobuf/descriptor-sets/ + + + + org.apache.maven.plugins maven-shade-plugin @@ -167,12 +206,6 @@ test - - io.grpc - serviceconfig-proto - 0.0.0 - - com.google.api metadata-proto @@ -200,12 +233,5 @@ test - - com.google.api - gapic-generator-test-protos - 0.0.0 - test - - diff --git a/repositories.bzl b/repositories.bzl new file mode 100644 index 0000000000..1c3a14f637 --- /dev/null +++ b/repositories.bzl @@ -0,0 +1,96 @@ +# Copyright 2019 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. + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") +load("//:PROPERTIES.bzl", "PROPERTIES") + +def gapic_generator_java_repositories(): + # Import dependencies shared between Gradle and Bazel (i.e. maven dependencies) + for name, artifact in PROPERTIES.items(): + _maybe( + jvm_maven_import_external, + name = name, + strip_repo_prefix = "maven.", + artifact = _fix_bazel_artifact_format(artifact), + server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"], + licenses = ["notice", "reciprocal"], + ) + + # Import Bazel-only dependencies (Gradle version will import maven artifacts of same + # version, while Bazel will depend on Bazel workspaces). The versions are shared in the + # properties file. + _protobuf_version = PROPERTIES["version.com_google_protobuf"] + _maybe( + http_archive, + name = "com_google_protobuf", + urls = ["https://github.com/protocolbuffers/protobuf/archive/v%s.zip" % _protobuf_version], + strip_prefix = "protobuf-%s" % _protobuf_version, + ) + + _maybe( + jvm_maven_import_external, + name = "google_java_format_all_deps", + artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:%s" % PROPERTIES["version.google_java_format"], + server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"], + licenses = ["notice", "reciprocal"], + ) + + _maybe( + http_archive, + name = "bazel_skylib", + sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d", + strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b", + urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"], + ) + + _maybe( + http_archive, + name = "com_google_googleapis", + strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c", + urls = [ + "https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip", + ], + ) + + _maybe( + native.bind, + name = "guava", + actual = "@com_google_guava_guava//jar", + ) + + _maybe( + native.bind, + name = "gson", + actual = "@com_google_code_gson_gson//jar", + ) + +def _maybe(repo_rule, name, strip_repo_prefix = "", **kwargs): + if not name.startswith(strip_repo_prefix): + return + repo_name = name[len(strip_repo_prefix):] + if repo_name in native.existing_rules(): + return + repo_rule(name = repo_name, **kwargs) + +def _fix_bazel_artifact_format(artifact_id): + # Fix the artifact id format discrepancy between Bazel & Gradle. + # This is relevant only when classifier is specified explicitly. + # Bazel format: groupId:artifactId:jar:classifier:version + # Gradle format: groupId:artifactId:version:classifier + ids = artifact_id.split(":") + if len(ids) != 4: + return artifact_id + return "%s:%s:%s:%s:%s" % (ids[0], ids[1], "jar", ids[3], ids[2]) diff --git a/src/main/proto/service_config.proto b/src/main/proto/service_config.proto new file mode 100644 index 0000000000..286ee65c74 --- /dev/null +++ b/src/main/proto/service_config.proto @@ -0,0 +1,594 @@ +// Copyright 2016 The gRPC Authors +// +// 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. + +// A ServiceConfig is supplied when a service is deployed. It mostly contains +// parameters for how clients that connect to the service should behave (for +// example, the load balancing policy to use to pick between service replicas). +// +// The configuration options provided here act as overrides to automatically +// chosen option values. Service owners should be conservative in specifying +// options as the system is likely to choose better values for these options in +// the vast majority of cases. In other words, please specify a configuration +// option only if you really have to, and avoid copy-paste inclusion of configs. +// +// Note that gRPC uses the service config in JSON form, not in protobuf +// form. This proto definition is intended to help document the schema but +// will not actually be used directly by gRPC. + +syntax = "proto3"; + +package grpc.service_config; + +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/wrappers.proto"; +import "google/rpc/code.proto"; + +option java_package = "io.grpc.serviceconfig"; +option java_multiple_files = true; +option java_outer_classname = "ServiceConfigProto"; + +// Configuration for a method. +message MethodConfig { + // The names of the methods to which this configuration applies. + // - MethodConfig without names (empty list) will be skipped. + // - Each name entry must be unique across the entire ServiceConfig. + // - If the 'method' field is empty, this MethodConfig specifies the defaults + // for all methods for the specified service. + // - If the 'service' field is empty, the 'method' field must be empty, and + // this MethodConfig specifies the default for all methods (it's the default + // config). + // + // When determining which MethodConfig to use for a given RPC, the most + // specific match wins. For example, let's say that the service config + // contains the following MethodConfig entries: + // + // method_config { name { } ... } + // method_config { name { service: "MyService" } ... } + // method_config { name { service: "MyService" method: "Foo" } ... } + // + // MyService/Foo will use the third entry, because it exactly matches the + // service and method name. MyService/Bar will use the second entry, because + // it provides the default for all methods of MyService. AnotherService/Baz + // will use the first entry, because it doesn't match the other two. + // + // In JSON representation, value "", value `null`, and not present are the + // same. The following are the same Name: + // - { "service": "s" } + // - { "service": "s", "method": null } + // - { "service": "s", "method": "" } + message Name { + string service = 1; // Required. Includes proto package name. + string method = 2; + } + repeated Name name = 1; + + // Whether RPCs sent to this method should wait until the connection is + // ready by default. If false, the RPC will abort immediately if there is + // a transient failure connecting to the server. Otherwise, gRPC will + // attempt to connect until the deadline is exceeded. + // + // The value specified via the gRPC client API will override the value + // set here. However, note that setting the value in the client API will + // also affect transient errors encountered during name resolution, which + // cannot be caught by the value here, since the service config is + // obtained by the gRPC client via name resolution. + google.protobuf.BoolValue wait_for_ready = 2; + + // The default timeout in seconds for RPCs sent to this method. This can be + // overridden in code. If no reply is received in the specified amount of + // time, the request is aborted and a DEADLINE_EXCEEDED error status + // is returned to the caller. + // + // The actual deadline used will be the minimum of the value specified here + // and the value set by the application via the gRPC client API. If either + // one is not set, then the other will be used. If neither is set, then the + // request has no deadline. + google.protobuf.Duration timeout = 3; + + // The maximum allowed payload size for an individual request or object in a + // stream (client->server) in bytes. The size which is measured is the + // serialized payload after per-message compression (but before stream + // compression) in bytes. This applies both to streaming and non-streaming + // requests. + // + // The actual value used is the minimum of the value specified here and the + // value set by the application via the gRPC client API. If either one is + // not set, then the other will be used. If neither is set, then the + // built-in default is used. + // + // If a client attempts to send an object larger than this value, it will not + // be sent and the client will see a ClientError. + // Note that 0 is a valid value, meaning that the request message + // must be empty. + google.protobuf.UInt32Value max_request_message_bytes = 4; + + // The maximum allowed payload size for an individual response or object in a + // stream (server->client) in bytes. The size which is measured is the + // serialized payload after per-message compression (but before stream + // compression) in bytes. This applies both to streaming and non-streaming + // requests. + // + // The actual value used is the minimum of the value specified here and the + // value set by the application via the gRPC client API. If either one is + // not set, then the other will be used. If neither is set, then the + // built-in default is used. + // + // If a server attempts to send an object larger than this value, it will not + // be sent, and a ServerError will be sent to the client instead. + // Note that 0 is a valid value, meaning that the response message + // must be empty. + google.protobuf.UInt32Value max_response_message_bytes = 5; + + // The retry policy for outgoing RPCs. + message RetryPolicy { + // The maximum number of RPC attempts, including the original attempt. + // + // This field is required and must be greater than 1. + // Any value greater than 5 will be treated as if it were 5. + uint32 max_attempts = 1; + + // Exponential backoff parameters. The initial retry attempt will occur at + // random(0, initial_backoff). In general, the nth attempt will occur at + // random(0, + // min(initial_backoff*backoff_multiplier**(n-1), max_backoff)). + // Required. Must be greater than zero. + google.protobuf.Duration initial_backoff = 2; + // Required. Must be greater than zero. + google.protobuf.Duration max_backoff = 3; + float backoff_multiplier = 4; // Required. Must be greater than zero. + + // The set of status codes which may be retried. + // + // This field is required and must be non-empty. + repeated google.rpc.Code retryable_status_codes = 5; + } + + // The hedging policy for outgoing RPCs. Hedged RPCs may execute more than + // once on the server, so only idempotent methods should specify a hedging + // policy. + message HedgingPolicy { + // The hedging policy will send up to max_requests RPCs. + // This number represents the total number of all attempts, including + // the original attempt. + // + // This field is required and must be greater than 1. + // Any value greater than 5 will be treated as if it were 5. + uint32 max_attempts = 1; + + // The first RPC will be sent immediately, but the max_requests-1 subsequent + // hedged RPCs will be sent at intervals of every hedging_delay. Set this + // to 0 to immediately send all max_requests RPCs. + google.protobuf.Duration hedging_delay = 2; + + // The set of status codes which indicate other hedged RPCs may still + // succeed. If a non-fatal status code is returned by the server, hedged + // RPCs will continue. Otherwise, outstanding requests will be canceled and + // the error returned to the client application layer. + // + // This field is optional. + repeated google.rpc.Code non_fatal_status_codes = 3; + } + + // Only one of retry_policy or hedging_policy may be set. If neither is set, + // RPCs will not be retried or hedged. + oneof retry_or_hedging_policy { + RetryPolicy retry_policy = 6; + HedgingPolicy hedging_policy = 7; + } +} + +// Configuration for pick_first LB policy. +message PickFirstConfig {} + +// Configuration for round_robin LB policy. +message RoundRobinConfig {} + +// Configuration for grpclb LB policy. +message GrpcLbConfig { + // Optional. What LB policy to use for routing between the backend + // addresses. If unset, defaults to round_robin. + // Currently, the only supported values are round_robin and pick_first. + // Note that this will be used both in balancer mode and in fallback mode. + // Multiple LB policies can be specified; clients will iterate through + // the list in order and stop at the first policy that they support. + repeated LoadBalancingConfig child_policy = 1; + // Optional. If specified, overrides the name of the service to be sent to + // the balancer. + string service_name = 2; +} + +// Configuration for priority LB policy. +message PriorityLoadBalancingPolicyConfig { + // A map of name to child policy configuration. + // The names are used to allow the priority policy to update + // existing child policies instead of creating new ones every + // time it receives a config update. + message Child { + repeated LoadBalancingConfig config = 1; + + // If true, will ignore reresolution requests from this child. + bool ignore_reresolution_requests = 2; + } + map children = 1; + + // A list of child names in decreasing priority order + // (i.e., first element is the highest priority). + repeated string priorities = 2; +} + +// Configuration for weighted_target LB policy. +message WeightedTargetLoadBalancingPolicyConfig { + message Target { + uint32 weight = 1; + repeated LoadBalancingConfig child_policy = 2; + } + map targets = 1; +} + +// Configuration for xds_cluster_manager_experimental LB policy. +message XdsClusterManagerLoadBalancingPolicyConfig { + message Child { + repeated LoadBalancingConfig child_policy = 1; + } + map children = 1; +} + +// Configuration for the cds LB policy. +message CdsConfig { + string cluster = 1; // Required. +} + +// Represents an xDS server. +message XdsServer { + string server_uri = 1 [json_name = "server_uri"]; // Required. + + message ChannelCredentials { + string type = 1; // Required. + google.protobuf.Struct config = 2; // Optional JSON config. + } + // A list of channel creds to use. The first supported type will be used. + repeated ChannelCredentials channel_creds = 2 [json_name = "channel_creds"]; + + // A repeated list of server features. + repeated google.protobuf.Value server_features = 3 + [json_name = "server_features"]; +} + +// Configuration for xds_cluster_resolver LB policy. +message XdsClusterResolverLoadBalancingPolicyConfig { + // Describes a discovery mechanism instance. + // For EDS or LOGICAL_DNS clusters, there will be exactly one + // DiscoveryMechanism, which will describe the cluster of the parent + // CDS policy. + // For aggregate clusters, there will be one DiscoveryMechanism for each + // underlying cluster. + message DiscoveryMechanism { + // Cluster name. + string cluster = 1; + + // LRS server to send load reports to. + // If not present, load reporting will be disabled. + // If set to the empty string, load reporting will be sent to the same + // server that we obtained CDS data from. + // DEPRECATED: Use new lrs_load_reporting_server field instead. + google.protobuf.StringValue lrs_load_reporting_server_name = 2 + [deprecated=true]; + + // LRS server to send load reports to. + // If not present, load reporting will be disabled. + // Supercedes lrs_load_reporting_server_name field. + XdsServer lrs_load_reporting_server = 7; + + // Maximum number of outstanding requests can be made to the upstream + // cluster. Default is 1024. + google.protobuf.UInt32Value max_concurrent_requests = 3; + + enum Type { + UNKNOWN = 0; + EDS = 1; + LOGICAL_DNS = 2; + }; + Type type = 4; + + // For type EDS only. + // EDS service name, as returned in CDS. + // May be unset if not specified in CDS. + string eds_service_name = 5; + + // For type LOGICAL_DNS only. + // DNS name to resolve in "host:port" form. + string dns_hostname = 6; + } + + // Ordered list of discovery mechanisms. + // Must have at least one element. + // Results from each discovery mechanism are concatenated together in + // successive priorities. + repeated DiscoveryMechanism discovery_mechanisms = 1; + + // xDS LB policy. + // This represents the xDS LB policy, which does not necessarily map + // one-to-one to a gRPC LB policy. Currently, the following policies + // are supported: + // - "ROUND_ROBIN" (config is empty) + // - "RING_HASH" (config is a RingHashLoadBalancingConfig) + repeated LoadBalancingConfig xds_lb_policy = 2; +} + +// Configuration for xds_cluster_impl LB policy. +message XdsClusterImplLoadBalancingPolicyConfig { + // Cluster name. Required. + string cluster = 1; + + // EDS service name. + // Not set if cluster is not an EDS cluster or if it does not + // specify an EDS service name. + string eds_service_name = 2; + + // Server to send load reports to. + // If unset, no load reporting is done. + // If set to empty string, load reporting will be sent to the same + // server as we are getting xds data from. + // DEPRECATED: Use new lrs_load_reporting_server field instead. + google.protobuf.StringValue lrs_load_reporting_server_name = 3 + [deprecated=true]; + + // LRS server to send load reports to. + // If not present, load reporting will be disabled. + // Supercedes lrs_load_reporting_server_name field. + XdsServer lrs_load_reporting_server = 7; + + // Maximum number of outstanding requests can be made to the upstream cluster. + // Default is 1024. + google.protobuf.UInt32Value max_concurrent_requests = 4; + + // Drop configuration. + message DropCategory { + string category = 1; + uint32 requests_per_million = 2; + } + repeated DropCategory drop_categories = 5; + + // Child policy. + repeated LoadBalancingConfig child_policy = 6; +} + +// Configuration for eds LB policy. +message EdsLoadBalancingPolicyConfig { + // Cluster name. Required. + string cluster = 1; + + // EDS service name, as returned in CDS. + // May be unset if not specified in CDS. + string eds_service_name = 2; + + // Server to send load reports to. + // If unset, no load reporting is done. + // If set to empty string, load reporting will be sent to the same + // server as we are getting xds data from. + google.protobuf.StringValue lrs_load_reporting_server_name = 3; + + // Locality-picking policy. + // This policy's config is expected to be in the format used + // by the weighted_target policy. Note that the config should include + // an empty value for the "targets" field; that empty value will be + // replaced by one that is dynamically generated based on the EDS data. + // Optional; defaults to "weighted_target". + repeated LoadBalancingConfig locality_picking_policy = 4; + + // Endpoint-picking policy. + // This will be configured as the policy for each child in the + // locality-policy's config. + // Optional; defaults to "round_robin". + repeated LoadBalancingConfig endpoint_picking_policy = 5; +} + +// Configuration for ring_hash LB policy. +message RingHashLoadBalancingConfig { + uint64 min_ring_size = 1; + uint64 max_ring_size = 2; +} + +// Configuration for lrs LB policy. +message LrsLoadBalancingPolicyConfig { + // Cluster name. Required. + string cluster_name = 1; + + // EDS service name, as returned in CDS. + // May be unset if not specified in CDS. + string eds_service_name = 2; + + // Server to send load reports to. Required. + // If set to empty string, load reporting will be sent to the same + // server as we are getting xds data from. + string lrs_load_reporting_server_name = 3; + + // The locality for which this policy will report load. Required. + message Locality { + string region = 1; + string zone = 2; + string subzone = 3; + } + Locality locality = 4; + + // Endpoint-picking policy. + repeated LoadBalancingConfig child_policy = 5; +} + +// Configuration for xds LB policy. +message XdsConfig { + // Name of balancer to connect to. + string balancer_name = 1 [deprecated = true]; + // Optional. What LB policy to use for intra-locality routing. + // If unset, will use whatever algorithm is specified by the balancer. + // Multiple LB policies can be specified; clients will iterate through + // the list in order and stop at the first policy that they support. + repeated LoadBalancingConfig child_policy = 2; + // Optional. What LB policy to use in fallback mode. If not + // specified, defaults to round_robin. + // Multiple LB policies can be specified; clients will iterate through + // the list in order and stop at the first policy that they support. + repeated LoadBalancingConfig fallback_policy = 3; + // Optional. Name to use in EDS query. If not present, defaults to + // the server name from the target URI. + string eds_service_name = 4; + // LRS server to send load reports to. + // If not present, load reporting will be disabled. + // If set to the empty string, load reporting will be sent to the same + // server that we obtained CDS data from. + google.protobuf.StringValue lrs_load_reporting_server_name = 5; +} + +// Selects LB policy and provides corresponding configuration. +// +// In general, all instances of this field should be repeated. Clients will +// iterate through the list in order and stop at the first policy that they +// support. This allows the service config to specify custom policies that may +// not be known to all clients. +// +// - If the config for the first supported policy is invalid, the whole service +// config is invalid. +// - If the list doesn't contain any supported policy, the whole service config +// is invalid. +message LoadBalancingConfig { + // Exactly one LB policy may be configured. + oneof policy { + // For each new LB policy supported by gRPC, a new field must be added + // here. The field's name must be the LB policy name and its type is a + // message that provides whatever configuration parameters are needed + // by the LB policy. The configuration message will be passed to the + // LB policy when it is instantiated on the client. + // + // If the LB policy does not require any configuration parameters, the + // message for that LB policy may be empty. + // + // Note that if an LB policy contains another nested LB policy + // (e.g., a gslb policy picks the cluster and then delegates to + // a round_robin policy to pick the backend within that cluster), its + // configuration message may include a nested instance of the + // LoadBalancingConfig message to configure the nested LB policy. + + PickFirstConfig pick_first = 4 [json_name = "pick_first"]; + + RoundRobinConfig round_robin = 1 [json_name = "round_robin"]; + + // gRPC lookaside load balancing. + // This will eventually be deprecated by the new xDS-based local + // balancing policy. + GrpcLbConfig grpclb = 3; + + // REMAINING POLICIES ARE EXPERIMENTAL -- DO NOT USE + + PriorityLoadBalancingPolicyConfig priority_experimental = 9 + [json_name = "priority_experimental"]; + WeightedTargetLoadBalancingPolicyConfig weighted_target_experimental = 10 + [json_name = "weighted_target_experimental"]; + + // xDS-based load balancing. + XdsClusterManagerLoadBalancingPolicyConfig xds_cluster_manager_experimental + = 14 [json_name = "xds_cluster_manager_experimental"]; + CdsConfig cds_experimental = 6 [json_name = "cds_experimental"]; + XdsClusterResolverLoadBalancingPolicyConfig + xds_cluster_resolver_experimental = 11 + [json_name = "xds_cluster_resolver_experimental"]; + XdsClusterImplLoadBalancingPolicyConfig xds_cluster_impl_experimental = 12 + [json_name = "xds_cluster_impl_experimental"]; + RingHashLoadBalancingConfig ring_hash_experimental = 13 + [json_name = "ring_hash_experimental"]; + + // Deprecated xDS-related policies. + LrsLoadBalancingPolicyConfig lrs_experimental = 8 + [json_name = "lrs_experimental", deprecated = true]; + EdsLoadBalancingPolicyConfig eds_experimental = 7 + [json_name = "eds_experimental", deprecated = true]; + XdsConfig xds = 2 [deprecated = true]; + XdsConfig xds_experimental = 5 [json_name = "xds_experimental", + deprecated = true]; + + // Next available ID: 14 + } +} + +// A ServiceConfig represents information about a service but is not specific to +// any name resolver. +message ServiceConfig { + // Load balancing policy. + // + // Note that load_balancing_policy is deprecated in favor of + // load_balancing_config; the former will be used only if the latter + // is unset. + // + // If no LB policy is configured here, then the default is pick_first. + // If the policy name is set via the client API, that value overrides + // the value specified here. + // + // If the deprecated load_balancing_policy field is used, note that if the + // resolver returns at least one balancer address (as opposed to backend + // addresses), gRPC will use grpclb (see + // https://github.com/grpc/grpc/blob/master/doc/load-balancing.md), + // regardless of what policy is configured here. However, if the resolver + // returns at least one backend address in addition to the balancer + // address(es), the client may fall back to the requested policy if it + // is unable to reach any of the grpclb load balancers. + enum LoadBalancingPolicy { + UNSPECIFIED = 0; + ROUND_ROBIN = 1; + } + LoadBalancingPolicy load_balancing_policy = 1 [deprecated = true]; + // Multiple LB policies can be specified; clients will iterate through + // the list in order and stop at the first policy that they support. If none + // are supported, the service config is considered invalid. + repeated LoadBalancingConfig load_balancing_config = 4; + + // Per-method configuration. + repeated MethodConfig method_config = 2; + + // If a RetryThrottlingPolicy is provided, gRPC will automatically throttle + // retry attempts and hedged RPCs when the client's ratio of failures to + // successes exceeds a threshold. + // + // For each server name, the gRPC client will maintain a token_count which is + // initially set to max_tokens. Every outgoing RPC (regardless of service or + // method invoked) will change token_count as follows: + // + // - Every failed RPC will decrement the token_count by 1. + // - Every successful RPC will increment the token_count by token_ratio. + // + // If token_count is less than or equal to max_tokens / 2, then RPCs will not + // be retried and hedged RPCs will not be sent. + message RetryThrottlingPolicy { + // The number of tokens starts at max_tokens. The token_count will always be + // between 0 and max_tokens. + // + // This field is required and must be greater than zero. + uint32 max_tokens = 1; + + // The amount of tokens to add on each successful RPC. Typically this will + // be some number between 0 and 1, e.g., 0.1. + // + // This field is required and must be greater than zero. Up to 3 decimal + // places are supported. + float token_ratio = 2; + } + RetryThrottlingPolicy retry_throttling = 3; + + message HealthCheckConfig { + // Service name to use in the health-checking request. + google.protobuf.StringValue service_name = 1; + } + HealthCheckConfig health_check_config = 5; + + // next available tag: 6 +} diff --git a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java index 25b15590d4..36ca5d15f8 100644 --- a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java +++ b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java @@ -26,13 +26,15 @@ import com.google.protobuf.Descriptors.OneofDescriptor; import com.google.protobuf.Descriptors.ServiceDescriptor; import java.io.FileInputStream; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.junit.Before; import org.junit.Test; public class SourceCodeInfoParserTest { - private static final String TEST_PROTO_FILE = "bazel-bin/basic_proto.descriptor"; + private static final String BASIC_PROTO = "basic.proto"; + private static final String PROTO_DESCRIPTOR_SET = "test-proto.descriptorset"; private SourceCodeInfoParser parser; private FileDescriptor protoFile; @@ -143,20 +145,29 @@ public void getOnoeofInfo() { } /** - * Parses a {@link FileDescriptorSet} from the {@code basic_proto.descriptor} and converts the + * Parses a {@link FileDescriptorSet} from the descriptor of {@code basic.proto} and converts the * protos to {@link FileDescriptor} wrappers. * * @return the top level target protoFile descriptor */ private static FileDescriptor buildFileDescriptor() throws Exception { - FileDescriptor result = null; - List protoFileList = - FileDescriptorSet.parseFrom(new FileInputStream(TEST_PROTO_FILE)).getFileList(); - List deps = new ArrayList<>(); - for (FileDescriptorProto proto : protoFileList) { - result = FileDescriptor.buildFrom(proto, deps.toArray(new FileDescriptor[0])); - deps.add(result); + InputStream testProto = + SourceCodeInfoParserTest.class.getClassLoader().getResourceAsStream(PROTO_DESCRIPTOR_SET); + if (testProto == null) { // TODO: only for Bazel build. Remove when we don't build with Bazel. + testProto = new FileInputStream(PROTO_DESCRIPTOR_SET); } - return result; + try (InputStream in = testProto) { + List protoFileList = FileDescriptorSet.parseFrom(in).getFileList(); + List deps = new ArrayList<>(); + for (FileDescriptorProto proto : protoFileList) { + FileDescriptor descriptor = + FileDescriptor.buildFrom(proto, deps.toArray(new FileDescriptor[0])); + if (descriptor.getName().endsWith(BASIC_PROTO)) { + return descriptor; + } + deps.add(descriptor); + } + } + return null; } } diff --git a/src/test/java/com/google/api/generator/test/framework/Utils.java b/src/test/java/com/google/api/generator/test/framework/Utils.java index d5d97c9118..a6a9a53515 100644 --- a/src/test/java/com/google/api/generator/test/framework/Utils.java +++ b/src/test/java/com/google/api/generator/test/framework/Utils.java @@ -33,12 +33,17 @@ public class Utils { * @param codegen the generated code from JUnit test */ public static void saveCodegenToFile(Class clazz, String fileName, String codegen) { - if (System.getProperty("updateUnitGoldens") == null) { + String relativeGoldenDir = getTestoutGoldenDir(clazz); + Path testOutputDir = Paths.get("src", "test", "java", relativeGoldenDir); + + // Auto-detect project workspace when running `bazel run //:update_TargetTest`. + String workspaceDir = System.getenv("BUILD_WORKSPACE_DIRECTORY"); + if (workspaceDir != null) { + testOutputDir = Paths.get(workspaceDir).resolve(testOutputDir); + } else if (System.getProperty("updateUnitGoldens") == null) { return; } - String relativeGoldenDir = getTestoutGoldenDir(clazz); - Path testOutputDir = Paths.get("src", "test", "java", relativeGoldenDir); testOutputDir.toFile().mkdirs(); try (FileWriter myWriter = new FileWriter(testOutputDir.resolve(fileName).toFile())) { myWriter.write(codegen); diff --git a/src/test/resources/bad_message_resname_def.proto b/src/test/proto/bad_message_resname_def.proto similarity index 100% rename from src/test/resources/bad_message_resname_def.proto rename to src/test/proto/bad_message_resname_def.proto diff --git a/src/test/resources/basic.proto b/src/test/proto/basic.proto similarity index 100% rename from src/test/resources/basic.proto rename to src/test/proto/basic.proto diff --git a/src/test/resources/bookshop.proto b/src/test/proto/bookshop.proto similarity index 100% rename from src/test/resources/bookshop.proto rename to src/test/proto/bookshop.proto diff --git a/src/test/resources/compliance.proto b/src/test/proto/compliance.proto similarity index 100% rename from src/test/resources/compliance.proto rename to src/test/proto/compliance.proto diff --git a/src/test/resources/deprecated_service.proto b/src/test/proto/deprecated_service.proto similarity index 100% rename from src/test/resources/deprecated_service.proto rename to src/test/proto/deprecated_service.proto diff --git a/src/test/resources/echo.proto b/src/test/proto/echo.proto similarity index 100% rename from src/test/resources/echo.proto rename to src/test/proto/echo.proto diff --git a/src/test/resources/explicit_dynamic_routing_header_testing.proto b/src/test/proto/explicit_dynamic_routing_header_testing.proto similarity index 100% rename from src/test/resources/explicit_dynamic_routing_header_testing.proto rename to src/test/proto/explicit_dynamic_routing_header_testing.proto diff --git a/src/test/resources/identity.proto b/src/test/proto/identity.proto similarity index 100% rename from src/test/resources/identity.proto rename to src/test/proto/identity.proto diff --git a/src/test/resources/locker.proto b/src/test/proto/locker.proto similarity index 100% rename from src/test/resources/locker.proto rename to src/test/proto/locker.proto diff --git a/src/test/resources/messaging.proto b/src/test/proto/messaging.proto similarity index 100% rename from src/test/resources/messaging.proto rename to src/test/proto/messaging.proto diff --git a/src/test/resources/nested_message.proto b/src/test/proto/nested_message.proto similarity index 100% rename from src/test/resources/nested_message.proto rename to src/test/proto/nested_message.proto diff --git a/src/test/resources/routing_rule_parser_testing.proto b/src/test/proto/routing_rule_parser_testing.proto similarity index 100% rename from src/test/resources/routing_rule_parser_testing.proto rename to src/test/proto/routing_rule_parser_testing.proto diff --git a/src/test/resources/testing.proto b/src/test/proto/testing.proto similarity index 100% rename from src/test/resources/testing.proto rename to src/test/proto/testing.proto From 7ef9a38469f7f48611543b990807dc6d64f59845 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 17:48:46 -0500 Subject: [PATCH 20/73] chore: re-work build infra --- .githooks/pre-commit | 7 +- .github/workflows/ci.yaml | 17 +- .gitignore | 2 +- BUILD.bazel | 24 +- DEVELOPMENT.md | 30 +-- ad-hoc-compile-proto-files.sh | 27 -- pom.xml | 237 ------------------ .../api/generator/test/framework/Utils.java | 1 + 8 files changed, 28 insertions(+), 317 deletions(-) delete mode 100755 ad-hoc-compile-proto-files.sh delete mode 100644 pom.xml diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 8f63a2c40a..746debcd9a 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -83,11 +83,11 @@ fi if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] then echo_status "Running Java linter..." - mvn fmt:check + bazel --batch run --disk_cache="$BAZEL_CACHE_DIR" //:google_java_format_verification FORMAT_STATUS=$? if [ $FORMAT_STATUS != 0 ] then - echo_error "Linting failed." "Please run mvn fmt:format try again." + echo_error "Linting failed." "Please run :google_java_format and try again." exit 1 fi fi @@ -96,8 +96,7 @@ fi if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ] then echo_status "Checking unit tests..." - ./ad-hoc-compile-proto-files.sh - mvn verify + bazel --batch test //:units --disk_cache="$BAZEL_CACHE_DIR" TEST_STATUS=$? if [ $TEST_STATUS != 0 ] then diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 968027e42c..511d074fd7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,14 +18,6 @@ jobs: java-version: ${{ matrix.java }} - run: java -version - - name: Cache local Maven repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Bazel File Cache Setup id: cache-bazel uses: actions/cache@v2 @@ -51,11 +43,6 @@ jobs: - name: Unit Tests run: bazel --batch test //:units --noshow_progress --test_output=errors - - name: Unit Tests (Maven) - run: | - ./ad-hoc-compile-proto-files.sh - mvn verify --batch-mode --no-transfer-progress - - name: Integration Tests run: bazel --batch test //test/integration/... @@ -89,9 +76,6 @@ jobs: - name: Java Linter run: bazel --batch run //:google_java_format_verification - - name: Java Linter (Maven) - run: mvn fmt:check - coverage: runs-on: ubuntu-latest steps: @@ -122,3 +106,4 @@ jobs: run: | go get -u github.com/google/addlicense addlicense -c "Google LLC" -l apache -check $(find $PWD -type f -name '*.java' ! -iname '*PlaceholderFile.java') + diff --git a/.gitignore b/.gitignore index 913a2a8e6e..a484993351 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ +# Bazel. bazel-* .gradle/ -target/ # IDE .idea diff --git a/BUILD.bazel b/BUILD.bazel index 9b9ff37e71..bef962d787 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -94,12 +94,20 @@ java_plugin( processor_class = "com.google.auto.value.processor.AutoValueProcessor", deps = ["@com_google_auto_value_auto_value//jar"], ) + java_library( name = "gapic-generator-java", srcs = glob(["src/main/java/**/*.java"]), plugins = [":autovalue_plugin"], deps = MAIN_DEPS, ) + +java_library( + name = "gapic-generator-java-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [":gapic-generator-java"] + MAIN_DEPS + TEST_DEPS, +) + java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", @@ -154,15 +162,13 @@ genrule( # Unit tests. Run each test with, e.g., # bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest -java_library( - name = "gapic-generator-java-test", - srcs = glob(["src/test/java/**/*.java"]), - deps = [":gapic-generator-java"] + MAIN_DEPS + TEST_DEPS, -) [java_test( name = "unit_" + file[14:-5].replace('/', '_'), test_class = file[14:-5].replace('/', '.'), - runtime_deps = [":gapic-generator-java", ":gapic-generator-java-test"] + MAIN_DEPS + TEST_DEPS, + runtime_deps = [ + ":gapic-generator-java", + ":gapic-generator-java-test", + ] + MAIN_DEPS + TEST_DEPS, data = [":basic_proto_descriptor"] + glob([ "src/test/java/**/*.golden", "src/test/resources/**", @@ -199,10 +205,12 @@ GOLDEN_UPDATING_UNIT_TESTS = [ # bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest [java_binary( name = "update_%s" % test_class.replace('.', '_'), - srcs = glob(["src/test/java/**/*.java"]), main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", args = [test_class], - deps = [":protoc-gen-java_gapic"] + MAIN_DEPS + TEST_DEPS, + runtime_deps = [ + ":gapic-generator-java", + ":gapic-generator-java-test", + ] + MAIN_DEPS + TEST_DEPS, data = glob([ "src/test/java/**/*.golden", "src/test/resources/**", diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 17bab368bb..9c92cf6f95 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -92,20 +92,12 @@ ```sh bazel run //:google_java_format_verification ``` - or - ```sh - mvn fmt:check - ``` - Format files. ```sh bazel run //:google_java_format ``` - or - ```sh - mvn fmt:format - ``` ## Test Running @@ -120,27 +112,17 @@ ```sh bazel test //:units ``` - or - ```sh - mvn test - ``` - -- Run a single unit test like `JavaCodeGeneratorTest.java`: - ```sh - bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest - ``` - -- Update unit test golden files, for example `JavaCodeGeneratorTest.java`: +- Run a single unit test like `JavaCodeGeneratorTest.java` - ```sh - bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest - ``` + ```sh + bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest + ``` -- Update unit test golden files: +- Update unit test golden files, for example `JavaCodeGeneratorTest.java`: ```sh - mvn test -DupdateUnitGoldens + bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest ``` - Run a single integration test for API like `Redis`, it generates Java source diff --git a/ad-hoc-compile-proto-files.sh b/ad-hoc-compile-proto-files.sh deleted file mode 100755 index aaf44debad..0000000000 --- a/ad-hoc-compile-proto-files.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -set -o errexit - -# Some auto-generated Java proto library code for .proto files are not published -# anywhere, so currently, we need to build them using `java_proto_library()` to -# generate .jar files. -# -# gapic_metadata.proto -# common_resources.proto -# pubsub.proto (v2) -# logging.proto (v1) - -bazel --batch build \ - @com_google_googleapis//gapic/metadata:metadata_java_proto \ - @com_google_googleapis//google/logging/v2:logging_java_proto \ - @com_google_googleapis//google/pubsub/v1:pubsub_java_proto - -install_jar() { - mvn install:install-file -Dfile=bazel-bin/external/$1 -DgroupId=$2 -DartifactId=$3 -Dversion=0.0.0 -Dpackaging=jar \ - --batch-mode --no-transfer-progress -} - -install_jar com_google_googleapis/gapic/metadata/libmetadata_proto-speed.jar com.google.api metadata-proto -install_jar com_google_googleapis/google/cloud/libcommon_resources_proto-speed.jar com.google.api common-resources-proto -install_jar com_google_googleapis/google/pubsub/v1/libpubsub_proto-speed.jar com.google.api pubsub-proto -install_jar com_google_googleapis/google/logging/v2/liblogging_proto-speed.jar com.google.api logging-proto diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 526ac9b2cf..0000000000 --- a/pom.xml +++ /dev/null @@ -1,237 +0,0 @@ - - 4.0.0 - com.google.api - gapic-generator-java - 0.0.1-SNAPSHOT - - - UTF-8 - - - - - - maven-compiler-plugin - 3.8.1 - - 8 - 8 - - - com.google.auto.value - auto-value - 1.7.2 - - - - - - - com.coveo - fmt-maven-plugin - 2.9.1 - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.6.1 - - - protobuf-compile - - compile - - - - protobuf-test-compile - - test-compile - - - true - true - true - test-proto.descriptor - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M5 - - - ${project.build.directory}/generated-test-resources/protobuf/descriptor-sets/ - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - - - - com.google.guava - guava - 30.1.1-jre - - - com.google.api - gax - 2.12.0 - - - com.google.api - gax - 2.12.0 - testlib - - - com.google.api - gax-grpc - 2.12.0 - - - com.google.api - gax-grpc - 2.12.0 - testlib - - - com.google.api - gax-httpjson - 0.95.0 - - - com.google.api - gax-httpjson - 0.95.0 - testlib - - - - com.google.auto.value - auto-value-annotations - 1.7.2 - - - com.google.protobuf - protobuf-java-util - 3.19.1 - - - io.grpc - grpc-stub - 1.42.1 - - - io.grpc - grpc-protobuf - 1.42.1 - - - org.yaml - snakeyaml - 1.26 - - - com.google.googlejavaformat - google-java-format - 1.7 - - - - - javax.annotation - javax.annotation-api - 1.3.2 - - - - junit - junit - 4.13.1 - - - - - com.google.truth - truth - 1.1.2 - test - - - io.github.java-diff-utils - java-diff-utils - 4.0 - test - - - - com.google.api - metadata-proto - 0.0.0 - - - - - com.google.api - common-resources-proto - 0.0.0 - test - - - - com.google.api - logging-proto - 0.0.0 - test - - - com.google.api - pubsub-proto - 0.0.0 - test - - - - diff --git a/src/test/java/com/google/api/generator/test/framework/Utils.java b/src/test/java/com/google/api/generator/test/framework/Utils.java index a6a9a53515..3d5a4359ab 100644 --- a/src/test/java/com/google/api/generator/test/framework/Utils.java +++ b/src/test/java/com/google/api/generator/test/framework/Utils.java @@ -37,6 +37,7 @@ public static void saveCodegenToFile(Class clazz, String fileName, String cod Path testOutputDir = Paths.get("src", "test", "java", relativeGoldenDir); // Auto-detect project workspace when running `bazel run //:update_TargetTest`. + // TODO: remove when we don't use Bazel. String workspaceDir = System.getenv("BUILD_WORKSPACE_DIRECTORY"); if (workspaceDir != null) { testOutputDir = Paths.get(workspaceDir).resolve(testOutputDir); From 1297100d1f15648120dfbc4e02b7127b692ded5e Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 16 Feb 2022 22:13:46 -0500 Subject: [PATCH 21/73] chore: set up fully working pom.xml --- .github/workflows/ci-maven.yaml | 34 ++++ .gitignore | 2 +- DEVELOPMENT.md | 38 +++- pom.xml | 329 ++++++++++++++++++++++++++++++++ 4 files changed, 396 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci-maven.yaml create mode 100644 pom.xml diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml new file mode 100644 index 0000000000..5ffc8cae1b --- /dev/null +++ b/.github/workflows/ci-maven.yaml @@ -0,0 +1,34 @@ +on: + push: + branches: + - main + pull_request: +name: ci-maven +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + java: [8, 11] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - run: java -version + + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Unit Tests + run: | + mvn verify --batch-mode --no-transfer-progress + + - name: Java Linter + run: mvn fmt:check diff --git a/.gitignore b/.gitignore index a484993351..913a2a8e6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -# Bazel. bazel-* .gradle/ +target/ # IDE .idea diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 9c92cf6f95..7bc9f79c7f 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -92,12 +92,20 @@ ```sh bazel run //:google_java_format_verification ``` + or + ```sh + mvn fmt:check + ``` - Format files. ```sh bazel run //:google_java_format ``` + or + ```sh + mvn fmt:format + ``` ## Test Running @@ -112,19 +120,37 @@ ```sh bazel test //:units ``` - -- Run a single unit test like `JavaCodeGeneratorTest.java` - + or ```sh - bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest + mvn test ``` -- Update unit test golden files, for example `JavaCodeGeneratorTest.java`: +- Run a single unit test like `JavaCodeGeneratorTest.java`: + + ```sh + bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest + ``` + or + ```sh + mvn test -Dtest=JavaCodeGeneratorTest + ``` + +- Update all unit test golden files: ```sh - bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest + mvn test -DupdateUnitGoldens ``` +- Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: + + ```sh + bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest + ``` + or + ```sh + mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest + ``` + - Run a single integration test for API like `Redis`, it generates Java source code using the Java microgenerator and compares them with the goldens files in `test/integration/goldens/redis`. diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000..bd8964b867 --- /dev/null +++ b/pom.xml @@ -0,0 +1,329 @@ + + 4.0.0 + com.google.api + gapic-generator-java + 0.0.1-SNAPSHOT + + + UTF-8 + + 44d6bef0ca6db8bba3fb324c8186e694bcc4829c + + + + + + com.google.cloud + google-cloud-shared-dependencies + 2.7.0 + pom + import + + + + + + + + kr.motd.maven + os-maven-plugin + 1.7.0 + + + + + + maven-compiler-plugin + 3.8.1 + + 8 + 8 + + + com.google.auto.value + auto-value + 1.7.2 + + + + + + + com.coveo + fmt-maven-plugin + 2.9.1 + + + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.6.8 + + + download-metadata-proto + generate-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/gapic/metadata/gapic_metadata.proto + ${project.build.directory}/generated-sources/proto/ + + + + download-common-resources-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/cloud/common_resources.proto + ${project.build.directory}/generated-test-sources/proto/ + + + + download-pubsub-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/pubsub/v1/pubsub.proto + ${project.build.directory}/generated-test-sources/proto/ + + + + download-schema-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/pubsub/v1/schema.proto + ${project.build.directory}/generated-test-sources/proto/google/pubsub/v1/ + + + + download-logging-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging.proto + ${project.build.directory}/generated-test-sources/proto/ + + + + download-log-entry-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/log_entry.proto + ${project.build.directory}/generated-test-sources/proto/google/logging/v2/ + + + + download-logging-config-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging_config.proto + ${project.build.directory}/generated-test-sources/proto/google/logging/v2/ + + + + download-logging-metrics-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging_metrics.proto + ${project.build.directory}/generated-test-sources/proto/google/logging/v2/ + + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + com.google.protobuf:protoc:3.19.4:exe:${os.detected.classifier} + + + + compile-protos + + compile + + + + compile-downloaded-protos + + compile + + + ${project.build.directory}/generated-sources/proto/ + false + + + + compile-test-protos + + test-compile + + + true + true + true + test-proto.descriptorset + + + + compile-downloaded-test-protos + + test-compile + + + ${project.build.directory}/generated-test-sources/proto/ + false + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + ${project.build.directory}/generated-test-resources/protobuf/descriptor-sets/ + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.api + gax + testlib + + + com.google.api + gax-grpc + + + com.google.api + gax-grpc + testlib + + + com.google.api + gax-httpjson + + + com.google.api + gax-httpjson + testlib + + + com.google.auto.value + auto-value-annotations + + + com.google.protobuf + protobuf-java-util + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + org.yaml + snakeyaml + 1.26 + + + com.google.googlejavaformat + google-java-format + 1.7 + + + junit + junit + 4.13.1 + + + + + javax.annotation + javax.annotation-api + 1.3.2 + + + + com.google.truth + truth + 1.1.2 + test + + + io.github.java-diff-utils + java-diff-utils + 4.0 + test + + + From 0d0015390a6f62d4ee3d76b92c99abc2504a4bf0 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Thu, 17 Feb 2022 15:41:03 -0500 Subject: [PATCH 22/73] merge with setup-maven --- .githooks/pre-commit | 6 +- .github/workflows/ci.yaml | 25 --- BUILD.bazel | 203 +----------------- DEVELOPMENT.md | 43 ++-- PROPERTIES.bzl | 31 --- WORKSPACE | 25 +-- pom.xml | 1 - .../protoparser/SourceCodeInfoParserTest.java | 12 +- .../api/generator/test/framework/Utils.java | 12 +- 9 files changed, 37 insertions(+), 321 deletions(-) delete mode 100644 PROPERTIES.bzl diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 746debcd9a..2cde4be697 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -83,11 +83,11 @@ fi if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] then echo_status "Running Java linter..." - bazel --batch run --disk_cache="$BAZEL_CACHE_DIR" //:google_java_format_verification + mvn fmt:check FORMAT_STATUS=$? if [ $FORMAT_STATUS != 0 ] then - echo_error "Linting failed." "Please run :google_java_format and try again." + echo_error "Linting failed." "Please run mvn fmt:format and try again." exit 1 fi fi @@ -96,7 +96,7 @@ fi if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ] then echo_status "Checking unit tests..." - bazel --batch test //:units --disk_cache="$BAZEL_CACHE_DIR" + mvn test TEST_STATUS=$? if [ $TEST_STATUS != 0 ] then diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 511d074fd7..64df39babd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,9 +40,6 @@ jobs: echo "and it will start over with a clean cache." echo "The old one will disappear after 7 days." - - name: Unit Tests - run: bazel --batch test //:units --noshow_progress --test_output=errors - - name: Integration Tests run: bazel --batch test //test/integration/... @@ -73,28 +70,6 @@ jobs: path: ~/.cache/bazel/*/*/*/gapic_generator_java/bazel-out/*/testlogs/* retention-days: 5 - - name: Java Linter - run: bazel --batch run //:google_java_format_verification - - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - java-version: 8 - - run: java -version - - - name: Generate Code Coverage Report - # Run only test targets, and not golden_update targets. - run: bazel coverage //:units --combined_report=lcov - - - name: Upload Code Coverage Report - uses: codecov/codecov-action@v2 - with: - name: actions ${{ matrix.java }} - files: ./bazel-out/_coverage/_coverage_report.dat - license-header: runs-on: ubuntu-latest steps: diff --git a/BUILD.bazel b/BUILD.bazel index bef962d787..4e843013d3 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -2,116 +2,17 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_proto_library") package(default_visibility = ["//visibility:public"]) -# TODO: some dependencies may be runtime only. -MAIN_DEPS = [ - ":service_config_java_proto", - "@com_google_api_api_common//jar", - "@com_google_api_gax_java//gax", - "@com_google_api_gax_java//gax:gax_testlib", - "@com_google_api_gax_java//gax-grpc:gax_grpc", - "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson", - "@com_google_api_gax_java//gax-httpjson:gax_httpjson_testlib", - "@com_google_api_grpc_proto_google_common_protos", - "@com_google_auto_value_auto_value_annotations//jar", # Ideally should be compile-time only, but this is OK. - "@com_google_code_gson//jar", - "@com_google_googleapis//gapic/metadata:metadata_java_proto", - "@com_google_guava_guava", - "@com_google_http_client_google_http_client//jar", - "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", - "@google_java_format_all_deps//jar", - "@io_grpc_grpc_java//api", - "@io_grpc_grpc_java//protobuf", - "@io_grpc_grpc_java//stub", - "@javax_annotation_javax_annotation_api//jar", - "@junit_junit//jar", - "@org_threeten_threetenbp//jar", - "@org_yaml_snakeyaml//jar", -] - -MAIN_DEPS_DEBUG_RUNTIME_ONLY = [ - "@com_google_googleapis//google/api:api_java_proto", - "@com_google_googleapis//google/cloud:extended_operations_java_proto", - "@com_google_googleapis//google/longrunning:longrunning_java_proto", - "@com_google_protobuf//java/core", -] - -# Some dependencies are runtime only, but that's fine for tests. -TEST_DEPS = [ - ":test_java_protos", - "@com_google_googleapis//google/logging/v2:logging_java_proto", - "@com_google_googleapis//google/pubsub/v1:pubsub_java_proto", - "@com_google_googleapis//google/rpc:rpc_java_proto", - "@com_google_truth_truth//jar", - "@io_github_java_diff_utils//jar", -] - -proto_library( - name = "service_config_proto", - srcs = ["src/main/proto/service_config.proto"], - deps = [ - "@com_google_googleapis//google/rpc:code_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:wrappers_proto", - "@com_google_protobuf//:struct_proto", - ], -) -java_proto_library( - name = "service_config_java_proto", - deps = [":service_config_proto"], -) - -proto_library( - name = "test_protos", - srcs = glob(["src/test/proto/*.proto"]), - deps = [ - "@com_google_googleapis//google/api:annotations_proto", - "@com_google_googleapis//google/api:client_proto", - "@com_google_googleapis//google/api:field_behavior_proto", - "@com_google_googleapis//google/api:routing_proto", - "@com_google_googleapis//google/api:resource_proto", - "@com_google_googleapis//google/cloud:extended_operations_proto", - "@com_google_googleapis//google/longrunning:operations_proto", - "@com_google_googleapis//google/rpc:error_details_proto", - "@com_google_googleapis//google/rpc:status_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:field_mask_proto", - "@com_google_protobuf//:timestamp_proto", - ], -) -java_proto_library( - name = "test_java_protos", - deps = [ - ":test_protos", - "@com_google_googleapis//google/cloud:common_resources_proto" - ], -) - -java_plugin( - name = "autovalue_plugin", - processor_class = "com.google.auto.value.processor.AutoValueProcessor", - deps = ["@com_google_auto_value_auto_value//jar"], -) - -java_library( - name = "gapic-generator-java", - srcs = glob(["src/main/java/**/*.java"]), - plugins = [":autovalue_plugin"], - deps = MAIN_DEPS, -) - -java_library( - name = "gapic-generator-java-test", - srcs = glob(["src/test/java/**/*.java"]), - deps = [":gapic-generator-java"] + MAIN_DEPS + TEST_DEPS, +java_import( + name = "gapic_generator_java", + # Note referring to target/ is only for local development; you can also pull from remote + # filesystem, GCS bucket, Maven repositories, etc. + jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], ) java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", - runtime_deps = [":gapic-generator-java"] + MAIN_DEPS, + runtime_deps = [":gapic-generator-java"], ) # Request dumper binary, which dumps the CodeGeneratorRequest to a file on disk @@ -133,7 +34,7 @@ java_binary( java_binary( name = "protoc-gen-code_generator_request_dumper", main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper", - runtime_deps = [":gapic-generator-java"] + MAIN_DEPS + MAIN_DEPS_DEBUG_RUNTIME_ONLY, + runtime_deps = [":gapic-generator-java"], ) # A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest @@ -146,77 +47,9 @@ java_binary( java_binary( name = "code_generator_request_file_to_gapic_main", main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", - runtime_deps = [":gapic-generator-java"] + MAIN_DEPS + MAIN_DEPS_DEBUG_RUNTIME_ONLY, -) - -# another test resource -genrule( - name = "basic_proto_descriptor", - srcs = ["src/test/proto/basic.proto"], - outs = ["test-proto.descriptorset"], - cmd = "$(location @com_google_protobuf//:protoc) " + - "--include_source_info --include_imports --descriptor_set_out=$(OUTS) $(SRCS)", - message = "Generating proto descriptor", - tools = ["@com_google_protobuf//:protoc"], + runtime_deps = [":gapic-generator-java"], ) -# Unit tests. Run each test with, e.g., -# bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest -[java_test( - name = "unit_" + file[14:-5].replace('/', '_'), - test_class = file[14:-5].replace('/', '.'), - runtime_deps = [ - ":gapic-generator-java", - ":gapic-generator-java-test", - ] + MAIN_DEPS + TEST_DEPS, - data = [":basic_proto_descriptor"] + glob([ - "src/test/java/**/*.golden", - "src/test/resources/**", - ]), - tags = ["small"], -) for file in glob(["src/test/java/**/*Test.java"])] - -test_suite(name = "units", tags = ["small"]) - -# Tests that generate and save unit golden (.golden) files. -GOLDEN_UPDATING_UNIT_TESTS = [ - "com.google.api.generator.engine.JavaCodeGeneratorTest", - "com.google.api.generator.gapic.composer.ComposerTest", - "com.google.api.generator.gapic.composer.common.BatchingDescriptorComposerTest", - "com.google.api.generator.gapic.composer.grpc.GrpcServiceCallableFactoryClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.GrpcServiceStubClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.MockServiceClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.MockServiceImplClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceClientClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceClientTestClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceSettingsClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceStubClassComposerTest", - "com.google.api.generator.gapic.composer.grpc.ServiceStubSettingsClassComposerTest", - "com.google.api.generator.gapic.composer.resourcename.ResourceNameHelperClassComposerTest", - "com.google.api.generator.gapic.composer.rest.HttpJsonServiceCallableFactoryClassComposerTest", - "com.google.api.generator.gapic.composer.rest.HttpJsonServiceStubClassComposerTest", - "com.google.api.generator.gapic.composer.rest.ServiceClientTestClassComposerTest", - "com.google.api.generator.gapic.composer.rest.ServiceSettingsClassComposerTest", - "com.google.api.generator.gapic.composer.rest.ServiceStubSettingsClassComposerTest", -] - -# Manually runs a single JUnit test for the tests that generate and save .golden -# files. To update .golden files, run with, e.g., -# bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest -[java_binary( - name = "update_%s" % test_class.replace('.', '_'), - main_class = "com.google.api.generator.test.framework.SingleJUnitTestRunner", - args = [test_class], - runtime_deps = [ - ":gapic-generator-java", - ":gapic-generator-java-test", - ] + MAIN_DEPS + TEST_DEPS, - data = glob([ - "src/test/java/**/*.golden", - "src/test/resources/**", - ]), -) for test_class in GOLDEN_UPDATING_UNIT_TESTS] - # google-java-format java_binary( name = "google_java_format_binary", @@ -224,23 +57,3 @@ java_binary( main_class = "com.google.googlejavaformat.java.Main", runtime_deps = ["@google_java_format_all_deps//jar"], ) - -genrule( - name = "google_java_format", - outs = ["google_java_format.sh"], - cmd = "echo 'find src test -name \'*.java\' | grep -v /goldens/ | xargs $(execpath :google_java_format_binary) --replace' > $(OUTS)", - executable = 1, - tools = [":google_java_format_binary"], - local = 1, -) - -# Run `bazel build //:google_java_format_verification` to verify that gapic-generator-java sources -# are formatted correctly. -genrule( - name = "google_java_format_verification", - outs = ["google_java_format_verification.sh"], - cmd = "echo 'find src test -name \'*.java\' | grep -v /goldens/ | xargs $(execpath :google_java_format_binary) --dry-run --set-exit-if-changed' > $(OUTS)", - executable = 1, - tools = [":google_java_format_binary"], - local = 1, -) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 7bc9f79c7f..defb8b8f11 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -47,7 +47,7 @@ java_proto_library( name = "showcase_java_proto", deps = [ - "showcase_proto", + ":showcase_proto", ], ) @@ -89,20 +89,12 @@ - Run linter checks without actually doing the formatting. - ```sh - bazel run //:google_java_format_verification - ``` - or ```sh mvn fmt:check ``` - Format files. - ```sh - bazel run //:google_java_format - ``` - or ```sh mvn fmt:format ``` @@ -112,28 +104,23 @@ - Run all unit and integration tests. ```sh - bazel test //... + mvn test # unit tests + bazel test //... # integration tests ``` - Run all unit tests. - ```sh - bazel test //:units - ``` - or ```sh mvn test ``` -- Run a single unit test like `JavaCodeGeneratorTest.java`: +- Run a single or multiple unit tests: + + ```sh + mvn test -Dtest=JavaCodeGeneratorTest - ```sh - bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest - ``` - or - ```sh - mvn test -Dtest=JavaCodeGeneratorTest - ``` + mvn test "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]" + ```  - Update all unit test golden files: @@ -141,15 +128,11 @@ mvn test -DupdateUnitGoldens ``` -- Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: +- Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: - ```sh - bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest - ``` - or - ```sh - mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest - ``` + ```sh + mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest + ``` - Run a single integration test for API like `Redis`, it generates Java source code using the Java microgenerator and compares them with the goldens files diff --git a/PROPERTIES.bzl b/PROPERTIES.bzl deleted file mode 100644 index 8abf2dd26f..0000000000 --- a/PROPERTIES.bzl +++ /dev/null @@ -1,31 +0,0 @@ -PROPERTIES = { - "version.com_google_protobuf": "3.19.1", - # Version of google-java-format is downgraded from 1.8 to 1.7, because 1.8 supports java 11 minimum, while our JRE is java 8. - "version.google_java_format": "1.7", - "version.io_grpc_java": "1.42.1", - - # Common deps. - "maven.com_google_guava_guava": "com.google.guava:guava:30.1-android", - "maven.com_google_code_findbugs_jsr305": "com.google.code.findbugs:jsr305:3.0.0", - "maven.com_google_auto_value_auto_value": "com.google.auto.value:auto-value:1.7.2", - "maven.com_google_auto_value_auto_value_annotations": "com.google.auto.value:auto-value-annotations:1.7.2", - "maven.com_google_code_gson": "com.google.code.gson:gson:2.8.6", - "maven.com_google_protobuf_protobuf_java": "com.google.protobuf:protobuf-java:3.19.1", - "maven.io_github_java_diff_utils": "io.github.java-diff-utils:java-diff-utils:4.0", - "maven.javax_annotation_javax_annotation_api": "javax.annotation:javax.annotation-api:1.3.2", - - # Gapic YAML parsing for batching settings. - "maven.org_yaml_snakeyaml": "org.yaml:snakeyaml:1.26", - - # ServiceStubSettings class. Used only in generated code. - "maven.org_threeten_threetenbp": "org.threeten:threetenbp:1.3.3", - - # Testing. - "maven.junit_junit": "junit:junit:4.13.1", - # This hamcrest-core dependency is for running JUnit test manually, before JUnit 4.11 it's wrapped along with JUnit package. - # But now it has to be explicitly added. - "maven.org_hamcrest_hamcrest_core": "org.hamcrest:hamcrest-core:1.3", - "maven.org_mockito_mockito_core": "org.mockito:mockito-core:2.21.0", - # Keep in sync with gax-java. - "maven.com_google_truth_truth": "com.google.truth:truth:1.1.2", -} diff --git a/WORKSPACE b/WORKSPACE index 22744a67eb..817fdcb4d3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,18 +3,6 @@ workspace(name = "gapic_generator_java") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") -# DO NOT REMOVE. -# This is needed to clobber any transitively-pulled in versions of bazel_skylib so that packages -# like protobuf will build. -http_archive( - name = "bazel_skylib", - sha256 = "af87959afe497dc8dfd4c6cb66e1279cb98ccc84284619ebfec27d9c09a903de", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz", - ], -) - jvm_maven_import_external( name = "google_java_format_all_deps", artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:1.7", @@ -52,9 +40,11 @@ load("@com_google_api_gax_java//:repositories.bzl", "com_google_api_gax_java_rep com_google_api_gax_java_repositories() -load("//:repositories.bzl", "gapic_generator_java_repositories") - -gapic_generator_java_repositories() +http_archive( + name = "com_google_googleapis", + urls = ["https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip"], + strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c", +) # protobuf RULES_JVM_EXTERNAL_TAG = "4.2" @@ -73,10 +63,7 @@ load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = PROTOBUF_MAVEN_ARTIFACTS, - generate_compat_repositories = True, - repositories = [ - "https://repo.maven.apache.org/maven2/", - ], + repositories = ["https://repo.maven.apache.org/maven2/"], ) protobuf_deps() diff --git a/pom.xml b/pom.xml index bd8964b867..e7f28f51fe 100644 --- a/pom.xml +++ b/pom.xml @@ -310,7 +310,6 @@ javax.annotation javax.annotation-api - 1.3.2 diff --git a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java index 36ca5d15f8..94effe2627 100644 --- a/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java +++ b/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java @@ -25,7 +25,6 @@ import com.google.protobuf.Descriptors.FileDescriptor; import com.google.protobuf.Descriptors.OneofDescriptor; import com.google.protobuf.Descriptors.ServiceDescriptor; -import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.List; @@ -151,13 +150,10 @@ public void getOnoeofInfo() { * @return the top level target protoFile descriptor */ private static FileDescriptor buildFileDescriptor() throws Exception { - InputStream testProto = - SourceCodeInfoParserTest.class.getClassLoader().getResourceAsStream(PROTO_DESCRIPTOR_SET); - if (testProto == null) { // TODO: only for Bazel build. Remove when we don't build with Bazel. - testProto = new FileInputStream(PROTO_DESCRIPTOR_SET); - } - try (InputStream in = testProto) { - List protoFileList = FileDescriptorSet.parseFrom(in).getFileList(); + try (InputStream testProto = + SourceCodeInfoParserTest.class.getClassLoader().getResourceAsStream(PROTO_DESCRIPTOR_SET)) { + List protoFileList = + FileDescriptorSet.parseFrom(testProto).getFileList(); List deps = new ArrayList<>(); for (FileDescriptorProto proto : protoFileList) { FileDescriptor descriptor = diff --git a/src/test/java/com/google/api/generator/test/framework/Utils.java b/src/test/java/com/google/api/generator/test/framework/Utils.java index 3d5a4359ab..d5d97c9118 100644 --- a/src/test/java/com/google/api/generator/test/framework/Utils.java +++ b/src/test/java/com/google/api/generator/test/framework/Utils.java @@ -33,18 +33,12 @@ public class Utils { * @param codegen the generated code from JUnit test */ public static void saveCodegenToFile(Class clazz, String fileName, String codegen) { - String relativeGoldenDir = getTestoutGoldenDir(clazz); - Path testOutputDir = Paths.get("src", "test", "java", relativeGoldenDir); - - // Auto-detect project workspace when running `bazel run //:update_TargetTest`. - // TODO: remove when we don't use Bazel. - String workspaceDir = System.getenv("BUILD_WORKSPACE_DIRECTORY"); - if (workspaceDir != null) { - testOutputDir = Paths.get(workspaceDir).resolve(testOutputDir); - } else if (System.getProperty("updateUnitGoldens") == null) { + if (System.getProperty("updateUnitGoldens") == null) { return; } + String relativeGoldenDir = getTestoutGoldenDir(clazz); + Path testOutputDir = Paths.get("src", "test", "java", relativeGoldenDir); testOutputDir.toFile().mkdirs(); try (FileWriter myWriter = new FileWriter(testOutputDir.resolve(fileName).toFile())) { myWriter.write(codegen); From ac1aed3c6e2f2827c049d974febe739589e8cc00 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Thu, 17 Feb 2022 15:43:52 -0500 Subject: [PATCH 23/73] chore: fix names --- BUILD.bazel | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 4e843013d3..a8f50027cb 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -12,7 +12,7 @@ java_import( java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", - runtime_deps = [":gapic-generator-java"], + runtime_deps = [":gapic_generator_java"], ) # Request dumper binary, which dumps the CodeGeneratorRequest to a file on disk @@ -34,7 +34,7 @@ java_binary( java_binary( name = "protoc-gen-code_generator_request_dumper", main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper", - runtime_deps = [":gapic-generator-java"], + runtime_deps = [":gapic_generator_java"], ) # A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest @@ -47,7 +47,7 @@ java_binary( java_binary( name = "code_generator_request_file_to_gapic_main", main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", - runtime_deps = [":gapic-generator-java"], + runtime_deps = [":gapic_generator_java"], ) # google-java-format From 08012caebbcbad0f9ab713d036f45469cb9b2276 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Thu, 17 Feb 2022 15:48:59 -0500 Subject: [PATCH 24/73] chore: update DEVELOPMENT.md --- DEVELOPMENT.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index defb8b8f11..fb423ba488 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -127,6 +127,7 @@ ```sh mvn test -DupdateUnitGoldens ``` + This is inefficient for updating only a few golden files, as it runs all tests. - Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: From 860b4b12976b3e233538f0bec5e0f03feb2eeb79 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Thu, 17 Feb 2022 15:56:14 -0500 Subject: [PATCH 25/73] chore: update DEVELOPMENT.md --- DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index fb423ba488..8063666a52 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -129,7 +129,7 @@ ``` This is inefficient for updating only a few golden files, as it runs all tests. -- Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: +- Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: ```sh  mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest From bc006012917ab19eaadd40eee250941eb093d97e Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Thu, 17 Feb 2022 16:00:32 -0500 Subject: [PATCH 26/73] chore: fix Bazel CI --- .github/workflows/ci.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 64df39babd..edb0560597 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,7 +41,9 @@ jobs: echo "The old one will disappear after 7 days." - name: Integration Tests - run: bazel --batch test //test/integration/... + run: | + mvn package + bazel --batch test //test/integration/... - name: Gradle Build Generated Storage Client Library run: | From 9afa48691d076c4d1aca50330b9dc322b900e7b3 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Fri, 18 Feb 2022 15:29:17 -0500 Subject: [PATCH 27/73] chore: remove unnecessary file --- DEVELOPMENT.md | 6 +-- repositories.bzl | 96 ------------------------------------------------ 2 files changed, 3 insertions(+), 99 deletions(-) delete mode 100644 repositories.bzl diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 8063666a52..d4d2d80174 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -117,9 +117,9 @@ - Run a single or multiple unit tests: ```sh - mvn test -Dtest=JavaCodeGeneratorTest + mvn test -Dtest=JavaCodeGeneratorTest - mvn test "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]" + mvn test "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]" ```  - Update all unit test golden files: @@ -132,7 +132,7 @@ - Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: ```sh - mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest + mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest ``` - Run a single integration test for API like `Redis`, it generates Java source diff --git a/repositories.bzl b/repositories.bzl deleted file mode 100644 index 1c3a14f637..0000000000 --- a/repositories.bzl +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2019 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. - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") -load("//:PROPERTIES.bzl", "PROPERTIES") - -def gapic_generator_java_repositories(): - # Import dependencies shared between Gradle and Bazel (i.e. maven dependencies) - for name, artifact in PROPERTIES.items(): - _maybe( - jvm_maven_import_external, - name = name, - strip_repo_prefix = "maven.", - artifact = _fix_bazel_artifact_format(artifact), - server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"], - licenses = ["notice", "reciprocal"], - ) - - # Import Bazel-only dependencies (Gradle version will import maven artifacts of same - # version, while Bazel will depend on Bazel workspaces). The versions are shared in the - # properties file. - _protobuf_version = PROPERTIES["version.com_google_protobuf"] - _maybe( - http_archive, - name = "com_google_protobuf", - urls = ["https://github.com/protocolbuffers/protobuf/archive/v%s.zip" % _protobuf_version], - strip_prefix = "protobuf-%s" % _protobuf_version, - ) - - _maybe( - jvm_maven_import_external, - name = "google_java_format_all_deps", - artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:%s" % PROPERTIES["version.google_java_format"], - server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"], - licenses = ["notice", "reciprocal"], - ) - - _maybe( - http_archive, - name = "bazel_skylib", - sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d", - strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b", - urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"], - ) - - _maybe( - http_archive, - name = "com_google_googleapis", - strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c", - urls = [ - "https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip", - ], - ) - - _maybe( - native.bind, - name = "guava", - actual = "@com_google_guava_guava//jar", - ) - - _maybe( - native.bind, - name = "gson", - actual = "@com_google_code_gson_gson//jar", - ) - -def _maybe(repo_rule, name, strip_repo_prefix = "", **kwargs): - if not name.startswith(strip_repo_prefix): - return - repo_name = name[len(strip_repo_prefix):] - if repo_name in native.existing_rules(): - return - repo_rule(name = repo_name, **kwargs) - -def _fix_bazel_artifact_format(artifact_id): - # Fix the artifact id format discrepancy between Bazel & Gradle. - # This is relevant only when classifier is specified explicitly. - # Bazel format: groupId:artifactId:jar:classifier:version - # Gradle format: groupId:artifactId:version:classifier - ids = artifact_id.split(":") - if len(ids) != 4: - return artifact_id - return "%s:%s:%s:%s:%s" % (ids[0], ids[1], "jar", ids[3], ids[2]) From cd66e52f09ac8eb95b0b940d0fb393f6277df5f5 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Fri, 18 Feb 2022 15:32:50 -0500 Subject: [PATCH 28/73] chore: remove weird character --- DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index d4d2d80174..a937dfd8ed 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -121,7 +121,7 @@ mvn test "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]" ``` - + - Update all unit test golden files: ```sh From 527187e142a9c3272e6bb9e47aa6a59ec4a2f7b4 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 19 Oct 2022 22:26:59 -0400 Subject: [PATCH 29/73] deps: Upgrade googleapis to latest. --- .gitignore | 2 ++ WORKSPACE | 20 ++++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 913a2a8e6e..c8de661074 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ target/ # Vscode Settings .vscode/settings.json + +*.iml diff --git a/WORKSPACE b/WORKSPACE index 26d5a0ce02..674409cc50 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -41,30 +41,26 @@ load("@com_google_api_gax_java//:repositories.bzl", "com_google_api_gax_java_rep com_google_api_gax_java_repositories() http_archive( - name = "com_google_googleapis", - strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c", - urls = [ - "https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip", - ], - ) - -load("//:repositories.bzl", "gapic_generator_java_repositories") - -gapic_generator_java_repositories() + name = "com_google_googleapis", + strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c", + urls = [ + "https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip", + ], +) # protobuf RULES_JVM_EXTERNAL_TAG = "4.2" + RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca" http_archive( name = "rules_jvm_external", - strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, 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("@com_google_protobuf//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps") - load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( From 0b00473642153b4d0814dd154093375a884934a9 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 9 Nov 2022 13:49:35 -0500 Subject: [PATCH 30/73] chore: Load jar from local maven repo instead of from target folder. --- BUILD.bazel | 3 ++- WORKSPACE | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index f3d469fefa..b98c2b3aec 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -8,10 +8,11 @@ java_import( # filesystem, GCS bucket, Maven repositories, etc. jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], ) + java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", - runtime_deps = [":gapic_generator_java"], + runtime_deps = ["@maven//:com_google_api_gapic"], ) # Request dumper binary, which dumps the CodeGeneratorRequest to a file on disk diff --git a/WORKSPACE b/WORKSPACE index 674409cc50..508f0593ef 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -49,9 +49,9 @@ http_archive( ) # protobuf -RULES_JVM_EXTERNAL_TAG = "4.2" +RULES_JVM_EXTERNAL_TAG = "4.5" -RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca" +RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6" http_archive( name = "rules_jvm_external", @@ -60,6 +60,14 @@ http_archive( 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("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") + +rules_jvm_external_setup() + load("@com_google_protobuf//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps") load("@rules_jvm_external//:defs.bzl", "maven_install") @@ -68,6 +76,17 @@ maven_install( repositories = ["https://repo.maven.apache.org/maven2/"], ) +maven_install( + artifacts = [ + "com.google.api:gapic-generator-java:0.0.1-SNAPSHOT", + ], + fail_on_missing_checksum = True, + repositories = [ + "m2Local", + "https://repo.maven.apache.org/maven2/", + ], +) + protobuf_deps() # Bazel rules. From 16bfc2915a0fa353b59b2cb3312e1a09fcf33160 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 13 Dec 2022 17:32:43 -0500 Subject: [PATCH 31/73] chore: Skip clirr check. --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index e2055cdde6..613d46e3dc 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,7 @@ true true + true UTF-8 44d6bef0ca6db8bba3fb324c8186e694bcc4829c From afc32344e7568079e4b508ecd5a0990cebe3d74d Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 13 Dec 2022 22:34:02 -0500 Subject: [PATCH 32/73] Used release gapic-generator-java jar --- BUILD.bazel | 13 +++---------- WORKSPACE | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index b98c2b3aec..d2a67f4eee 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -2,17 +2,10 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_proto_library") package(default_visibility = ["//visibility:public"]) -java_import( - name = "gapic_generator_java", - # Note referring to target/ is only for local development; you can also pull from remote - # filesystem, GCS bucket, Maven repositories, etc. - jars = ["target/gapic-generator-java-0.0.1-SNAPSHOT.jar"], -) - java_binary( name = "protoc-gen-java_gapic", main_class = "com.google.api.generator.Main", - runtime_deps = ["@maven//:com_google_api_gapic"], + runtime_deps = ["@maven//:com_google_api_gapic_generator_java"], ) # Request dumper binary, which dumps the CodeGeneratorRequest to a file on disk @@ -34,7 +27,7 @@ java_binary( java_binary( name = "protoc-gen-code_generator_request_dumper", main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper", - runtime_deps = [":gapic_generator_java"], + runtime_deps = ["@maven//:com_google_api_gapic_generator_java"], ) # A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest @@ -47,7 +40,7 @@ java_binary( java_binary( name = "code_generator_request_file_to_gapic_main", main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", - runtime_deps = [":gapic_generator_java"], + runtime_deps = ["@maven//:com_google_api_gapic_generator_java"], ) # google-java-format diff --git a/WORKSPACE b/WORKSPACE index 978ba17dfd..1b75f73c7b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -80,7 +80,7 @@ maven_install( maven_install( artifacts = [ - "com.google.api:gapic-generator-java:0.0.1-SNAPSHOT", + "com.google.api:gapic-generator-java:2.12.0", ], fail_on_missing_checksum = True, repositories = [ From 605a2baa2d20b7f39bbf8e201bc4bde4a794f38b Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 21 Dec 2022 01:22:59 -0500 Subject: [PATCH 33/73] Rely on release please to update gapic-generator-java version --- PROPERTIES.bzl | 0 WORKSPACE | 6 ++++-- 2 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 PROPERTIES.bzl diff --git a/PROPERTIES.bzl b/PROPERTIES.bzl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/WORKSPACE b/WORKSPACE index 1b75f73c7b..944a22c3f6 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -78,11 +78,13 @@ maven_install( repositories = ["https://repo.maven.apache.org/maven2/"], ) +_gapic_generator_java_version = "2.12.1-SNAPSHOT" # {x-version-update:gapic-generator-java:current} + maven_install( artifacts = [ - "com.google.api:gapic-generator-java:2.12.0", + "com.google.api:gapic-generator-java:" + _gapic_generator_java_version, ], - fail_on_missing_checksum = True, + fail_on_missing_checksum = False, repositories = [ "m2Local", "https://repo.maven.apache.org/maven2/", From a234a8baaef3f1b7fedbed39d43c1c95d01b4483 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 21 Dec 2022 01:38:44 -0500 Subject: [PATCH 34/73] Remove unused bazel rules --- BUILD.bazel | 8 -------- WORKSPACE | 14 -------------- 2 files changed, 22 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index d2a67f4eee..024d063ae7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -42,11 +42,3 @@ java_binary( main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", runtime_deps = ["@maven//:com_google_api_gapic_generator_java"], ) - -# google-java-format -java_binary( - name = "google_java_format_binary", - jvm_flags = ["-Xmx512m"], - main_class = "com.google.googlejavaformat.java.Main", - runtime_deps = ["@google_java_format_all_deps//jar"], -) diff --git a/WORKSPACE b/WORKSPACE index 944a22c3f6..847f3604d9 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,20 +1,6 @@ workspace(name = "gapic_generator_java") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") - -jvm_maven_import_external( - name = "google_java_format_all_deps", - artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:1.7", - licenses = [ - "notice", - "reciprocal", - ], - server_urls = [ - "https://repo.maven.apache.org/maven2/", - "http://repo1.maven.org/maven2/", - ], -) # gax-java and its transitive dependencies must be imported before # gapic-generator-java dependencies to match the order in googleapis repository, From 56f78e6d5835c2379c6418fc80e28137e93efe13 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 21 Dec 2022 01:47:57 -0500 Subject: [PATCH 35/73] Build gapic-generator-java in integration tests. --- .github/workflows/ci.yaml | 2 +- WORKSPACE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8aaf8c1594..d2c505d18c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: - name: Integration Tests run: | - mvn package + mvn clean install -B -DskipTests=true -Dclirr.skip=true -f gapic-generator-java/ bazel --batch test //test/integration/... - uses: actions/upload-artifact@v3 diff --git a/WORKSPACE b/WORKSPACE index 847f3604d9..043384a509 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -64,7 +64,7 @@ maven_install( repositories = ["https://repo.maven.apache.org/maven2/"], ) -_gapic_generator_java_version = "2.12.1-SNAPSHOT" # {x-version-update:gapic-generator-java:current} +_gapic_generator_java_version = "2.12.1-SNAPSHOT" # {x-version-update:gapic-generator-java:current} maven_install( artifacts = [ From 5810cbaa41cd962446f8bedd01aefae3d9f437c0 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 21 Dec 2022 11:53:23 -0500 Subject: [PATCH 36/73] Build gapic-generator-java in integration tests. --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d2c505d18c..7093413e07 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: - name: Integration Tests run: | - mvn clean install -B -DskipTests=true -Dclirr.skip=true -f gapic-generator-java/ + mvn -B -ntp verify --projects 'gapic-generator-java' -Dcheckstyle.skip -Dfmt.skip bazel --batch test //test/integration/... - uses: actions/upload-artifact@v3 From 1964b8a4d193736daf14c3d419b9dc3e744ea2f6 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 21 Dec 2022 12:00:36 -0500 Subject: [PATCH 37/73] Add google_java_format_binary back --- BUILD.bazel | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index 024d063ae7..d2a67f4eee 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -42,3 +42,11 @@ java_binary( main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain", runtime_deps = ["@maven//:com_google_api_gapic_generator_java"], ) + +# google-java-format +java_binary( + name = "google_java_format_binary", + jvm_flags = ["-Xmx512m"], + main_class = "com.google.googlejavaformat.java.Main", + runtime_deps = ["@google_java_format_all_deps//jar"], +) From 103d0065c2d99fa1b8f2f3b612bda4fc64065c1b Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 21 Dec 2022 12:12:38 -0500 Subject: [PATCH 38/73] Build all modules in integration tests. --- .github/workflows/ci.yaml | 2 +- gapic-generator-java/pom.xml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7093413e07..01a8414e1b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: - name: Integration Tests run: | - mvn -B -ntp verify --projects 'gapic-generator-java' -Dcheckstyle.skip -Dfmt.skip + mvn -B -ntp install -DskipTests -Dcheckstyle.skip -Dfmt.skip bazel --batch test //test/integration/... - uses: actions/upload-artifact@v3 diff --git a/gapic-generator-java/pom.xml b/gapic-generator-java/pom.xml index 3a3a929a89..7bc332561e 100644 --- a/gapic-generator-java/pom.xml +++ b/gapic-generator-java/pom.xml @@ -7,8 +7,6 @@ 2.12.1-SNAPSHOT - true - true true UTF-8 From 42de4ddc008640bf280f3dfd5d0d5cbd27c8ba58 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 21 Dec 2022 13:18:24 -0500 Subject: [PATCH 39/73] Run integration tests in ci-maven --- .github/workflows/ci-maven.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 15ba07a36e..d22f607b70 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -20,8 +20,12 @@ jobs: - run: java -version - name: Unit Tests run: | - mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \ + mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip + - run: bazelisk version + - name: Integration Tests + run: | + bazel --batch test //test/integration/... units-java8: name: "units (8) except gapic-generator-java" @@ -87,8 +91,12 @@ jobs: - name: Run test only for gapic-generator-java using Java 8 shell: bash run: | - mvn -B -ntp verify --projects 'gapic-generator-java' \ + mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip + - run: bazelisk version + - name: Integration Tests + run: | + bazel --batch test //test/integration/... lint: runs-on: ubuntu-latest From 4239533cd0598b558e470ed0ded40901a96a07aa Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 12:42:18 -0800 Subject: [PATCH 40/73] Delete Bazel ci and move necessary steps to ci-maven --- .github/workflows/ci-maven.yaml | 50 ++++++++++++-- .github/workflows/ci.yaml | 117 -------------------------------- 2 files changed, 44 insertions(+), 123 deletions(-) delete mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 91b5b516a9..c03c12034a 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -7,7 +7,7 @@ name: ci-maven env: SHOWCASE_VERSION: 0.25.0 jobs: - units: + build: runs-on: ubuntu-latest strategy: matrix: @@ -28,8 +28,27 @@ jobs: - name: Integration Tests run: | bazel --batch test //test/integration/... +# - name: Gradle Build Generated Storage Client Library +# run: | +# echo "Building Storage lib from generated source..." +# mkdir /tmp/java-storage +# bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java +# tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage +# pushd /tmp/java-storage/google-cloud-storage-v2-java +# ./gradlew clean build publishToMavenLocal sourcesJar allJars +# popd +# +# - name: Gradle Build Generated Compute Client Library +# run: | +# echo "Building Compute lib from generated source..." +# mkdir /tmp/java-compute +# bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java +# tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute +# pushd /tmp/java-compute/google-cloud-compute-small-v1-java +# ./gradlew clean build publishToMavenLocal sourcesJar allJars +# popd - units-java8: + build-java8(except gapic-generator-java): name: "units (8) except gapic-generator-java" runs-on: ubuntu-latest steps: @@ -69,7 +88,7 @@ jobs: -Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \ -Dfmt.skip - units-java8-gapic-generator-java: + build-java8-gapic-generator-java: name: "units (8) for gapic-generator-java" runs-on: ubuntu-latest steps: @@ -90,15 +109,34 @@ jobs: distribution: temurin cache: maven - run: java -version - - name: Run test only for gapic-generator-java using Java 8 + - name: Run unit tests and install gapic-generator-java using Java 8 shell: bash run: | - mvn -B -ntp verify --projects 'gapic-generator-java' \ + mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - name: Integration Tests run: | - bazel --batch test //test/integration/... + bazelisk --batch test //test/integration/... +# - name: Gradle Build Generated Storage Client Library +# run: | +# echo "Building Storage lib from generated source..." +# mkdir /tmp/java-storage +# bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java +# tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage +# pushd /tmp/java-storage/google-cloud-storage-v2-java +# ./gradlew clean build publishToMavenLocal sourcesJar allJars +# popd +# +# - name: Gradle Build Generated Compute Client Library +# run: | +# echo "Building Compute lib from generated source..." +# mkdir /tmp/java-compute +# bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java +# tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute +# pushd /tmp/java-compute/google-cloud-compute-small-v1-java +# ./gradlew clean build publishToMavenLocal sourcesJar allJars +# popd lint: runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index b7e731a3c7..0000000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,117 +0,0 @@ -on: - push: - branches: - - main - pull_request: -name: ci -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - java: [ 8, 11 ] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: temurin - - run: java -version - - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old one will disappear after 7 days." - - - name: Integration Tests - run: | - mvn -B -ntp install -DskipTests -Dcheckstyle.skip -Dfmt.skip - bazel --batch test //test/integration/... - - - uses: actions/upload-artifact@v3 - if: ${{ failure() }} - with: - name: test-artifacts - path: ~/.cache/bazel/*/*/*/gapic_generator_java/bazel-out/*/testlogs/* - retention-days: 5 - - generate-client-libraries: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - java: [ 8, 11 ] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: temurin - - run: java -version - - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - - - name: Gradle Build Generated Storage Client Library - run: | - echo "Building Storage lib from generated source..." - mkdir /tmp/java-storage - bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java - tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage - pushd /tmp/java-storage/google-cloud-storage-v2-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - - name: Gradle Build Generated Compute Client Library - run: | - echo "Building Compute lib from generated source..." - mkdir /tmp/java-compute - bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java - tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute - pushd /tmp/java-compute/google-cloud-compute-small-v1-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - license-header: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v3 - with: - go-version: '^1.13.1' - - name: License Header Check - run: | - go install github.com/google/addlicense@latest - addlicense -c "Google LLC" -l apache -check $(find $PWD -type f -name '*.java' ! -path '**/showcase/**' ! -iname '*PlaceholderFile.java') - From 21704d65050fec7193ec7408305165effb723062 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 13:19:17 -0800 Subject: [PATCH 41/73] Rename ci-maven.yaml to ci.yaml --- .github/workflows/{ci-maven.yaml => ci.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci-maven.yaml => ci.yaml} (100%) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci.yaml similarity index 100% rename from .github/workflows/ci-maven.yaml rename to .github/workflows/ci.yaml From c0f03eb8155d0c93dd872d3ffa151e04096a69a0 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 13:32:34 -0800 Subject: [PATCH 42/73] Revert "Rename ci-maven.yaml to ci.yaml" This reverts commit 21704d65050fec7193ec7408305165effb723062. --- .github/workflows/{ci.yaml => ci-maven.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci.yaml => ci-maven.yaml} (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci-maven.yaml similarity index 100% rename from .github/workflows/ci.yaml rename to .github/workflows/ci-maven.yaml From fee244124388d7a974728e2893e9c5a7bb440a7f Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 13:32:59 -0800 Subject: [PATCH 43/73] Revert "Delete Bazel ci and move necessary steps to ci-maven" This reverts commit 4239533cd0598b558e470ed0ded40901a96a07aa. --- .github/workflows/ci-maven.yaml | 50 ++------------ .github/workflows/ci.yaml | 117 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index c03c12034a..91b5b516a9 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -7,7 +7,7 @@ name: ci-maven env: SHOWCASE_VERSION: 0.25.0 jobs: - build: + units: runs-on: ubuntu-latest strategy: matrix: @@ -28,27 +28,8 @@ jobs: - name: Integration Tests run: | bazel --batch test //test/integration/... -# - name: Gradle Build Generated Storage Client Library -# run: | -# echo "Building Storage lib from generated source..." -# mkdir /tmp/java-storage -# bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java -# tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage -# pushd /tmp/java-storage/google-cloud-storage-v2-java -# ./gradlew clean build publishToMavenLocal sourcesJar allJars -# popd -# -# - name: Gradle Build Generated Compute Client Library -# run: | -# echo "Building Compute lib from generated source..." -# mkdir /tmp/java-compute -# bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java -# tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute -# pushd /tmp/java-compute/google-cloud-compute-small-v1-java -# ./gradlew clean build publishToMavenLocal sourcesJar allJars -# popd - build-java8(except gapic-generator-java): + units-java8: name: "units (8) except gapic-generator-java" runs-on: ubuntu-latest steps: @@ -88,7 +69,7 @@ jobs: -Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \ -Dfmt.skip - build-java8-gapic-generator-java: + units-java8-gapic-generator-java: name: "units (8) for gapic-generator-java" runs-on: ubuntu-latest steps: @@ -109,34 +90,15 @@ jobs: distribution: temurin cache: maven - run: java -version - - name: Run unit tests and install gapic-generator-java using Java 8 + - name: Run test only for gapic-generator-java using Java 8 shell: bash run: | - mvn -B -ntp install --projects 'gapic-generator-java' \ + mvn -B -ntp verify --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - name: Integration Tests run: | - bazelisk --batch test //test/integration/... -# - name: Gradle Build Generated Storage Client Library -# run: | -# echo "Building Storage lib from generated source..." -# mkdir /tmp/java-storage -# bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java -# tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage -# pushd /tmp/java-storage/google-cloud-storage-v2-java -# ./gradlew clean build publishToMavenLocal sourcesJar allJars -# popd -# -# - name: Gradle Build Generated Compute Client Library -# run: | -# echo "Building Compute lib from generated source..." -# mkdir /tmp/java-compute -# bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java -# tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute -# pushd /tmp/java-compute/google-cloud-compute-small-v1-java -# ./gradlew clean build publishToMavenLocal sourcesJar allJars -# popd + bazel --batch test //test/integration/... lint: runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000000..b7e731a3c7 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,117 @@ +on: + push: + branches: + - main + pull_request: +name: ci +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [ 8, 11 ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: temurin + - run: java -version + - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old one will disappear after 7 days." + + - name: Integration Tests + run: | + mvn -B -ntp install -DskipTests -Dcheckstyle.skip -Dfmt.skip + bazel --batch test //test/integration/... + + - uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: test-artifacts + path: ~/.cache/bazel/*/*/*/gapic_generator_java/bazel-out/*/testlogs/* + retention-days: 5 + + generate-client-libraries: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [ 8, 11 ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: temurin + - run: java -version + - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." + + - name: Gradle Build Generated Storage Client Library + run: | + echo "Building Storage lib from generated source..." + mkdir /tmp/java-storage + bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java + tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage + pushd /tmp/java-storage/google-cloud-storage-v2-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + - name: Gradle Build Generated Compute Client Library + run: | + echo "Building Compute lib from generated source..." + mkdir /tmp/java-compute + bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java + tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute + pushd /tmp/java-compute/google-cloud-compute-small-v1-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + license-header: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v3 + with: + go-version: '^1.13.1' + - name: License Header Check + run: | + go install github.com/google/addlicense@latest + addlicense -c "Google LLC" -l apache -check $(find $PWD -type f -name '*.java' ! -path '**/showcase/**' ! -iname '*PlaceholderFile.java') + From af7b838ec0fd422183c168bad51cb9f97a424745 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 13:58:53 -0800 Subject: [PATCH 44/73] Remove uncessary Bazel builds and comment out some Bazel checks. --- .github/workflows/ci-maven.yaml | 10 +- .github/workflows/ci.yaml | 165 +++++++++++--------------------- 2 files changed, 60 insertions(+), 115 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 91b5b516a9..5d10124722 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -7,7 +7,7 @@ name: ci-maven env: SHOWCASE_VERSION: 0.25.0 jobs: - units: + build: runs-on: ubuntu-latest strategy: matrix: @@ -29,7 +29,7 @@ jobs: run: | bazel --batch test //test/integration/... - units-java8: + build-java8-except-gapic-generator-java: name: "units (8) except gapic-generator-java" runs-on: ubuntu-latest steps: @@ -69,7 +69,7 @@ jobs: -Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \ -Dfmt.skip - units-java8-gapic-generator-java: + build-java8-gapic-generator-java: name: "units (8) for gapic-generator-java" runs-on: ubuntu-latest steps: @@ -93,12 +93,12 @@ jobs: - name: Run test only for gapic-generator-java using Java 8 shell: bash run: | - mvn -B -ntp verify --projects 'gapic-generator-java' \ + mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - name: Integration Tests run: | - bazel --batch test //test/integration/... + bazelisk --batch test //test/integration/... lint: runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b7e731a3c7..a403014ebc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,117 +1,62 @@ on: push: branches: - - main + - main pull_request: name: ci jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - java: [ 8, 11 ] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: temurin - - run: java -version - - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old one will disappear after 7 days." - - - name: Integration Tests - run: | - mvn -B -ntp install -DskipTests -Dcheckstyle.skip -Dfmt.skip - bazel --batch test //test/integration/... - - - uses: actions/upload-artifact@v3 - if: ${{ failure() }} - with: - name: test-artifacts - path: ~/.cache/bazel/*/*/*/gapic_generator_java/bazel-out/*/testlogs/* - retention-days: 5 - - generate-client-libraries: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - java: [ 8, 11 ] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: temurin - - run: java -version - - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - - - name: Gradle Build Generated Storage Client Library - run: | - echo "Building Storage lib from generated source..." - mkdir /tmp/java-storage - bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java - tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage - pushd /tmp/java-storage/google-cloud-storage-v2-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - - name: Gradle Build Generated Compute Client Library - run: | - echo "Building Compute lib from generated source..." - mkdir /tmp/java-compute - bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java - tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute - pushd /tmp/java-compute/google-cloud-compute-small-v1-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - license-header: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v3 - with: - go-version: '^1.13.1' - - name: License Header Check - run: | - go install github.com/google/addlicense@latest - addlicense -c "Google LLC" -l apache -check $(find $PWD -type f -name '*.java' ! -path '**/showcase/**' ! -iname '*PlaceholderFile.java') +# Due to the circular dependencies in the integration tests between googleapis and gapic-generator-java, +# this check will not work until we update googleapis to use the Maven jar +# generate-client-libraries: +# runs-on: ubuntu-latest +# strategy: +# fail-fast: false +# matrix: +# java: [ 8, 11 ] +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/setup-java@v3 +# with: +# java-version: ${{ matrix.java }} +# distribution: temurin +# - run: java -version +# - run: bazelisk version +# - name: Bazel File Cache Setup +# id: cache-bazel +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- +# - name: Bazel Cache Not Found +# if: steps.cache-bazel.outputs.cache-hit != 'true' +# run: | +# echo "No cache found." +# - name: Bazel Cache Found +# if: steps.cache-bazel.outputs.cache-hit == 'true' +# run: | +# echo -n "Cache found. Cache size: " +# du -sh ~/.cache/bazel +# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." +# echo "The old cache will disappear after 7 days." +# +# - name: Gradle Build Generated Storage Client Library +# run: | +# echo "Building Storage lib from generated source..." +# mkdir /tmp/java-storage +# bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java +# tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage +# pushd /tmp/java-storage/google-cloud-storage-v2-java +# ./gradlew clean build publishToMavenLocal sourcesJar allJars +# popd +# +# - name: Gradle Build Generated Compute Client Library +# run: | +# echo "Building Compute lib from generated source..." +# mkdir /tmp/java-compute +# bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java +# tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute +# pushd /tmp/java-compute/google-cloud-compute-small-v1-java +# ./gradlew clean build publishToMavenLocal sourcesJar allJars +# popd From dac6afd381eef725eb01dcb458d31dc763d5ab20 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 14:09:00 -0800 Subject: [PATCH 45/73] Add minimum github action steps for `generate-client-libraries` step --- .github/workflows/ci.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a403014ebc..86165fff19 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,20 +7,20 @@ name: ci jobs: # Due to the circular dependencies in the integration tests between googleapis and gapic-generator-java, # this check will not work until we update googleapis to use the Maven jar -# generate-client-libraries: -# runs-on: ubuntu-latest -# strategy: -# fail-fast: false -# matrix: -# java: [ 8, 11 ] -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-java@v3 -# with: -# java-version: ${{ matrix.java }} -# distribution: temurin -# - run: java -version -# - run: bazelisk version + generate-client-libraries: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [ 8, 11 ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: temurin + - run: java -version + - run: bazelisk version # - name: Bazel File Cache Setup # id: cache-bazel # uses: actions/cache@v3 From 55a3bc8431cfd1853775838d099b23e539a2584d Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 14:43:42 -0800 Subject: [PATCH 46/73] Rename steps --- .github/workflows/ci-maven.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 5d10124722..d135ffdb56 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -30,7 +30,7 @@ jobs: bazel --batch test //test/integration/... build-java8-except-gapic-generator-java: - name: "units (8) except gapic-generator-java" + name: "unit tests except gapic-generator-java in Java 8" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -70,7 +70,7 @@ jobs: -Dfmt.skip build-java8-gapic-generator-java: - name: "units (8) for gapic-generator-java" + name: "unit and integration tests for gapic-generator-java in Java 8" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 872f419e5f42b3cb6b1b266c00dfe79245956f3a Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 14:47:58 -0800 Subject: [PATCH 47/73] Add gradle build generated libraries --- .github/workflows/ci-maven.yaml | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index d135ffdb56..a701c6ae4a 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -28,6 +28,25 @@ jobs: - name: Integration Tests run: | bazel --batch test //test/integration/... + - name: Gradle Build Generated Storage Client Library + run: | + echo "Building Storage lib from generated source..." + mkdir /tmp/java-storage + bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java + tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage + pushd /tmp/java-storage/google-cloud-storage-v2-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + - name: Gradle Build Generated Compute Client Library + run: | + echo "Building Compute lib from generated source..." + mkdir /tmp/java-compute + bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java + tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute + pushd /tmp/java-compute/google-cloud-compute-small-v1-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd build-java8-except-gapic-generator-java: name: "unit tests except gapic-generator-java in Java 8" @@ -99,6 +118,25 @@ jobs: - name: Integration Tests run: | bazelisk --batch test //test/integration/... + - name: Gradle Build Generated Storage Client Library + run: | + echo "Building Storage lib from generated source..." + mkdir /tmp/java-storage + bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java + tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage + pushd /tmp/java-storage/google-cloud-storage-v2-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + - name: Gradle Build Generated Compute Client Library + run: | + echo "Building Compute lib from generated source..." + mkdir /tmp/java-compute + bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java + tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute + pushd /tmp/java-compute/google-cloud-compute-small-v1-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd lint: runs-on: ubuntu-latest From b5eb03d4207438173ea06f1dc9c31f987065d054 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 14:57:42 -0800 Subject: [PATCH 48/73] Rename steps --- .github/workflows/ci-maven.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index a701c6ae4a..0c7ab5747a 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -49,7 +49,7 @@ jobs: popd build-java8-except-gapic-generator-java: - name: "unit tests except gapic-generator-java in Java 8" + name: "build(8) except for gapic-generator-java" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -89,7 +89,7 @@ jobs: -Dfmt.skip build-java8-gapic-generator-java: - name: "unit and integration tests for gapic-generator-java in Java 8" + name: "build(8) for gapic-generator-java" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 08dbe8c371c9652772733a2caaf2aeea6a74a578 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 15:29:48 -0800 Subject: [PATCH 49/73] Add bazel cache --- .github/workflows/ci-maven.yaml | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 0c7ab5747a..cb84e39df4 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,6 +25,25 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." + - name: Integration Tests run: | bazel --batch test //test/integration/... @@ -115,6 +134,24 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Integration Tests run: | bazelisk --batch test //test/integration/... From d883362614fd1a88ee3245cedf3be1efab7de904 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 16:32:21 -0800 Subject: [PATCH 50/73] Update DEVELOPMENT.md --- DEVELOPMENT.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 8d075477a0..e7c508066b 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -49,13 +49,6 @@ mvn test "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]" ``` -- Update all unit test golden files: - - ```sh - mvn test -DupdateUnitGoldens - ``` - This is inefficient for updating only a few golden files, as it runs all tests. - - Update all unit test golden files: ```sh @@ -64,10 +57,6 @@ - Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: - ```sh - bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest - ``` - or ```sh mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest ``` From ed491f82a761e6732679128ee7e7d70b9126d0de Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 16:34:41 -0800 Subject: [PATCH 51/73] Reformat ci-maven.yml --- .github/workflows/ci-maven.yaml | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index cb84e39df4..515da8a209 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -32,17 +32,17 @@ jobs: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Integration Tests run: | @@ -141,17 +141,17 @@ jobs: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Integration Tests run: | bazelisk --batch test //test/integration/... From 62896d06642ceb07017d402af213ce0c7dc9c655 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 16:37:06 -0800 Subject: [PATCH 52/73] Comment out bazel cache --- .github/workflows/ci-maven.yaml | 72 ++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 515da8a209..d4adf1d476 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,24 +25,24 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." +# - name: Bazel File Cache Setup +# id: cache-bazel +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- +# - name: Bazel Cache Not Found +# if: steps.cache-bazel.outputs.cache-hit != 'true' +# run: | +# echo "No cache found." +# - name: Bazel Cache Found +# if: steps.cache-bazel.outputs.cache-hit == 'true' +# run: | +# echo -n "Cache found. Cache size: " +# du -sh ~/.cache/bazel +# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." +# echo "The old cache will disappear after 7 days." - name: Integration Tests run: | @@ -134,24 +134,24 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." +# - name: Bazel File Cache Setup +# id: cache-bazel +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- +# - name: Bazel Cache Not Found +# if: steps.cache-bazel.outputs.cache-hit != 'true' +# run: | +# echo "No cache found." +# - name: Bazel Cache Found +# if: steps.cache-bazel.outputs.cache-hit == 'true' +# run: | +# echo -n "Cache found. Cache size: " +# du -sh ~/.cache/bazel +# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." +# echo "The old cache will disappear after 7 days." - name: Integration Tests run: | bazelisk --batch test //test/integration/... From 9f276615cf46c48834343a1d5534582d6167c16e Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 27 Dec 2022 16:53:19 -0800 Subject: [PATCH 53/73] Add Bazel cache back and remove id for steps --- .github/workflows/ci-maven.yaml | 71 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index d4adf1d476..00eefd4f64 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,24 +25,23 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version -# - name: Bazel File Cache Setup -# id: cache-bazel -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- -# - name: Bazel Cache Not Found -# if: steps.cache-bazel.outputs.cache-hit != 'true' -# run: | -# echo "No cache found." -# - name: Bazel Cache Found -# if: steps.cache-bazel.outputs.cache-hit == 'true' -# run: | -# echo -n "Cache found. Cache size: " -# du -sh ~/.cache/bazel -# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." -# echo "The old cache will disappear after 7 days." + - name: Bazel File Cache Setup + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Integration Tests run: | @@ -134,24 +133,23 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version -# - name: Bazel File Cache Setup -# id: cache-bazel -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- -# - name: Bazel Cache Not Found -# if: steps.cache-bazel.outputs.cache-hit != 'true' -# run: | -# echo "No cache found." -# - name: Bazel Cache Found -# if: steps.cache-bazel.outputs.cache-hit == 'true' -# run: | -# echo -n "Cache found. Cache size: " -# du -sh ~/.cache/bazel -# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." -# echo "The old cache will disappear after 7 days." + - name: Bazel File Cache Setup + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Integration Tests run: | bazelisk --batch test //test/integration/... @@ -203,7 +201,6 @@ jobs: - run: java -version - name: Bazel File Cache Setup - id: cache-bazel uses: actions/cache@v3 with: path: ~/.cache/bazel From 407fdb90285a82d459452a1d5b6de0ad8cd4d92b Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 07:28:49 -0800 Subject: [PATCH 54/73] Give different id for bazel cache steps --- .github/workflows/ci-maven.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 00eefd4f64..adfe51a0fa 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -26,17 +26,18 @@ jobs: -Dfmt.skip - run: bazelisk version - name: Bazel File Cache Setup + id: cache-bazel-build uses: actions/cache@v3 with: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' + if: steps.cache-bazel-build.outputs.cache-hit != 'true' run: | echo "No cache found." - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' + if: steps.cache-bazel-build.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " du -sh ~/.cache/bazel @@ -134,17 +135,18 @@ jobs: -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - name: Bazel File Cache Setup + id: cache-bazel-build-8 uses: actions/cache@v3 with: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' + if: steps.cache-bazel-build-8.outputs.cache-hit != 'true' run: | echo "No cache found." - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' + if: steps.cache-bazel-build-8.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " du -sh ~/.cache/bazel From 6f541e94666a1d66b38f9d66af947422d3f364f4 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 19:30:55 -0800 Subject: [PATCH 55/73] Give different names to bazel cache steps --- .github/workflows/ci-maven.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index adfe51a0fa..a0e2da5afc 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,18 +25,18 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup + - name: Bazel File Cache Setup${{ matrix.java }} id: cache-bazel-build uses: actions/cache@v3 with: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found + - name: Bazel Cache Not Found${{ matrix.java }} if: steps.cache-bazel-build.outputs.cache-hit != 'true' run: | echo "No cache found." - - name: Bazel Cache Found + - name: Bazel Cache Found${{ matrix.java }} if: steps.cache-bazel-build.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " @@ -134,18 +134,18 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup + - name: Bazel File Cache Setup(8) id: cache-bazel-build-8 uses: actions/cache@v3 with: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found + - name: Bazel Cache Not Found(8) if: steps.cache-bazel-build-8.outputs.cache-hit != 'true' run: | echo "No cache found." - - name: Bazel Cache Found + - name: Bazel Cache Found(8) if: steps.cache-bazel-build-8.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " From 8499934e29199a4e5aacaf078637872ab21fec2a Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 19:33:34 -0800 Subject: [PATCH 56/73] Comment out bazel cahce --- .github/workflows/ci-maven.yaml | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index a0e2da5afc..8102407d1b 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,24 +25,24 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup${{ matrix.java }} - id: cache-bazel-build - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found${{ matrix.java }} - if: steps.cache-bazel-build.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found${{ matrix.java }} - if: steps.cache-bazel-build.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." +# - name: Bazel File Cache Setup${{ matrix.java }} +# id: cache-bazel-build +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- +# - name: Bazel Cache Not Found${{ matrix.java }} +# if: steps.cache-bazel-build.outputs.cache-hit != 'true' +# run: | +# echo "No cache found." +# - name: Bazel Cache Found${{ matrix.java }} +# if: steps.cache-bazel-build.outputs.cache-hit == 'true' +# run: | +# echo -n "Cache found. Cache size: " +# du -sh ~/.cache/bazel +# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." +# echo "The old cache will disappear after 7 days." - name: Integration Tests run: | From 4e52db11b65f96d8f888f17d228ffb1658c04128 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 19:55:46 -0800 Subject: [PATCH 57/73] Reformat step names --- .github/workflows/ci-maven.yaml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 8102407d1b..45e27a024a 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -26,12 +26,12 @@ jobs: -Dfmt.skip - run: bazelisk version # - name: Bazel File Cache Setup${{ matrix.java }} -# id: cache-bazel-build -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- +# id: cache-bazel-build +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- # - name: Bazel Cache Not Found${{ matrix.java }} # if: steps.cache-bazel-build.outputs.cache-hit != 'true' # run: | @@ -134,18 +134,17 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup(8) - id: cache-bazel-build-8 - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found(8) - if: steps.cache-bazel-build-8.outputs.cache-hit != 'true' + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' run: | echo "No cache found." - - name: Bazel Cache Found(8) + - name: Bazel Cache Found if: steps.cache-bazel-build-8.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " From 708272dfcf832df242db51a8679198214cb8da78 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 19:58:57 -0800 Subject: [PATCH 58/73] Reformat steps --- .github/workflows/ci-maven.yaml | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 45e27a024a..82cc75c261 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,24 +25,24 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version -# - name: Bazel File Cache Setup${{ matrix.java }} -# id: cache-bazel-build -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- -# - name: Bazel Cache Not Found${{ matrix.java }} -# if: steps.cache-bazel-build.outputs.cache-hit != 'true' -# run: | -# echo "No cache found." -# - name: Bazel Cache Found${{ matrix.java }} -# if: steps.cache-bazel-build.outputs.cache-hit == 'true' -# run: | -# echo -n "Cache found. Cache size: " -# du -sh ~/.cache/bazel -# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." -# echo "The old cache will disappear after 7 days." + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found${{ matrix.java }} + if: steps.cache-bazel-build.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found${{ matrix.java }} + if: steps.cache-bazel-build.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Integration Tests run: | From 5bf16a2b662a69bd2b43cf78156e63f7b39f8e7d Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 20:05:58 -0800 Subject: [PATCH 59/73] Add restore hash key --- .github/workflows/ci-maven.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index 82cc75c261..e273b34dd9 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -140,6 +140,7 @@ jobs: with: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }} - name: Bazel Cache Not Found if: steps.cache-bazel.outputs.cache-hit != 'true' run: | From 7a9971fc07ae746a849f00031647c2d5471b52cd Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 20:38:54 -0800 Subject: [PATCH 60/73] Add restore hash key --- .github/workflows/ci-maven.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index e273b34dd9..b0632239de 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -32,11 +32,11 @@ jobs: path: ~/.cache/bazel key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found${{ matrix.java }} + - name: Bazel Cache Not Found if: steps.cache-bazel-build.outputs.cache-hit != 'true' run: | echo "No cache found." - - name: Bazel Cache Found${{ matrix.java }} + - name: Bazel Cache Found if: steps.cache-bazel-build.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " From 2aa1a2c39f2903c793adc7fb9b78dfa4a00783cb Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 21:21:33 -0800 Subject: [PATCH 61/73] Rename Bazel Cache steps --- .github/workflows/ci-maven.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index b0632239de..734a6f849a 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -33,11 +33,11 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} restore-keys: ${{ runner.os }}- - name: Bazel Cache Not Found - if: steps.cache-bazel-build.outputs.cache-hit != 'true' + if: steps.cache-bazel.outputs.cache-hit != 'true' run: | echo "No cache found." - name: Bazel Cache Found - if: steps.cache-bazel-build.outputs.cache-hit == 'true' + if: steps.cache-bazel.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " du -sh ~/.cache/bazel @@ -146,7 +146,7 @@ jobs: run: | echo "No cache found." - name: Bazel Cache Found - if: steps.cache-bazel-build-8.outputs.cache-hit == 'true' + if: steps.cache-bazel.outputs.cache-hit == 'true' run: | echo -n "Cache found. Cache size: " du -sh ~/.cache/bazel From 07649c15e03ac066d4e04583d103cb9d06a7445a Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 21:23:08 -0800 Subject: [PATCH 62/73] Delete ci-maven.yaml --- .github/workflows/ci-maven.yaml | 247 -------------------------------- 1 file changed, 247 deletions(-) delete mode 100644 .github/workflows/ci-maven.yaml diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml deleted file mode 100644 index 734a6f849a..0000000000 --- a/.github/workflows/ci-maven.yaml +++ /dev/null @@ -1,247 +0,0 @@ -on: - push: - branches: - - main - pull_request: -name: ci-maven -env: - SHOWCASE_VERSION: 0.25.0 -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - java: [ 11, 17 ] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: temurin - cache: maven - - run: java -version - - name: Unit Tests - run: | - mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ - -Dfmt.skip - - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - - - name: Integration Tests - run: | - bazel --batch test //test/integration/... - - name: Gradle Build Generated Storage Client Library - run: | - echo "Building Storage lib from generated source..." - mkdir /tmp/java-storage - bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java - tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage - pushd /tmp/java-storage/google-cloud-storage-v2-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - - name: Gradle Build Generated Compute Client Library - run: | - echo "Building Compute lib from generated source..." - mkdir /tmp/java-compute - bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java - tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute - pushd /tmp/java-compute/google-cloud-compute-small-v1-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - build-java8-except-gapic-generator-java: - name: "build(8) except for gapic-generator-java" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - # Java 8 tests uses JDK 11 to compile and JDK 8 to run tests. - - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: temurin - cache: maven - - run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV - - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: temurin - - run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV - - name: Compile with Java 11 - shell: bash - run: | - set -x - export JAVA_HOME=$JAVA11_HOME - export PATH=${JAVA_HOME}/bin:$PATH - - # Why not compile? It's because the process needs to package jar so - # that gapic-generator-java module can use testlib modules of gax. - mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \ - -DskipTests -Dfmt.skip - - name: Run test with Java 8 for all modules except gapic-generator-java - shell: bash - run: | - set -x - export JAVA_HOME=$JAVA8_HOME - export PATH=${JAVA_HOME}/bin:$PATH - # useIncrementalCompilation=false to avoid recompiling classes - # generated by Java 11 compiler above. - mvn -B -ntp test --projects '!gapic-generator-java' \ - -Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \ - -Dfmt.skip - - build-java8-gapic-generator-java: - name: "build(8) for gapic-generator-java" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: temurin - cache: maven - - name: Install modules outside gapic-generator-java - shell: bash - run: | - mvn -B -ntp install --projects '!gapic-generator-java' \ - -Dcheckstyle.skip -Dfmt.skip -DskipTests - - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: temurin - cache: maven - - run: java -version - - name: Run test only for gapic-generator-java using Java 8 - shell: bash - run: | - mvn -B -ntp install --projects 'gapic-generator-java' \ - -Dcheckstyle.skip -Dfmt.skip - - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }} - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - - name: Integration Tests - run: | - bazelisk --batch test //test/integration/... - - name: Gradle Build Generated Storage Client Library - run: | - echo "Building Storage lib from generated source..." - mkdir /tmp/java-storage - bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java - tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage - pushd /tmp/java-storage/google-cloud-storage-v2-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - - name: Gradle Build Generated Compute Client Library - run: | - echo "Building Compute lib from generated source..." - mkdir /tmp/java-compute - bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java - tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute - pushd /tmp/java-compute/google-cloud-compute-small-v1-java - ./gradlew clean build publishToMavenLocal sourcesJar allJars - popd - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: temurin - cache: maven - - run: java -version - - name: Java Linter - # Exclude the root project - run: mvn -B -ntp --projects '!.' fmt:check - - showcase: - runs-on: ubuntu-latest - strategy: - matrix: - java: [ 11, 17 ] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: temurin - - run: java -version - - - name: Bazel File Cache Setup - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - - - name: Install maven modules - run: | - mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip - - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl unzip - - name: Install showcase server - run: | - sudo mkdir -p /usr/src/showcase - sudo chown -R ${USER} /usr/src/ - curl --location https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz --output /usr/src/showcase/showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz - cd /usr/src/showcase/ - tar -xf showcase-* - ./gapic-showcase run & - cd - - - name: Showcase integration tests - working-directory: showcase - run: | - mvn verify \ - -P enable-golden-tests \ - -P enable-integration-tests \ - --batch-mode \ - --no-transfer-progress From 501b23ecb4eabfe6ff61af31778dbe8ef1a5ee0c Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 21:24:11 -0800 Subject: [PATCH 63/73] Revert "Delete ci-maven.yaml" This reverts commit 07649c15e03ac066d4e04583d103cb9d06a7445a. --- .github/workflows/ci-maven.yaml | 247 ++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 .github/workflows/ci-maven.yaml diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml new file mode 100644 index 0000000000..734a6f849a --- /dev/null +++ b/.github/workflows/ci-maven.yaml @@ -0,0 +1,247 @@ +on: + push: + branches: + - main + pull_request: +name: ci-maven +env: + SHOWCASE_VERSION: 0.25.0 +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 11, 17 ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: temurin + cache: maven + - run: java -version + - name: Unit Tests + run: | + mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ + -Dfmt.skip + - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." + + - name: Integration Tests + run: | + bazel --batch test //test/integration/... + - name: Gradle Build Generated Storage Client Library + run: | + echo "Building Storage lib from generated source..." + mkdir /tmp/java-storage + bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java + tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage + pushd /tmp/java-storage/google-cloud-storage-v2-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + - name: Gradle Build Generated Compute Client Library + run: | + echo "Building Compute lib from generated source..." + mkdir /tmp/java-compute + bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java + tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute + pushd /tmp/java-compute/google-cloud-compute-small-v1-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + build-java8-except-gapic-generator-java: + name: "build(8) except for gapic-generator-java" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + # Java 8 tests uses JDK 11 to compile and JDK 8 to run tests. + - uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: temurin + cache: maven + - run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + - run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV + - name: Compile with Java 11 + shell: bash + run: | + set -x + export JAVA_HOME=$JAVA11_HOME + export PATH=${JAVA_HOME}/bin:$PATH + + # Why not compile? It's because the process needs to package jar so + # that gapic-generator-java module can use testlib modules of gax. + mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \ + -DskipTests -Dfmt.skip + - name: Run test with Java 8 for all modules except gapic-generator-java + shell: bash + run: | + set -x + export JAVA_HOME=$JAVA8_HOME + export PATH=${JAVA_HOME}/bin:$PATH + # useIncrementalCompilation=false to avoid recompiling classes + # generated by Java 11 compiler above. + mvn -B -ntp test --projects '!gapic-generator-java' \ + -Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \ + -Dfmt.skip + + build-java8-gapic-generator-java: + name: "build(8) for gapic-generator-java" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + cache: maven + - name: Install modules outside gapic-generator-java + shell: bash + run: | + mvn -B -ntp install --projects '!gapic-generator-java' \ + -Dcheckstyle.skip -Dfmt.skip -DskipTests + - uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: temurin + cache: maven + - run: java -version + - name: Run test only for gapic-generator-java using Java 8 + shell: bash + run: | + mvn -B -ntp install --projects 'gapic-generator-java' \ + -Dcheckstyle.skip -Dfmt.skip + - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }} + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." + - name: Integration Tests + run: | + bazelisk --batch test //test/integration/... + - name: Gradle Build Generated Storage Client Library + run: | + echo "Building Storage lib from generated source..." + mkdir /tmp/java-storage + bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java + tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage + pushd /tmp/java-storage/google-cloud-storage-v2-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + - name: Gradle Build Generated Compute Client Library + run: | + echo "Building Compute lib from generated source..." + mkdir /tmp/java-compute + bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java + tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute + pushd /tmp/java-compute/google-cloud-compute-small-v1-java + ./gradlew clean build publishToMavenLocal sourcesJar allJars + popd + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + cache: maven + - run: java -version + - name: Java Linter + # Exclude the root project + run: mvn -B -ntp --projects '!.' fmt:check + + showcase: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 11, 17 ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: temurin + - run: java -version + + - name: Bazel File Cache Setup + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." + + - name: Install maven modules + run: | + mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y curl unzip + - name: Install showcase server + run: | + sudo mkdir -p /usr/src/showcase + sudo chown -R ${USER} /usr/src/ + curl --location https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz --output /usr/src/showcase/showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz + cd /usr/src/showcase/ + tar -xf showcase-* + ./gapic-showcase run & + cd - + - name: Showcase integration tests + working-directory: showcase + run: | + mvn verify \ + -P enable-golden-tests \ + -P enable-integration-tests \ + --batch-mode \ + --no-transfer-progress From 0b52f40f24b9c8fa50b9cccf9aae5b6f2bc1f22e Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 21:24:36 -0800 Subject: [PATCH 64/73] Delete ci.yaml --- .github/workflows/ci.yaml | 62 --------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 86165fff19..0000000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,62 +0,0 @@ -on: - push: - branches: - - main - pull_request: -name: ci -jobs: -# Due to the circular dependencies in the integration tests between googleapis and gapic-generator-java, -# this check will not work until we update googleapis to use the Maven jar - generate-client-libraries: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - java: [ 8, 11 ] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: temurin - - run: java -version - - run: bazelisk version -# - name: Bazel File Cache Setup -# id: cache-bazel -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- -# - name: Bazel Cache Not Found -# if: steps.cache-bazel.outputs.cache-hit != 'true' -# run: | -# echo "No cache found." -# - name: Bazel Cache Found -# if: steps.cache-bazel.outputs.cache-hit == 'true' -# run: | -# echo -n "Cache found. Cache size: " -# du -sh ~/.cache/bazel -# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." -# echo "The old cache will disappear after 7 days." -# -# - name: Gradle Build Generated Storage Client Library -# run: | -# echo "Building Storage lib from generated source..." -# mkdir /tmp/java-storage -# bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java -# tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage -# pushd /tmp/java-storage/google-cloud-storage-v2-java -# ./gradlew clean build publishToMavenLocal sourcesJar allJars -# popd -# -# - name: Gradle Build Generated Compute Client Library -# run: | -# echo "Building Compute lib from generated source..." -# mkdir /tmp/java-compute -# bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java -# tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute -# pushd /tmp/java-compute/google-cloud-compute-small-v1-java -# ./gradlew clean build publishToMavenLocal sourcesJar allJars -# popd - From a215f9faa5c67cd2dc113d568fab29cc0ca2a5f9 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 28 Dec 2022 21:47:29 -0800 Subject: [PATCH 65/73] Update pom.xml --- gapic-generator-java/pom.xml | 2 ++ pom.xml | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gapic-generator-java/pom.xml b/gapic-generator-java/pom.xml index 7bc332561e..3a3a929a89 100644 --- a/gapic-generator-java/pom.xml +++ b/gapic-generator-java/pom.xml @@ -7,6 +7,8 @@ 2.12.1-SNAPSHOT + true + true true UTF-8 diff --git a/pom.xml b/pom.xml index e120f30813..5cf661aae5 100644 --- a/pom.xml +++ b/pom.xml @@ -9,8 +9,6 @@ 0.1.0-SNAPSHOT - true - true true UTF-8 From cd1cc61038437a5e86ca4e08756d468bf653c46e Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 3 Jan 2023 08:44:33 -0800 Subject: [PATCH 66/73] Rename ci-maven.yaml to ci.yaml --- .github/workflows/{ci-maven.yaml => ci.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci-maven.yaml => ci.yaml} (100%) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci.yaml similarity index 100% rename from .github/workflows/ci-maven.yaml rename to .github/workflows/ci.yaml From d0d720a4f7a1cb811a2c626abc85df545de598f5 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Tue, 3 Jan 2023 18:21:20 -0800 Subject: [PATCH 67/73] Disable bazel cache --- .github/workflows/ci.yaml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 734a6f849a..690e4126dd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -202,23 +202,23 @@ jobs: distribution: temurin - run: java -version - - name: Bazel File Cache Setup - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." +# - name: Bazel File Cache Setup +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- +# - name: Bazel Cache Not Found +# if: steps.cache-bazel.outputs.cache-hit != 'true' +# run: | +# echo "No cache found." +# - name: Bazel Cache Found +# if: steps.cache-bazel.outputs.cache-hit == 'true' +# run: | +# echo -n "Cache found. Cache size: " +# du -sh ~/.cache/bazel +# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." +# echo "The old cache will disappear after 7 days." - name: Install maven modules run: | From acf9de6c0e0ef26bb390898aa33136ba0b6814e2 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Wed, 4 Jan 2023 10:42:52 -0800 Subject: [PATCH 68/73] Remove bazel cache --- .github/workflows/ci.yaml | 56 --------------------------------------- 1 file changed, 56 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 690e4126dd..9425f854f5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,25 +25,6 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - - name: Integration Tests run: | bazel --batch test //test/integration/... @@ -134,24 +115,6 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }} - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - name: Integration Tests run: | bazelisk --batch test //test/integration/... @@ -201,25 +164,6 @@ jobs: java-version: ${{ matrix.java }} distribution: temurin - run: java -version - -# - name: Bazel File Cache Setup -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- -# - name: Bazel Cache Not Found -# if: steps.cache-bazel.outputs.cache-hit != 'true' -# run: | -# echo "No cache found." -# - name: Bazel Cache Found -# if: steps.cache-bazel.outputs.cache-hit == 'true' -# run: | -# echo -n "Cache found. Cache size: " -# du -sh ~/.cache/bazel -# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." -# echo "The old cache will disappear after 7 days." - - name: Install maven modules run: | mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip From 9275feafb6ddcebdfe450d3acbe75be5ac913454 Mon Sep 17 00:00:00 2001 From: Burke Davison Date: Wed, 4 Jan 2023 15:22:09 -0500 Subject: [PATCH 69/73] Revert "Remove bazel cache" This reverts commit acf9de6c0e0ef26bb390898aa33136ba0b6814e2. --- .github/workflows/ci.yaml | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9425f854f5..690e4126dd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,6 +25,25 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." + - name: Integration Tests run: | bazel --batch test //test/integration/... @@ -115,6 +134,24 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }} + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Integration Tests run: | bazelisk --batch test //test/integration/... @@ -164,6 +201,25 @@ jobs: java-version: ${{ matrix.java }} distribution: temurin - run: java -version + +# - name: Bazel File Cache Setup +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- +# - name: Bazel Cache Not Found +# if: steps.cache-bazel.outputs.cache-hit != 'true' +# run: | +# echo "No cache found." +# - name: Bazel Cache Found +# if: steps.cache-bazel.outputs.cache-hit == 'true' +# run: | +# echo -n "Cache found. Cache size: " +# du -sh ~/.cache/bazel +# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." +# echo "The old cache will disappear after 7 days." + - name: Install maven modules run: | mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip From 54a246fb65442ea5deb1ca15f8469a10bb7651f4 Mon Sep 17 00:00:00 2001 From: Burke Davison Date: Wed, 4 Jan 2023 15:22:34 -0500 Subject: [PATCH 70/73] Revert "Disable bazel cache" This reverts commit d0d720a4f7a1cb811a2c626abc85df545de598f5. --- .github/workflows/ci.yaml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 690e4126dd..734a6f849a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -202,23 +202,23 @@ jobs: distribution: temurin - run: java -version -# - name: Bazel File Cache Setup -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- -# - name: Bazel Cache Not Found -# if: steps.cache-bazel.outputs.cache-hit != 'true' -# run: | -# echo "No cache found." -# - name: Bazel Cache Found -# if: steps.cache-bazel.outputs.cache-hit == 'true' -# run: | -# echo -n "Cache found. Cache size: " -# du -sh ~/.cache/bazel -# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." -# echo "The old cache will disappear after 7 days." + - name: Bazel File Cache Setup + uses: actions/cache@v3 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} + restore-keys: ${{ runner.os }}- + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." + echo "The old cache will disappear after 7 days." - name: Install maven modules run: | From ac464a1bb4224751b16f9a2d597d771fe66faf70 Mon Sep 17 00:00:00 2001 From: Burke Davison Date: Wed, 4 Jan 2023 15:28:48 -0500 Subject: [PATCH 71/73] Revert "Revert "Disable bazel cache"" This reverts commit 54a246fb65442ea5deb1ca15f8469a10bb7651f4. --- .github/workflows/ci.yaml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 734a6f849a..690e4126dd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -202,23 +202,23 @@ jobs: distribution: temurin - run: java -version - - name: Bazel File Cache Setup - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." +# - name: Bazel File Cache Setup +# uses: actions/cache@v3 +# with: +# path: ~/.cache/bazel +# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} +# restore-keys: ${{ runner.os }}- +# - name: Bazel Cache Not Found +# if: steps.cache-bazel.outputs.cache-hit != 'true' +# run: | +# echo "No cache found." +# - name: Bazel Cache Found +# if: steps.cache-bazel.outputs.cache-hit == 'true' +# run: | +# echo -n "Cache found. Cache size: " +# du -sh ~/.cache/bazel +# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." +# echo "The old cache will disappear after 7 days." - name: Install maven modules run: | From 5e000f4d2137247ae3b5db8243c46118b41f7400 Mon Sep 17 00:00:00 2001 From: Burke Davison Date: Wed, 4 Jan 2023 15:28:48 -0500 Subject: [PATCH 72/73] Revert "Revert "Remove bazel cache"" This reverts commit 9275feafb6ddcebdfe450d3acbe75be5ac913454. --- .github/workflows/ci.yaml | 56 --------------------------------------- 1 file changed, 56 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 690e4126dd..9425f854f5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,25 +25,6 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }}- - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - - name: Integration Tests run: | bazel --batch test //test/integration/... @@ -134,24 +115,6 @@ jobs: mvn -B -ntp install --projects 'gapic-generator-java' \ -Dcheckstyle.skip -Dfmt.skip - run: bazelisk version - - name: Bazel File Cache Setup - id: cache-bazel - uses: actions/cache@v3 - with: - path: ~/.cache/bazel - key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} - restore-keys: ${{ runner.os }} - - name: Bazel Cache Not Found - if: steps.cache-bazel.outputs.cache-hit != 'true' - run: | - echo "No cache found." - - name: Bazel Cache Found - if: steps.cache-bazel.outputs.cache-hit == 'true' - run: | - echo -n "Cache found. Cache size: " - du -sh ~/.cache/bazel - echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." - echo "The old cache will disappear after 7 days." - name: Integration Tests run: | bazelisk --batch test //test/integration/... @@ -201,25 +164,6 @@ jobs: java-version: ${{ matrix.java }} distribution: temurin - run: java -version - -# - name: Bazel File Cache Setup -# uses: actions/cache@v3 -# with: -# path: ~/.cache/bazel -# key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }} -# restore-keys: ${{ runner.os }}- -# - name: Bazel Cache Not Found -# if: steps.cache-bazel.outputs.cache-hit != 'true' -# run: | -# echo "No cache found." -# - name: Bazel Cache Found -# if: steps.cache-bazel.outputs.cache-hit == 'true' -# run: | -# echo -n "Cache found. Cache size: " -# du -sh ~/.cache/bazel -# echo "If the cache seems broken, update the root WORKSPACE file with a trivial change." -# echo "The old cache will disappear after 7 days." - - name: Install maven modules run: | mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip From 8ed2b9e5ff63c4405a14dd7ac11ae98d5c399588 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Thu, 5 Jan 2023 22:44:15 -0800 Subject: [PATCH 73/73] Rename ci to ci-maven --- .github/workflows/{ci.yaml => ci-maven.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci.yaml => ci-maven.yaml} (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci-maven.yaml similarity index 100% rename from .github/workflows/ci.yaml rename to .github/workflows/ci-maven.yaml