Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
chore: prepare for monorepo migration
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Aug 14, 2023
1 parent efbab67 commit dffc182
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .coveragerc
Expand Up @@ -4,8 +4,8 @@ branch = True
[report]
show_missing = True
omit =
google/cloud/iam_credentials/__init__.py
google/cloud/iam_credentials/gapic_version.py
google/cloud/iam/__init__.py
google/cloud/iam/gapic_version.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
Expand Down
4 changes: 2 additions & 2 deletions .github/.OwlBot.yaml
Expand Up @@ -24,9 +24,9 @@ deep-preserve-regex:

deep-copy-regex:
- source: /google/iam/credentials/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/iamcredentials/$1/$2
dest: /owl-bot-staging/$1/$2
- source: /google/iam/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/iam/$1/$2
dest: /owl-bot-staging/$1/$2

begin-after-commit-hash: 130ce904e5d546c312943d10f48799590f9c0f66

2 changes: 1 addition & 1 deletion .repo-metadata.json
Expand Up @@ -11,7 +11,7 @@
"repo": "googleapis/python-iam",
"distribution_name": "google-cloud-iam",
"api_id": "iam.googleapis.com",
"default_version": "v1",
"default_version": "v2",
"codeowner_team": "",
"api_shortname": "iamcredentials"
}
4 changes: 4 additions & 0 deletions docs/index.rst
Expand Up @@ -2,6 +2,9 @@

.. include:: multiprocessing.rst

This package includes clients for multiple versions of Cloud Identity and Access Management.
By default, you will get version ``iam_v2``.


API Reference
-------------
Expand All @@ -27,6 +30,7 @@ API Reference
iam_v2beta/services
iam_v2beta/types


Migration Guide
---------------

Expand Down
58 changes: 7 additions & 51 deletions owlbot.py
Expand Up @@ -14,8 +14,6 @@

import json
from pathlib import Path
from typing import List, Optional

import shutil

import synthtool as s
Expand All @@ -28,58 +26,16 @@

clean_up_generated_samples = True

# This is a customized version of the s.get_staging_dirs() function from synthtool to
# cater for copying 2 different folders from googleapis-gen
# which are workflows and workflows/executions
# Source https://github.com/googleapis/synthtool/blob/master/synthtool/transforms.py#L280
def get_staging_dirs(
default_version: Optional[str] = None, sub_directory: Optional[str] = None
) -> List[Path]:
"""Returns the list of directories, one per version, copied from
https://github.com/googleapis/googleapis-gen. Will return in lexical sorting
order with the exception of the default_version which will be last (if specified).
Args:
default_version (str): the default version of the API. The directory for this version
will be the last item in the returned list if specified.
sub_directory (str): if a `sub_directory` is provided, only the directories within the
specified `sub_directory` will be returned.
Returns: the empty list if no file were copied.
"""

staging = Path("owl-bot-staging")

if sub_directory:
staging /= sub_directory

if staging.is_dir():
# Collect the subdirectories of the staging directory.
versions = [v.name for v in staging.iterdir() if v.is_dir()]
# Reorder the versions so the default version always comes last.
versions = [v for v in versions if v != default_version]
versions.sort()
if default_version is not None:
versions += [default_version]
dirs = [staging / v for v in versions]
for dir in dirs:
s._tracked_paths.add(dir)
return dirs
else:
return []

# This library ships clients for two different APIs,
# IAM and IAM credentials
iam_credentials_default_version = "v1"
iam_default_version = "v2"
# Load the default version defined in .repo-metadata.json.
default_version = json.load(open(".repo-metadata.json", "rt")).get(
"default_version"
)

for library in get_staging_dirs(iam_default_version, "iam"):
for library in s.get_staging_dirs(default_version):
if clean_up_generated_samples:
shutil.rmtree("samples/generated_samples", ignore_errors=True)
clean_up_generated_samples = False
s.move([library], excludes=["docs/index.rst", "**/gapic_version.py"])

for library in get_staging_dirs(iam_credentials_default_version, "iamcredentials"):
s.move([library], excludes=["setup.py", "docs/index.rst", "**/gapic_version.py"])

s.move([library], excludes=["**/gapic_version.py"])
s.remove_staging_dirs()

# ----------------------------------------------------------------------------
Expand All @@ -91,7 +47,7 @@ def get_staging_dirs(
microgenerator=True,
versions=gcp.common.detect_versions(path="./google", default_first=True),
)
s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml", "docs/index.rst"])
s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"])

python.py_samples(skip_readmes=True)

Expand Down

0 comments on commit dffc182

Please sign in to comment.