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

build: cater for packages without gapic_version.py in release please config action #13436

Merged
merged 4 commits into from
Jan 16, 2025
Merged
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
20 changes: 19 additions & 1 deletion scripts/configure_release_please/configure_release_please.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -73,6 +79,8 @@ 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:
raise Exception("Failed to find gapic_version.py")
Expand All @@ -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:
Expand All @@ -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 = {}
Expand Down
Loading