Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ggj][bazel] feat: add microgenerator rules for cloud/asset #381

Merged
merged 9 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ jobs:
name: Build targets for gapic-generator-java
command: |
cd /tmp/gapic-generator-java
bazel --batch build //...
bazel --batch build //src/...
- run:
name: Run unit tests for gapic-generator-java
command: |
cd /tmp/gapic-generator-java
bazel --batch test //... --noshow_progress
bazel --batch test //src/test/... --noshow_progress
find . -type f -regex ".*/bazel-testlogs/.*xml" -exec cp {} ${TEST_REPORTS_DIR} \;
- store_test_results:
path: bazel/reports/gapic-generator-java
Expand Down
4 changes: 2 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fi
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_BAZEL_FILES_CHANGED -gt 0 ]
then
echo_status "Checking the build..."
bazel --batch build --disk_cache="$BAZEL_CACHE_DIR" //...
bazel --batch build --disk_cache="$BAZEL_CACHE_DIR" //src/...
BUILD_STATUS=$?
if [ $BUILD_STATUS != 0 ]
then
Expand All @@ -112,7 +112,7 @@ fi
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ]
then
echo_status "Checking tests..."
bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //...
bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //src/test/...
TEST_STATUS=$?
if [ $TEST_STATUS != 0 ]
then
Expand Down
4 changes: 2 additions & 2 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def gapic_generator_java_repositories():
_maybe(
http_archive,
name = "com_google_googleapis",
strip_prefix = "googleapis-dbdd8ddeb6d9556952aa8784d9e48f2566c9911a",
strip_prefix = "googleapis-bda7ce951def5ae6e5c4258d0e569188dd4ae02b",
urls = [
"https://github.com/googleapis/googleapis/archive/dbdd8ddeb6d9556952aa8784d9e48f2566c9911a.zip",
"https://github.com/googleapis/googleapis/archive/bda7ce951def5ae6e5c4258d0e569188dd4ae02b.zip",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
public class Parser {
private static final String COMMA = ",";
private static final String COLON = ":";
private static final String DOT = ".";
private static final String DEFAULT_PORT = "443";

// Allow other parsers to access this.
Expand Down Expand Up @@ -320,12 +321,23 @@ static LongrunningOperation parseLro(

OperationInfo lroInfo =
methodDescriptor.getOptions().getExtension(OperationsProto.operationInfo);

String responseTypeName = lroInfo.getResponseType();
String responseTypePackage = "";
if (responseTypeName.contains(DOT)) {
responseTypeName = responseTypeName.substring(responseTypeName.lastIndexOf(DOT) + 1);
}

String metadataTypeName = lroInfo.getMetadataType();
if (metadataTypeName.contains(DOT)) {
metadataTypeName = metadataTypeName.substring(metadataTypeName.lastIndexOf(DOT) + 1);
}

Message responseMessage = messageTypes.get(responseTypeName);
Message metadataMessage = messageTypes.get(metadataTypeName);
Preconditions.checkNotNull(
responseMessage, String.format("LRO response message %s not found", responseTypeName));
// TODO(miraleung): Check that the packages are equal if those strings are not empty.
Preconditions.checkNotNull(
metadataMessage, String.format("LRO metadata message %s not found", metadataTypeName));

Expand Down
26 changes: 26 additions & 0 deletions test/integration/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])

####################################################
# API Library Rules
####################################################
# These will eventually go away once more APIs in googleapis have been migrated to the microgenerator.

load(
"@com_google_googleapis_imports//:imports.bzl",
java_gapic_library = "java_gapic_library2",
)

java_gapic_library(
name = "asset_java_gapic",
srcs = ["@com_google_googleapis//google/cloud/asset/v1:asset_proto_with_info"],
grpc_service_config = "@com_google_googleapis//google/cloud/asset/v1:cloudasset_grpc_service_config.json",
package = "google.cloud.asset.v1",
test_deps = [
"@com_google_googleapis//google/cloud/asset/v1:asset_java_grpc",
"@com_google_googleapis//google/iam/v1:iam_java_grpc",
],
deps = [
"@com_google_googleapis//google/cloud/asset/v1:asset_java_proto",
"@com_google_googleapis//google/iam/v1:iam_java_proto",
],
)