|
| 1 | +# Copyright 2019 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +"""This script is used to synthesize generated parts of this library.""" |
| 16 | + |
| 17 | +import synthtool as s |
| 18 | +from synthtool import gcp |
| 19 | + |
| 20 | +common = gcp.CommonTemplates() |
| 21 | + |
| 22 | +default_version = "v1" |
| 23 | + |
| 24 | +for library in s.get_staging_dirs(default_version): |
| 25 | + # Fix namespace |
| 26 | + s.replace( |
| 27 | + library / f"google/devtools/**/*.py", |
| 28 | + f"google.devtools.cloudbuild_{library.name}", |
| 29 | + f"google.cloud.devtools.cloudbuild_{library.name}", |
| 30 | + ) |
| 31 | + s.replace( |
| 32 | + library / f"tests/unit/gapic/**/*.py", |
| 33 | + f"google.devtools.cloudbuild_{library.name}", |
| 34 | + f"google.cloud.devtools.cloudbuild_{library.name}", |
| 35 | + ) |
| 36 | + s.replace( |
| 37 | + library / f"docs/**/*.rst", |
| 38 | + f"google.devtools.cloudbuild_{library.name}", |
| 39 | + f"google.cloud.devtools.cloudbuild_{library.name}", |
| 40 | + ) |
| 41 | + |
| 42 | + # Rename package to `google-cloud-build` |
| 43 | + s.replace( |
| 44 | + [library / "**/*.rst", library / "*/**/*.py", library / "**/*.md"], |
| 45 | + "google-cloud-devtools-cloudbuild", |
| 46 | + "google-cloud-build" |
| 47 | + ) |
| 48 | + |
| 49 | + s.move(library / "google/devtools/cloudbuild", "google/cloud/devtools/cloudbuild") |
| 50 | + s.move( |
| 51 | + library / f"google/devtools/cloudbuild_{library.name}", |
| 52 | + f"google/cloud/devtools/cloudbuild_{library.name}" |
| 53 | + ) |
| 54 | + s.move(library / "tests") |
| 55 | + s.move(library / "scripts") |
| 56 | + s.move(library / "docs", excludes=["index.rst"]) |
| 57 | + |
| 58 | +s.remove_staging_dirs() |
| 59 | + |
| 60 | +# ---------------------------------------------------------------------------- |
| 61 | +# Add templated files |
| 62 | +# ---------------------------------------------------------------------------- |
| 63 | +templated_files = common.py_library( |
| 64 | + samples=False, # set to True only if there are samples |
| 65 | + microgenerator=True, |
| 66 | + cov_level=99, |
| 67 | +) |
| 68 | +s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file |
| 69 | + |
| 70 | +# TODO(busunkim): Use latest sphinx after microgenerator transition |
| 71 | +s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') |
| 72 | + |
| 73 | +s.replace( |
| 74 | + "noxfile.py", |
| 75 | + "google.cloud.cloudbuild", |
| 76 | + "google.cloud.devtools.cloudbuild", |
| 77 | +) |
| 78 | + |
| 79 | + |
| 80 | +s.shell.run(["nox", "-s", "blacken"], hide_output=False) |
0 commit comments