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 # {x-version-update:gapic-generator-java:current}
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
16 changes: 1 addition & 15 deletions library_generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ 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 |

### Library level parameters

Expand Down Expand Up @@ -147,19 +146,6 @@ gapic_generator_version: 2.34.0
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
destination_path: google-cloud-java
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: apigeeconnect
name_pretty: Apigee Connect
Expand Down
7 changes: 3 additions & 4 deletions library_generation/model/generation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def __init__(
self,
gapic_generator_version: str,
googleapis_commitish: str,
template_excludes: list[str],
libraries: list[LibraryConfig],
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.libraries = libraries
self.grpc_version = grpc_version
self.protoc_version = protoc_version
Expand Down Expand Up @@ -149,7 +149,6 @@ 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),
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
3 changes: 0 additions & 3 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 All @@ -84,7 +82,6 @@ def test_generate_pr_description_does_not_create_pr_description_without_qualifie
gapic_generator_version="",
googleapis_commitish=new_commit_sha,
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
# use empty libraries to make sure no qualified commit between
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
42 changes: 8 additions & 34 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,14 @@


class GenerationConfigTest(unittest.TestCase):
def test_generation_config_default_value(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries=[],
)
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 All @@ -53,22 +61,6 @@ def test_from_yaml_succeeds(self):
"1a45bf7393b52407188c82e63101db7dc9c72026", config.googleapis_commitish
)
self.assertEqual("26.37.0", config.libraries_bom_version)
self.assertEqual(
[
".github/*",
".kokoro/*",
"samples/*",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE",
"SECURITY.md",
"java.header",
"license-checks.xml",
"renovate.json",
".gitignore",
],
config.template_excludes,
)
library = config.libraries[0]
self.assertEqual("cloudasset", library.api_shortname)
self.assertEqual("Cloud Asset Inventory", library.name_pretty)
Expand Down Expand Up @@ -114,8 +106,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 +114,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 +122,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 +130,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 +141,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 +176,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
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ gapic_generator_version: 2.38.1
protoc_version: 25.2
googleapis_commitish: a17d4caf184b050d50cacf2b0d579ce72c31ce74
libraries_bom_version: 26.37.0
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: apigeeconnect
name_pretty: Apigee Connect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ gapic_generator_version: 2.38.1
protoc_version: 25.2
googleapis_commitish: 4ce0ff67a3d4509be641cbe47a35844ddc1268fc
libraries_bom_version: 26.37.0
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: apigeeconnect
name_pretty: Apigee Connect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
gapic_generator_version: 2.37.0
protoc_version: 25.2
googleapis_commitish: 9868a57470a969ffa1d21194a5c05d7a6e4e98cc
template_excludes:
- ".gitignore"
- ".kokoro/presubmit/integration.cfg"
- ".kokoro/presubmit/graalvm-native.cfg"
- ".kokoro/presubmit/graalvm-native-17.cfg"
- ".kokoro/nightly/integration.cfg"
- ".kokoro/presubmit/samples.cfg"
- ".kokoro/nightly/samples.cfg"
- ".github/ISSUE_TEMPLATE/bug_report.md"
- ".github/PULL_REQUEST_TEMPLATE.md"
- "CONTRIBUTING.md"
- "codecov.yaml"
- ".github/release-please.yml"
- "renovate.json"
- ".kokoro/requirements.in"
- ".kokoro/requirements.txt"
libraries:
- api_shortname: bigtable
name_pretty: Cloud Bigtable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ gapic_generator_version: 2.34.0
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: cloudasset
name_pretty: Cloud Asset Inventory
Expand Down
14 changes: 0 additions & 14 deletions library_generation/test/utilities_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,6 @@ def __get_a_gen_config(
return GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[
".github/*",
".kokoro/*",
"samples/*",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE",
"SECURITY.md",
"java.header",
"license-checks.xml",
"renovate.json",
".gitignore",
],
libraries=libraries,
)

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
15 changes: 14 additions & 1 deletion library_generation/utils/utilities.py
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still confirm the template excludes behave correctly using the owlbot.py golden test, right?

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, the unit test is not changed.

Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,23 @@ def generate_prerequisite_files(

# generate owlbot.py
py_file = "owlbot.py"
template_excludes = [
".github/*",
".kokoro/*",
"samples/*",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE",
"SECURITY.md",
"java.header",
"license-checks.xml",
"renovate.json",
".gitignore",
]
if not os.path.exists(f"{library_path}/{py_file}"):
render(
template_name="owlbot.py.j2",
output_name=f"{library_path}/{py_file}",
should_include_templates=True,
template_excludes=config.template_excludes,
template_excludes=template_excludes,
)
Loading