From 75bd536031626b96846dd69381632f884d73d175 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 14 Jan 2025 00:54:58 +0000 Subject: [PATCH 1/3] build: cater for packages without gapic_version.py in release please config action --- .../configure_release_please.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/configure_release_please/configure_release_please.py b/scripts/configure_release_please/configure_release_please.py index 6d457a63a829..bc5bdfe01b31 100644 --- a/scripts/configure_release_please/configure_release_please.py +++ b/scripts/configure_release_please/configure_release_please.py @@ -6,6 +6,12 @@ SCRIPT_DIR = Path(__file__).resolve().parent ROOT_DIR = Path(SCRIPT_DIR / ".." / "..").resolve() PACKAGES_DIR = ROOT_DIR / "packages" +PACKAGES_WITHOUT_GAPIC_VERSION = [ + "google-cloud-access-context-manager", + "google-cloud-audit-log", + "googleapis-common-protos", + "grpc-google-iam-v1", +] def get_version_for_package(version_path: Path) -> Tuple[int]: @@ -70,6 +76,8 @@ def configure_release_please_manifest( with open(release_please_manifest, "r") as f: manifest_json = json.load(f) for package_dir in package_dirs: + if not package_supports_gapic_version(package_dir): + continue if f"packages/{package_dir.name}" not in manifest_json: manifest_json[f"packages/{package_dir.name}"] = "0.0.0" @@ -89,6 +97,16 @@ def configure_release_please_manifest( f.write("\n") +def package_supports_gapic_version(package_dir: str) -> bool: + """Returns True if the given package directory is expected to have gapic_version.py """ + + for package in PACKAGES_WITHOUT_GAPIC_VERSION: + if package_dir == Path(PACKAGES_DIR / package): + return False + + return True + + def configure_release_please_config( package_dirs: List[Path], root_dir: Path = ROOT_DIR ) -> None: @@ -111,7 +129,7 @@ def configure_release_please_config( str(file.relative_to(package_dir)) for file in sorted(package_dir.rglob("**/gapic_version.py")) ] - if len(extra_files) < 1: + if len(extra_files) < 1 and package_supports_gapic_version(package_dir): raise Exception("Failed to find gapic_version.py") for json_file in sorted(package_dir.glob("samples/**/*.json")): sample_json = {} From 67cf899a73937e7bca7073778fd1717bccf75652 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 16 Jan 2025 15:40:11 +0000 Subject: [PATCH 2/3] address review feedback --- .../configure_release_please/configure_release_please.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/configure_release_please/configure_release_please.py b/scripts/configure_release_please/configure_release_please.py index bc5bdfe01b31..f88e82781f65 100644 --- a/scripts/configure_release_please/configure_release_please.py +++ b/scripts/configure_release_please/configure_release_please.py @@ -76,14 +76,15 @@ def configure_release_please_manifest( with open(release_please_manifest, "r") as f: manifest_json = json.load(f) for package_dir in package_dirs: - if not package_supports_gapic_version(package_dir): - continue if f"packages/{package_dir.name}" not in manifest_json: manifest_json[f"packages/{package_dir.name}"] = "0.0.0" gapic_version_file = next(package_dir.rglob("**/gapic_version.py"), None) if gapic_version_file is None: - raise Exception("Failed to find gapic_version.py") + if package_supports_gapic_version(package_dir): + raise Exception("Failed to find gapic_version.py") + else: + continue version = get_version_for_package(gapic_version_file) # check the version in gapic_version.py and update if newer than the default which is # 0.0.0 or 0.1.0. From 13bef06915147343e2c868b01169970c3fc7db79 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 16 Jan 2025 17:39:23 +0000 Subject: [PATCH 3/3] address review feedback --- .../configure_release_please/configure_release_please.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/configure_release_please/configure_release_please.py b/scripts/configure_release_please/configure_release_please.py index f88e82781f65..fa947ca50cbb 100644 --- a/scripts/configure_release_please/configure_release_please.py +++ b/scripts/configure_release_please/configure_release_please.py @@ -79,12 +79,11 @@ def configure_release_please_manifest( if f"packages/{package_dir.name}" not in manifest_json: manifest_json[f"packages/{package_dir.name}"] = "0.0.0" + if not package_supports_gapic_version(package_dir): + continue gapic_version_file = next(package_dir.rglob("**/gapic_version.py"), None) if gapic_version_file is None: - if package_supports_gapic_version(package_dir): - raise Exception("Failed to find gapic_version.py") - else: - continue + raise Exception("Failed to find gapic_version.py") version = get_version_for_package(gapic_version_file) # check the version in gapic_version.py and update if newer than the default which is # 0.0.0 or 0.1.0.