From e2d3bff913ceed598fccc758697100e41747185f Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 13 May 2021 17:51:15 -0400 Subject: [PATCH] chore: migrate to owl bot (#97) * chore: migrate to owl bot * chore: copy files from googleapis-gen 6a5da3f1274b088752f074da5bc9e30bd1beb27e * chore: run the post processor --- .../.github/.OwlBot.lock.yaml | 4 + .../google-cloud-build/.github/.OwlBot.yaml | 26 ++++ packages/google-cloud-build/owlbot.py | 80 +++++++++++ packages/google-cloud-build/synth.metadata | 126 ------------------ packages/google-cloud-build/synth.py | 93 ------------- 5 files changed, 110 insertions(+), 219 deletions(-) create mode 100644 packages/google-cloud-build/.github/.OwlBot.lock.yaml create mode 100644 packages/google-cloud-build/.github/.OwlBot.yaml create mode 100644 packages/google-cloud-build/owlbot.py delete mode 100644 packages/google-cloud-build/synth.metadata delete mode 100644 packages/google-cloud-build/synth.py diff --git a/packages/google-cloud-build/.github/.OwlBot.lock.yaml b/packages/google-cloud-build/.github/.OwlBot.lock.yaml new file mode 100644 index 000000000000..d49860b32e70 --- /dev/null +++ b/packages/google-cloud-build/.github/.OwlBot.lock.yaml @@ -0,0 +1,4 @@ +docker: + digest: sha256:457583330eec64daa02aeb7a72a04d33e7be2428f646671ce4045dcbc0191b1e + image: gcr.io/repo-automation-bots/owlbot-python:latest + diff --git a/packages/google-cloud-build/.github/.OwlBot.yaml b/packages/google-cloud-build/.github/.OwlBot.yaml new file mode 100644 index 000000000000..27d4caa7f8e5 --- /dev/null +++ b/packages/google-cloud-build/.github/.OwlBot.yaml @@ -0,0 +1,26 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +docker: + image: gcr.io/repo-automation-bots/owlbot-python:latest + +deep-remove-regex: + - /owl-bot-staging + +deep-copy-regex: + - source: /google/devtools/cloudbuild/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + +begin-after-commit-hash: 6a5da3f1274b088752f074da5bc9e30bd1beb27e + diff --git a/packages/google-cloud-build/owlbot.py b/packages/google-cloud-build/owlbot.py new file mode 100644 index 000000000000..005bac3d65ff --- /dev/null +++ b/packages/google-cloud-build/owlbot.py @@ -0,0 +1,80 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""This script is used to synthesize generated parts of this library.""" + +import synthtool as s +from synthtool import gcp + +common = gcp.CommonTemplates() + +default_version = "v1" + +for library in s.get_staging_dirs(default_version): + # Fix namespace + s.replace( + library / f"google/devtools/**/*.py", + f"google.devtools.cloudbuild_{library.name}", + f"google.cloud.devtools.cloudbuild_{library.name}", + ) + s.replace( + library / f"tests/unit/gapic/**/*.py", + f"google.devtools.cloudbuild_{library.name}", + f"google.cloud.devtools.cloudbuild_{library.name}", + ) + s.replace( + library / f"docs/**/*.rst", + f"google.devtools.cloudbuild_{library.name}", + f"google.cloud.devtools.cloudbuild_{library.name}", + ) + + # Rename package to `google-cloud-build` + s.replace( + [library / "**/*.rst", library / "*/**/*.py", library / "**/*.md"], + "google-cloud-devtools-cloudbuild", + "google-cloud-build" + ) + + s.move(library / "google/devtools/cloudbuild", "google/cloud/devtools/cloudbuild") + s.move( + library / f"google/devtools/cloudbuild_{library.name}", + f"google/cloud/devtools/cloudbuild_{library.name}" + ) + s.move(library / "tests") + s.move(library / "scripts") + s.move(library / "docs", excludes=["index.rst"]) + +s.remove_staging_dirs() + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- +templated_files = common.py_library( + samples=False, # set to True only if there are samples + microgenerator=True, + cov_level=99, +) +s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file + +# TODO(busunkim): Use latest sphinx after microgenerator transition +s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') + +s.replace( + "noxfile.py", + "google.cloud.cloudbuild", + "google.cloud.devtools.cloudbuild", +) + + +s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/packages/google-cloud-build/synth.metadata b/packages/google-cloud-build/synth.metadata deleted file mode 100644 index 3b17ae644d64..000000000000 --- a/packages/google-cloud-build/synth.metadata +++ /dev/null @@ -1,126 +0,0 @@ -{ - "sources": [ - { - "git": { - "name": ".", - "remote": "https://github.com/googleapis/python-cloudbuild.git", - "sha": "91078e3c1f1a62cef9c6ea76d854acf0896da804" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "56fc6d43fed71188d7e18f3ca003544646c4ab35", - "internalRef": "366346972" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "cloudbuild", - "apiVersion": "v1", - "language": "python", - "generator": "bazel" - } - } - ], - "generatedFiles": [ - ".flake8", - ".github/CONTRIBUTING.md", - ".github/ISSUE_TEMPLATE/bug_report.md", - ".github/ISSUE_TEMPLATE/feature_request.md", - ".github/ISSUE_TEMPLATE/support_request.md", - ".github/PULL_REQUEST_TEMPLATE.md", - ".github/header-checker-lint.yml", - ".github/release-please.yml", - ".github/snippet-bot.yml", - ".gitignore", - ".kokoro/build.sh", - ".kokoro/continuous/common.cfg", - ".kokoro/continuous/continuous.cfg", - ".kokoro/docker/docs/Dockerfile", - ".kokoro/docker/docs/fetch_gpg_keys.sh", - ".kokoro/docs/common.cfg", - ".kokoro/docs/docs-presubmit.cfg", - ".kokoro/docs/docs.cfg", - ".kokoro/populate-secrets.sh", - ".kokoro/presubmit/common.cfg", - ".kokoro/presubmit/presubmit.cfg", - ".kokoro/publish-docs.sh", - ".kokoro/release.sh", - ".kokoro/release/common.cfg", - ".kokoro/release/release.cfg", - ".kokoro/samples/lint/common.cfg", - ".kokoro/samples/lint/continuous.cfg", - ".kokoro/samples/lint/periodic.cfg", - ".kokoro/samples/lint/presubmit.cfg", - ".kokoro/samples/python3.6/common.cfg", - ".kokoro/samples/python3.6/continuous.cfg", - ".kokoro/samples/python3.6/periodic-head.cfg", - ".kokoro/samples/python3.6/periodic.cfg", - ".kokoro/samples/python3.6/presubmit.cfg", - ".kokoro/samples/python3.7/common.cfg", - ".kokoro/samples/python3.7/continuous.cfg", - ".kokoro/samples/python3.7/periodic-head.cfg", - ".kokoro/samples/python3.7/periodic.cfg", - ".kokoro/samples/python3.7/presubmit.cfg", - ".kokoro/samples/python3.8/common.cfg", - ".kokoro/samples/python3.8/continuous.cfg", - ".kokoro/samples/python3.8/periodic-head.cfg", - ".kokoro/samples/python3.8/periodic.cfg", - ".kokoro/samples/python3.8/presubmit.cfg", - ".kokoro/test-samples-against-head.sh", - ".kokoro/test-samples-impl.sh", - ".kokoro/test-samples.sh", - ".kokoro/trampoline.sh", - ".kokoro/trampoline_v2.sh", - ".pre-commit-config.yaml", - ".trampolinerc", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.rst", - "LICENSE", - "MANIFEST.in", - "docs/_static/custom.css", - "docs/_templates/layout.html", - "docs/cloudbuild_v1/cloud_build.rst", - "docs/cloudbuild_v1/services.rst", - "docs/cloudbuild_v1/types.rst", - "docs/conf.py", - "docs/multiprocessing.rst", - "google/cloud/devtools/cloudbuild/__init__.py", - "google/cloud/devtools/cloudbuild/py.typed", - "google/cloud/devtools/cloudbuild_v1/__init__.py", - "google/cloud/devtools/cloudbuild_v1/proto/cloudbuild.proto", - "google/cloud/devtools/cloudbuild_v1/py.typed", - "google/cloud/devtools/cloudbuild_v1/services/__init__.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/__init__.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/__init__.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/base.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py", - "google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py", - "google/cloud/devtools/cloudbuild_v1/types/__init__.py", - "google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py", - "noxfile.py", - "renovate.json", - "samples/AUTHORING_GUIDE.md", - "samples/CONTRIBUTING.md", - "scripts/decrypt-secrets.sh", - "scripts/fixup_cloudbuild_v1_keywords.py", - "scripts/readme-gen/readme_gen.py", - "scripts/readme-gen/templates/README.tmpl.rst", - "scripts/readme-gen/templates/auth.tmpl.rst", - "scripts/readme-gen/templates/auth_api_key.tmpl.rst", - "scripts/readme-gen/templates/install_deps.tmpl.rst", - "scripts/readme-gen/templates/install_portaudio.tmpl.rst", - "setup.cfg", - "testing/.gitignore", - "tests/unit/gapic/cloudbuild_v1/__init__.py", - "tests/unit/gapic/cloudbuild_v1/test_cloud_build.py" - ] -} \ No newline at end of file diff --git a/packages/google-cloud-build/synth.py b/packages/google-cloud-build/synth.py deleted file mode 100644 index d69dd4213198..000000000000 --- a/packages/google-cloud-build/synth.py +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""This script is used to synthesize generated parts of this library.""" - -import synthtool as s -from synthtool import gcp - -gapic = gcp.GAPICBazel() -common = gcp.CommonTemplates() -version = 'v1' - -# ---------------------------------------------------------------------------- -# Generate cloudbuild GAPIC layer -# ---------------------------------------------------------------------------- -library = gapic.py_library( - service='cloudbuild', - version=version, - bazel_target=f"//google/devtools/cloudbuild/{version}:devtools-cloudbuild-{version}-py", - include_protos=True, - proto_output_path=f"google/devtools/cloudbuild_{version}/proto", -) - -s.move(library / "google/devtools/cloudbuild", "google/cloud/devtools/cloudbuild") -s.move( - library / f"google/devtools/cloudbuild_{version}", - f"google/cloud/devtools/cloudbuild_{version}" -) -s.move(library / "tests") -s.move(library / "scripts") -s.move(library / "docs", excludes=[library / "docs/index.rst"]) - -# Fix namespace -s.replace( - f"google/cloud/**/*.py", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) -s.replace( - f"tests/unit/gapic/**/*.py", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) -s.replace( - f"google/cloud/**/*.py", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) -s.replace( - f"docs/**/*.rst", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) - -# Rename package to `google-cloud-build` -s.replace( - ["**/*.rst", "*/**/*.py", "**/*.md"], - "google-cloud-devtools-cloudbuild", - "google-cloud-build" -) - -# ---------------------------------------------------------------------------- -# Add templated files -# ---------------------------------------------------------------------------- -templated_files = common.py_library( - samples=False, # set to True only if there are samples - microgenerator=True, - cov_level=99, -) -s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file - -# TODO(busunkim): Use latest sphinx after microgenerator transition -s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') - -s.replace( - "noxfile.py", - "google.cloud.cloudbuild", - "google.cloud.devtools.cloudbuild", -) - - -s.shell.run(["nox", "-s", "blacken"], hide_output=False)