Skip to content

Commit

Permalink
fix(bazel): Eradicate monolith deps from Java µgen repo (#778)
Browse files Browse the repository at this point in the history
* fix(bazel): Eradicate monolith deps from Java µgen repo

* fix: update googleapis hash

* fix: update googleapis-discovery and deps' hashes
  • Loading branch information
miraleung authored Jun 30, 2021
1 parent 9432979 commit 86f2472
Show file tree
Hide file tree
Showing 15 changed files with 610 additions and 216 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
run: bazel --batch test $(bazel query "//src/test/..." | grep "Test$") --noshow_progress --test_output=errors

- name: Integration Tests
# TODO(miraleung): Change this to //test/integration/... after the monolith rule removal.
run: bazel --batch test //test/integration:asset //test/integration:compute //test/integration:credentials //test/integration:iam //test/integration:kms //test/integration:logging //test/integration:pubsub //test/integration:redis //test/integration:library --noshow_progress
run: bazel --batch test //test/integration/...

- uses: actions/upload-artifact@v2
if: ${{ failure() }}
Expand Down
14 changes: 3 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

# Bazel rules.
_rules_gapic_version = "0.5.4"
_rules_gapic_version = "0.5.5"

http_archive(
name = "rules_gapic",
Expand All @@ -78,14 +78,6 @@ http_archive(
)

# Java dependencies.
# Import the monolith so we can transitively use its gapic rules for googleapis.
# TODO: Remove this after this dep has been removed from googleapis' switched_rules_by_language.
http_archive(
name = "com_google_api_codegen",
strip_prefix = "gapic-generator-2.11.1",
urls = ["https://github.com/googleapis/gapic-generator/archive/v2.11.1.zip"],
)

load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")

switched_rules_by_language(
Expand All @@ -101,6 +93,6 @@ grpc_java_repositories()

http_archive(
name = "com_google_disco_to_proto3_converter",
strip_prefix = "disco-to-proto3-converter-1839f6aca5e968e59b7acc03e7018b0fda8c480b",
urls = ["https://github.com/googleapis/disco-to-proto3-converter/archive/1839f6aca5e968e59b7acc03e7018b0fda8c480b.zip"],
strip_prefix = "disco-to-proto3-converter-4b0956884b1aa9b367cf41488b622dc12eb16652",
urls = ["https://github.com/googleapis/disco-to-proto3-converter/archive/4b0956884b1aa9b367cf41488b622dc12eb16652.zip"],
)
4 changes: 2 additions & 2 deletions dependencies.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# The properties format is the following:
# <dependency_type>[.<artifact_name>]=<value>

# Target workspace name: com_google_api_codegen
# Target workspace name: gapic_generator_java

# Versions only, for dependencies which actual artifacts differ between Bazel and Gradle
version.com_google_protobuf=3.15.8
Expand Down Expand Up @@ -32,7 +32,7 @@ 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.
# 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
Expand Down
8 changes: 4 additions & 4 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ def gapic_generator_java_repositories():
_maybe(
http_archive,
name = "com_google_googleapis",
strip_prefix = "googleapis-f5ce261910c373fdd96bdaa47173f5604562876f",
strip_prefix = "googleapis-2c1d1b27646cba6f14b760b635f29fafc5a74ca6",
urls = [
"https://github.com/googleapis/googleapis/archive/f5ce261910c373fdd96bdaa47173f5604562876f.zip",
"https://github.com/googleapis/googleapis/archive/2c1d1b27646cba6f14b760b635f29fafc5a74ca6.zip",
],
)

_maybe(
http_archive,
name = "com_google_googleapis_discovery",
strip_prefix = "googleapis-discovery-6a189a8bada35e2657a67b903cad7fee649f2dbc",
strip_prefix = "googleapis-discovery-abf4cec1ce9e02e4d7d650bf66137c347cdd0d44",
urls = [
"https://github.com/googleapis/googleapis-discovery/archive/6a189a8bada35e2657a67b903cad7fee649f2dbc.zip",
"https://github.com/googleapis/googleapis-discovery/archive/abf4cec1ce9e02e4d7d650bf66137c347cdd0d44.zip",
],
)

Expand Down
169 changes: 8 additions & 161 deletions test/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ INTEGRATION_TEST_LIBRARIES = [

# Keys must match the values in INTEGRATION_TEST_LIBRARIES above.
API_GAPIC_TARGETS = {
"asset": ":asset_java_gapic",
"credentials": ":credentials_java_gapic",
"asset": "@com_google_googleapis//google/cloud/asset/v1:asset_java_gapic",
"credentials": "@com_google_googleapis//google/iam/credentials/v1:credentials_java_gapic",
"iam": ":iam_java_gapic", # Googleapis' LRO does not have a Java Gapic.
"kms": ":kms_java_gapic", # Local target because mixins are not rolled out yet.
"pubsub": ":pubsub_java_gapic",
"logging": ":logging_java_gapic",
"redis": ":redis_java_gapic",
"library": ":library_java_gapic",
"compute": ":compute_small_java_gapic",
"logging": "@com_google_googleapis//google/logging/v2:logging_java_gapic",
"redis": "@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_gapic",
"library": "@com_google_googleapis//google/example/library/v1:library_java_gapic",
"compute": "@com_google_googleapis_discovery//google/cloud/compute/v1:compute_small_java_gapic",
}

[integration_test(
Expand All @@ -59,161 +59,9 @@ API_GAPIC_TARGETS = {
target = API_GAPIC_TARGETS[lib_name],
) for lib_name in INTEGRATION_TEST_LIBRARIES]

###################################################
# Temporary proto_with_info definitions for
# monolith depdency removal.
# Remove this section when the monolith rule deps are
# out of googleapis.
###################################################
proto_library_with_info(
name = "asset_proto_with_info",
deps = [
"@com_google_googleapis//google/cloud:common_resources_proto",
"@com_google_googleapis//google/cloud/asset/v1:asset_proto",
],
)

proto_library_with_info(
name = "credentials_proto_with_info",
deps = [
"@com_google_googleapis//google/cloud:common_resources_proto",
"@com_google_googleapis//google/iam/credentials/v1:credentials_proto",
],
)

proto_library_with_info(
name = "logging_proto_with_info",
deps = [
"@com_google_googleapis//google/cloud:common_resources_proto",
"@com_google_googleapis//google/logging/v2:logging_proto",
],
)

proto_library_with_info(
name = "pubsub_proto_with_info",
deps = [
"@com_google_googleapis//google/cloud:common_resources_proto",
"@com_google_googleapis//google/iam/v1:iam_policy_proto",
"@com_google_googleapis//google/iam/v1:policy_proto",
"@com_google_googleapis//google/pubsub/v1:pubsub_proto",
],
)

proto_library_with_info(
name = "redis_proto_with_info",
deps = [
"@com_google_googleapis//google/cloud:common_resources_proto",
"@com_google_googleapis//google/cloud/redis/v1beta1:redis_proto",
],
)

proto_library_with_info(
name = "iam_proto_with_info",
deps = [
"@com_google_googleapis//google/iam/v1:iam_policy_proto",
"@com_google_googleapis//google/iam/v1:options_proto",
"@com_google_googleapis//google/iam/v1:policy_proto",
],
)

proto_library_with_info(
name = "library_proto_with_info",
deps = [
"@com_google_googleapis//google/cloud:common_resources_proto",
"@com_google_googleapis//google/example/library/v1:library_proto",
],
)

proto_library_with_info(
name = "compute_small_proto_with_info",
deps = [
"@com_google_googleapis//google/cloud:common_resources_proto",
"@com_google_googleapis_discovery//google/cloud/compute/v1:compute_small_proto",
],
)

java_gapic_library(
name = "compute_small_java_gapic",
srcs = [":compute_small_proto_with_info"],
test_deps = [],
transport = "rest",
deps = [
"@com_google_googleapis_discovery//google/cloud/compute/v1:compute_small_java_proto",
],
)

java_gapic_library(
name = "asset_java_gapic",
srcs = [":asset_proto_with_info"],
grpc_service_config = "@com_google_googleapis//google/cloud/asset/v1:cloudasset_grpc_service_config.json",
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",
"@com_google_googleapis//google/identity/accesscontextmanager/v1:accesscontextmanager_proto",
],
)

java_gapic_library(
name = "credentials_java_gapic",
srcs = [":credentials_proto_with_info"],
grpc_service_config = "@com_google_googleapis//google/iam/credentials/v1:iamcredentials_grpc_service_config.json",
test_deps = [
"@com_google_googleapis//google/iam/credentials/v1:credentials_java_grpc",
],
deps = [
"@com_google_googleapis//google/iam/credentials/v1:credentials_java_proto",
],
)

java_gapic_library(
name = "logging_java_gapic",
srcs = [":logging_proto_with_info"],
gapic_yaml = "@com_google_googleapis//google/logging/v2:logging_gapic.yaml",
grpc_service_config = "@com_google_googleapis//google/logging/v2:logging_grpc_service_config.json",
test_deps = [
"@com_google_googleapis//google/logging/v2:logging_java_grpc",
],
deps = [
"@com_google_googleapis//google/api:api_java_proto",
"@com_google_googleapis//google/logging/v2:logging_java_proto",
],
)

java_gapic_library(
name = "redis_java_gapic",
srcs = [":redis_proto_with_info"],
gapic_yaml = "@com_google_googleapis//google/cloud/redis/v1beta1:redis_gapic.yaml",
grpc_service_config = "@com_google_googleapis//google/cloud/redis/v1beta1:redis_grpc_service_config.json",
test_deps = [
"@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_grpc",
],
deps = [
"@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_proto",
],
)

java_gapic_library(
name = "library_java_gapic",
srcs = [":library_proto_with_info"],
gapic_yaml = "@com_google_googleapis//google/example/library/v1:library_example_gapic.yaml",
grpc_service_config = "@com_google_googleapis//google/example/library/v1:library_grpc_service_config.json",
test_deps = [
"@com_google_googleapis//google/example/library/v1:library_java_grpc",
],
deps = [
"@com_google_googleapis//google/example/library/v1:library_java_proto",
],
)
####################################################
# API Library Rules
####################################################
# These will eventually go away once more APIs in googleapis have been migrated to the
# microgenerator.

# Asset API.
java_gapic_test(
name = "asset_java_gapic_test_suite",
Expand Down Expand Up @@ -319,7 +167,7 @@ java_gapic_assembly_gradle_pkg(
# IAM (for a standalone mixed-in API).
java_gapic_library(
name = "iam_java_gapic",
srcs = [":iam_proto_with_info"],
srcs = ["@com_google_googleapis//google/iam/v1:iam_proto_with_info"],
grpc_service_config = "iam_grpc_service_config.json",
test_deps = [
"@com_google_googleapis//google/iam/v1:iam_java_grpc",
Expand Down Expand Up @@ -431,10 +279,9 @@ java_gapic_assembly_gradle_pkg(
)

# PubSub
# TODO: Remove some of these targets when PubSub has been migrated in googleapis.
java_gapic_library(
name = "pubsub_java_gapic",
srcs = [":pubsub_proto_with_info"],
srcs = ["@com_google_googleapis//google/pubsub/v1:pubsub_proto_with_info"],
gapic_yaml = "@com_google_googleapis//google/pubsub/v1:pubsub_gapic.yaml",
grpc_service_config = "@com_google_googleapis//google/pubsub/v1:pubsub_grpc_service_config.json",
# For the IAM mixin.
Expand Down
Loading

0 comments on commit 86f2472

Please sign in to comment.