Skip to content

Commit

Permalink
chore: prepare for monorepo migration (#252)
Browse files Browse the repository at this point in the history
* chore: prepare for monorepo migration

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* restore docs/index.rst

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
parthea and gcf-owl-bot[bot] authored Jun 8, 2023
1 parent 4449dc3 commit 314c828
Show file tree
Hide file tree
Showing 22 changed files with 2,177 additions and 57 deletions.
4 changes: 2 additions & 2 deletions packages/google-cloud-workflows/.github/.OwlBot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ deep-remove-regex:

deep-copy-regex:
- source: /google/cloud/workflows/executions/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/executions/$1/$2
dest: /owl-bot-staging/$1/$2
- source: /google/cloud/workflows/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/workflows/$1/$2
dest: /owl-bot-staging/$1/$2

begin-after-commit-hash: acb4b773a6df45f9303067ffcb21387a7b6ad40d

56 changes: 3 additions & 53 deletions packages/google-cloud-workflows/owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

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

Expand All @@ -32,61 +31,12 @@
"default_version"
)

# 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 []


for library in get_staging_dirs(default_version, "executions"):
# Make sure this library is named 'google-cloud-workflows'
s.replace(
library / "google/**/*.py", "google-cloud-workflows-executions", "google-cloud-workflows"
)
s.move([library], excludes=["**/gapic_version.py", "docs/index.rst"])

# move workflows after executions, since we want to use "workflows" for the name
for library in get_staging_dirs(default_version, "workflows"):
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=["**/gapic_version.py", "docs/index.rst"])

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

# ----------------------------------------------------------------------------
Expand All @@ -98,7 +48,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
Loading

0 comments on commit 314c828

Please sign in to comment.