8000 feat(generator): identify mono repo from config instead of len by zhumin8 · Pull Request #3682 · googleapis/sdk-platform-java · GitHub
[go: up one dir, main page]

Skip to content

feat(generator): identify mono repo from config instead of len #3682

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions generation_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
googleapis_commitish: fbbbf5023815f9a662c85aa8af8f3b72467fcb6f
is_monorepo: true

# the libraries are ordered with respect to library name, which is
# java-{library.library_name} or java-{libra 10000 ry.api-shortname} when
# library.library_name is not defined.
Expand Down
6 changes: 5 additions & 1 deletion hermetic_build/common/model/generation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
COMMON_PROTOS_LIBRARY_NAME = "common-protos"
GAPIC_GENERATOR_VERSION = "gapic_generator_version"
LIBRARIES_BOM_VERSION = "libraries_bom_version"
IS_MONOREPO = "is_monorepo"
GENERATOR_VERSION_ENV_KEY = "GENERATOR_VERSION"


Expand All @@ -39,6 +40,7 @@ def __init__(
libraries: list[LibraryConfig],
gapic_generator_version: Optional[str] = None,
libraries_bom_version: Optional[str] = None,
monorepo: Optional[bool] = False,
):
self.googleapis_commitish = googleapis_commitish
self.libraries_bom_version = (
Expand All @@ -48,6 +50,7 @@ def __init__(
gapic_generator_version
)
self.libraries = libraries
self.monorepo = monorepo
# explicit set to None so that we can compute the
# value in getter.
self.__contains_common_protos = None
Expand All @@ -66,7 +69,7 @@ def get_proto_path_to_library_name(self) -> dict[str, str]:
return paths

def is_monorepo(self) -> bool:
return len(self.libraries) > 1
return self.monorepo

def contains_common_protos(self) -> bool:
if self.__contains_common_protos is None:
Expand Down Expand Up @@ -169,6 +172,7 @@ def from_yaml(path_to_yaml: str) -> GenerationConfig:
),
gapic_generator_version=__optional(config, GAPIC_GENERATOR_VERSION, None),
libraries_bom_version=__optional(config, LIBRARIES_BOM_VERSION, None),
monorepo=__optional(config, IS_MONOREPO, False),
libraries=parsed_libraries,
)

Expand Down
10 changes: 10 additions & 0 deletions hermetic_build/common/tests/model/generation_config_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,21 @@ def test_is_monorepo_with_one_library_returns_false(self):
)
self.assertFalse(config.is_monorepo())

def test_is_monorepo_with_one_library_explicit_set_true(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries=[library_1],
monorepo=True,
)
self.assertTrue(config.is_monorepo())

def test_is_monorepo_with_two_libraries_returns_true(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries=[library_1, library_2],
monorepo=True,
)
self.assertTrue(config.is_monorepo())

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
gapic_generator_version: 2.38.1
googleapis_commitish: 4ce0ff67a3d4509be641cbe47a35844ddc1268fc
libraries_bom_version: 26.37.0
is_monorepo: true
libraries:
- api_shortname: apigeeconnect
name_pretty: Apigee Connect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
gapic_generator_version: 2.37.0
protoc_version: 25.2
googleapis_commitish: 9868a57470a969ffa1d21194a5c05d7a6e4e98cc
is_monorepo: false
libraries:
- api_shortname: bigtable
name_pretty: Cloud Bigtable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ gapic_generator_version: 2.34.0
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
is_monorepo: false
libraries:
- api_shortname: cloudasset
name_pretty: Cloud Asset Inventory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
gapic_generator_version: 2.34.0
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
is_monorepo: false
libraries:
- api_shortname: cloudasset
name_pretty: Cloud Asset Inventory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ gapic_generator_version: 2.34.0
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
is_monorepo: true
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
synthtool_commitish: 6612ab8f3afcd5e292aecd647f0fa68812c9f5b5
template_excludes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
gapic_generator_version: 2.34.0
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
is_monorepo: true
libraries:
- api_shortname: cloudasset
name_pretty: Cloud Asset Inventory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
gapic_generator_version: 2.34.0
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
is_monorepo: true
libraries:
- api_shortname: cloudasset
name_pretty: Cloud Asset Inventory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
googleapis_commitish: 6a474b31c53cc1797710206824a17b364a835d2d
gapic_generator_version: 2.34.0
is_monorepo: true
# the libraries are ordered with respect to library name, which is
# java-{library.library_name} or java-{library.api-shortname} when
# library.library_name is not defined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ gapic_generator_version: 2.34.0
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
is_monorepo: true
libraries:
- api_shortname: cloudasset
name_pretty: Cloud Asset Inventory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,13 @@ def __get_a_gen_config(
"""
if combination == 1:
libraries = [library_1]
monorepo = False
elif combination == 2:
libraries = [library_1, library_2]
monorepo = True
else:
libraries = [library_1, common_protos]
monorepo = True

# update libraries with custom configuration (for now, only
# library_type)
Expand All @@ -363,6 +366,7 @@ def __get_a_gen_config(
gapic_generator_version="",
googleapis_commitish="",
libraries=libraries,
monorepo=monorepo,
)

@staticmethod
Expand Down
Loading
0