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

chore: remove template_excludes in the generation config #2801

Merged
merged 10 commits into from
May 27, 2024
14 changes: 0 additions & 14 deletions generation_config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
gapic_generator_version: 2.40.2-SNAPSHOT
googleapis_commitish: 3d50414a7ff3f0b8ffe8ad7858257396e4f18131
template_excludes:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the behavior now this is removed? From the logic here, it should be fine for existing libraries. If we want to create new libraries with empty template_excludes, are we going to create an owlbot.py with empty template_excludes section?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to create new libraries with empty template_excludes, are we going to create an owlbot.py with empty template_excludes section?

Yes, the exclusions in owlbot.py is empty.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did we populate it before without hermetic build? Maybe we can populate a default list like this?

    ".github/*",
    ".kokoro/*",
    "samples/*",
    "CODE_OF_CONDUCT.md",
    "CONTRIBUTING.md",
    "LICENSE",
    "SECURITY.md",
    "java.header",
    "license-checks.xml",
    "renovate.json",
    ".gitignore"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's hard coded in the new-client.py

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was hardcode in new-client.py, but since it does not exist anymore, is it still hardcoded somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the only place that may have template exclusions is generation config.

This parameter is used to generate owlbot.py if it doesn't exist. Since we don't have this situation, we can remove this parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hardcode it somewhere in our code? So that we don't have to specify it anymore in google-cloud-java?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed template_exclusions from the config.

- .github/*
- .kokoro/*
- samples/*
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- LICENSE
- SECURITY.md
- java.header
- license-checks.xml
- README.md
- renovate.json
- .gitignore

# 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
4 changes: 2 additions & 2 deletions library_generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ They are shared by library level parameters.
| protoc_version | No | inferred from the generator if not specified |
| grpc_version | No | inferred from the generator if not specified |
| googleapis-commitish | Yes | |
| libraries_bom_version | Yes | |
| template_excludes | Yes | |
| libraries_bom_version | No | empty string if not specified |
| template_excludes | No | empty list if not specified |

### Library level parameters

Expand Down
10 changes: 6 additions & 4 deletions library_generation/model/generation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ def __init__(
self,
gapic_generator_version: str,
googleapis_commitish: str,
template_excludes: list[str],
libraries: list[LibraryConfig],
template_excludes: Optional[list[str]] = None,
libraries_bom_version: Optional[str] = None,
grpc_version: Optional[str] = None,
protoc_version: Optional[str] = None,
):
self.gapic_generator_version = gapic_generator_version
self.googleapis_commitish = googleapis_commitish
self.libraries_bom_version = libraries_bom_version
self.template_excludes = template_excludes
self.libraries_bom_version = (
libraries_bom_version if libraries_bom_version else ""
)
self.template_excludes = template_excludes if template_excludes else []
self.libraries = libraries
self.grpc_version = grpc_version
self.protoc_version = protoc_version
Expand Down Expand Up @@ -149,7 +151,7 @@ def from_yaml(path_to_yaml: str) -> GenerationConfig:
googleapis_commitish=__required(
config, "googleapis_commitish", REPO_LEVEL_PARAMETER
),
template_excludes=__required(config, "template_excludes", REPO_LEVEL_PARAMETER),
template_excludes=__optional(config, "template_excludes", None),
grpc_version=__optional(config, "grpc_version", None),
protoc_version=__optional(config, "protoc_version", None),
libraries_bom_version=__optional(config, "libraries_bom_version", None),
Expand Down
2 changes: 0 additions & 2 deletions library_generation/test/generate_pr_description_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def test_generate_pr_description_with_same_googleapis_commits(self):
config=GenerationConfig(
gapic_generator_version="",
googleapis_commitish=commit_sha,
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=[],
Expand Down
2 changes: 0 additions & 2 deletions library_generation/test/generate_repo_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def __get_an_empty_generation_config() -> GenerationConfig:
return GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[],
)

Expand Down
2 changes: 0 additions & 2 deletions library_generation/test/model/config_change_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ def __get_a_gen_config(
return GenerationConfig(
gapic_generator_version="",
googleapis_commitish=googleapis_commitish,
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=libraries,
Expand Down
27 changes: 9 additions & 18 deletions library_generation/test/model/generation_config_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@


class GenerationConfigTest(unittest.TestCase):
def test_generation_config_default_value(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries=[],
)
self.assertEqual([], config.template_excludes)
self.assertEqual("", config.libraries_bom_version)

def test_from_yaml_succeeds(self):
config = from_yaml(f"{test_config_dir}/generation_config.yaml")
self.assertEqual("2.34.0", config.gapic_generator_version)
Expand Down Expand Up @@ -114,8 +123,6 @@ def test_is_monorepo_with_one_library_returns_false(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1],
)
self.assertFalse(config.is_monorepo())
Expand All @@ -124,8 +131,6 @@ def test_is_monorepo_with_two_libraries_returns_true(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1, library_2],
)
self.assertTrue(config.is_monorepo())
Expand All @@ -134,8 +139,6 @@ def test_contains_common_protos_with_common_protos_returns_true(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1, library_2, common_protos_library],
)
self.assertTrue(config.contains_common_protos())
Expand All @@ -144,8 +147,6 @@ def test_contains_common_protos_without_common_protos_returns_false(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1, library_2],
)
self.assertFalse(config.contains_common_protos())
Expand All @@ -157,8 +158,6 @@ def test_validate_with_duplicate_library_name_raise_exception(self):
GenerationConfig,
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[
LibraryConfig(
api_shortname="secretmanager",
Expand Down Expand Up @@ -194,14 +193,6 @@ def test_from_yaml_without_googleapis_commitish_raise_exception(self):
f"{test_config_dir}/config_without_googleapis.yaml",
)

def test_from_yaml_without_template_excludes_raise_exception(self):
self.assertRaisesRegex(
ValueError,
"Repo level parameter, template_excludes",
from_yaml,
f"{test_config_dir}/config_without_temp_excludes.yaml",
)

def test_from_yaml_without_libraries_raise_exception(self):
self.assertRaisesRegex(
ValueError,
Expand Down
1 change: 0 additions & 1 deletion library_generation/test/utilities_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ def __get_a_gen_config(
return GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[
".github/*",
".kokoro/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ def setUp(self) -> None:
self.baseline_config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=[self.baseline_library],
)
self.current_config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=[self.current_library],
Expand Down
Loading