This is a temporal workflow that will evolve with codebase. The steps described below are temporary and better ones will be coming.
-
Clone this repo.
-
Copy the Git pre-commit hooks. This will automatically check the build, run tests, and perform linting before each commit.
cp .githooks/pre-commit .git/hooks/pre-commit
-
Clone googleapis and gapic-showcase and install protoc.
-
Copy the protos from Showcase into googleapis/google/showcase.
cp gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta
-
Add the new microgenerator rules to the protobuf directory's
BUILD.bazel
file as follows:load( "@com_google_googleapis_imports//:imports.bzl", # Existing rules here. "java_gapic_assembly_gradle_pkg2", "java_gapic_library2", ) # This should either replace the existing monolith target or have a unique name # that includes "java_gapic". java_gapic_library2( name = "showcase_java_gapic", srcs = [":showcase_proto_with_info"], # The gapic_yaml file is needed only for APIs that have batching configs. grpc_service_config = "showcase_grpc_service_config.json", package = "google.showcase.v1beta1", test_deps = [ ":showcase_java_grpc", ], deps = [ ":showcase_java_proto", ], ) java_gapic_assembly_gradle_pkg2( # This name should be unique from the existing target name. name = "google-cloud-showcase-v1beta1-java", deps = [ # This is the new microgen target above. ":showcase_java_gapic", # The following targets already exist. ":showcase_java_grpc", ":showcase_java_proto", ":showcase_proto", ], )
-
Build the new target.
bazel build google/showcase/v1beta1:showcase_java_gapic
-
Run linter checks without actually doing the formatting.
bazel build :google_java_format_verification
-
Format files.
bazel run :google_java_format
-
Run all unit tests.
bazel test //...
-
Run a single unit test like
JavaCodeGeneratorTest.java
bazel run //src/test/java/com/google/api/generator/engine:JavaCodeGeneratorTest
-
Update goldens files based on code generation in unit test, for example
JavaCodeGeneratorTest.java
bazel run //src/test/java/com/google/api/generator/engine:JavaCodeGeneratorTest_update
-
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 intest/integration/goldens/redis
.bazel test //test/integration:redis
-
Update goldens files based on code generation in integration test, for example
Redis
. It generates Java source code using the Java microgenerator and overwrites the goldens files intest/integration/goldens/redis
based on code generation.bazel run //test/integration:redis_update