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 2 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 @@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

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

For the case when gapic_version is supported by the package, we first verify it on line 79 and then again on line 85.

Does the github action fail at line 81? If so, Would it suffice if we move the condition at line 85 above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 67cf899

continue
if f"packages/{package_dir.name}" not in manifest_json:
manifest_json[f"packages/{package_dir.name}"] = "0.0.0"

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