diff --git a/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java b/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java index a51bdff91b..85e3a060bb 100644 --- a/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java +++ b/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java @@ -36,7 +36,6 @@ import java.util.Set; import java.util.stream.Stream; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -302,7 +301,6 @@ void complexResourceIdEqualsWildcard() { } @Test - @Disabled("https://github.com/googleapis/sdk-platform-java/issues/2778") void complexResourceIdEqualsPathWildcard() { Exception exception = Assertions.assertThrows( @@ -312,15 +310,6 @@ void complexResourceIdEqualsPathWildcard() { String.format( "parse error: wildcard path not allowed in complex ID resource '%s'", "zone_a"), exception.getMessage()); - - exception = - Assertions.assertThrows( - ValidationException.class, - () -> PathTemplate.create("projects/{project=*}/zones/{zone_a}.{zone_b=**}")); - Assertions.assertEquals( - String.format( - "parse error: wildcard path not allowed in complex ID resource '%s'", "zone_b"), - exception.getMessage()); } @Test @@ -360,9 +349,18 @@ void complexResourceIdNoSeparator() { "parse error: missing or 2+ consecutive delimiter characters in '%s'", "{zone_a}_{zone_b}{zone_c}"), exception.getMessage()); + + exception = + Assertions.assertThrows( + ValidationException.class, + () -> PathTemplate.create("projects/{project=*}/zones/{zone_a}{{zone_b}")); + Assertions.assertEquals( + String.format( + "parse error: missing or 2+ consecutive delimiter characters in '%s'", + "{zone_a}{{zone_b}"), + exception.getMessage()); } - @Disabled("https://github.com/googleapis/sdk-platform-java/issues/2776") @ParameterizedTest @MethodSource("invalidDelimiters") void complexResourceIdInvalidDelimiter(String invalidDelimiter) { @@ -381,7 +379,7 @@ void complexResourceIdInvalidDelimiter(String invalidDelimiter) { } static Stream invalidDelimiters() { - return Stream.of("|", "!", "@", "a", "1", ",", "{", ")"); + return Stream.of("|", "!", "@", "a", "1", ",", ")"); } @Test diff --git a/generation_config.yaml b/generation_config.yaml index 9c3ca80e0e..31c39e44ae 100644 --- a/generation_config.yaml +++ b/generation_config.yaml @@ -1,19 +1,5 @@ gapic_generator_version: 2.40.2-SNAPSHOT # {x-version-update:gapic-generator-java:current} googleapis_commitish: 3d50414a7ff3f0b8ffe8ad7858257396e4f18131 -template_excludes: -- .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. diff --git a/library_generation/README.md b/library_generation/README.md index 41e481c201..7ffe6a4a57 100644 --- a/library_generation/README.md +++ b/library_generation/README.md @@ -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 @@ -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 diff --git a/library_generation/model/generation_config.py b/library_generation/model/generation_config.py index 70e4adeec8..4503daf163 100644 --- a/library_generation/model/generation_config.py +++ b/library_generation/model/generation_config.py @@ -32,7 +32,6 @@ 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, @@ -40,8 +39,9 @@ def __init__( ): 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 @@ -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), diff --git a/library_generation/test/generate_pr_description_unit_tests.py b/library_generation/test/generate_pr_description_unit_tests.py index 3acc3f4e82..1a86770ac0 100644 --- a/library_generation/test/generate_pr_description_unit_tests.py +++ b/library_generation/test/generate_pr_description_unit_tests.py @@ -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=[], @@ -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 diff --git a/library_generation/test/generate_repo_unit_tests.py b/library_generation/test/generate_repo_unit_tests.py index 9269fb08a1..6085c237a6 100644 --- a/library_generation/test/generate_repo_unit_tests.py +++ b/library_generation/test/generate_repo_unit_tests.py @@ -45,8 +45,6 @@ def __get_an_empty_generation_config() -> GenerationConfig: return GenerationConfig( gapic_generator_version="", googleapis_commitish="", - libraries_bom_version="", - template_excludes=[], libraries=[], ) diff --git a/library_generation/test/model/config_change_unit_tests.py b/library_generation/test/model/config_change_unit_tests.py index 8349a7e1fa..6207c2100a 100644 --- a/library_generation/test/model/config_change_unit_tests.py +++ b/library_generation/test/model/config_change_unit_tests.py @@ -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, diff --git a/library_generation/test/model/generation_config_unit_tests.py b/library_generation/test/model/generation_config_unit_tests.py index dafbe238da..258b0db415 100644 --- a/library_generation/test/model/generation_config_unit_tests.py +++ b/library_generation/test/model/generation_config_unit_tests.py @@ -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) @@ -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) @@ -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()) @@ -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()) @@ -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()) @@ -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()) @@ -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", @@ -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, diff --git a/library_generation/test/resources/integration/google-cloud-java/baseline_generation_config.yaml b/library_generation/test/resources/integration/google-cloud-java/baseline_generation_config.yaml index 2b13ebb50f..9a27dd381d 100644 --- a/library_generation/test/resources/integration/google-cloud-java/baseline_generation_config.yaml +++ b/library_generation/test/resources/integration/google-cloud-java/baseline_generation_config.yaml @@ -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 diff --git a/library_generation/test/resources/integration/google-cloud-java/current_generation_config.yaml b/library_generation/test/resources/integration/google-cloud-java/current_generation_config.yaml index 995ab31eb9..adc1d170d6 100644 --- a/library_generation/test/resources/integration/google-cloud-java/current_generation_config.yaml +++ b/library_generation/test/resources/integration/google-cloud-java/current_generation_config.yaml @@ -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 diff --git a/library_generation/test/resources/integration/java-bigtable/generation_config.yaml b/library_generation/test/resources/integration/java-bigtable/generation_config.yaml index 784206521f..c6912c8125 100644 --- a/library_generation/test/resources/integration/java-bigtable/generation_config.yaml +++ b/library_generation/test/resources/integration/java-bigtable/generation_config.yaml @@ -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 diff --git a/library_generation/test/resources/test-config/generation_config.yaml b/library_generation/test/resources/test-config/generation_config.yaml index 6bd83e20d2..168c8fd9a5 100644 --- a/library_generation/test/resources/test-config/generation_config.yaml +++ b/library_generation/test/resources/test-config/generation_config.yaml @@ -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 diff --git a/library_generation/test/utilities_unit_tests.py b/library_generation/test/utilities_unit_tests.py index 565d0063da..1d522114cc 100644 --- a/library_generation/test/utilities_unit_tests.py +++ b/library_generation/test/utilities_unit_tests.py @@ -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, ) diff --git a/library_generation/test/utils/generation_config_comparator_unit_tests.py b/library_generation/test/utils/generation_config_comparator_unit_tests.py index be0568c1f4..8d018a7c15 100644 --- a/library_generation/test/utils/generation_config_comparator_unit_tests.py +++ b/library_generation/test/utils/generation_config_comparator_unit_tests.py @@ -39,8 +39,6 @@ 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], @@ -48,8 +46,6 @@ def setUp(self) -> None: self.current_config = GenerationConfig( gapic_generator_version="", googleapis_commitish="", - libraries_bom_version="", - template_excludes=[], grpc_version="", protoc_version="", libraries=[self.current_library], diff --git a/library_generation/utils/utilities.py b/library_generation/utils/utilities.py index 99673fb1bc..f21c35bf0e 100755 --- a/library_generation/utils/utilities.py +++ b/library_generation/utils/utilities.py @@ -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, )