|
| 1 | +# Copyright 2018 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 | +import synthtool as s |
| 17 | +from synthtool import gcp |
| 18 | +from synthtool.languages import python |
| 19 | + |
| 20 | +common = gcp.CommonTemplates() |
| 21 | + |
| 22 | +spanner_default_version = "v1" |
| 23 | +spanner_admin_instance_default_version = "v1" |
| 24 | +spanner_admin_database_default_version = "v1" |
| 25 | + |
| 26 | +for library in s.get_staging_dirs(spanner_default_version): |
| 27 | + if library.parent.absolute() == "spanner": |
| 28 | + s.move(library, excludes=["google/cloud/spanner/**", "*.*", "docs/index.rst", "google/cloud/spanner_v1/__init__.py"]) |
| 29 | + |
| 30 | +s.remove_staging_dirs() |
| 31 | + |
| 32 | +for library in s.get_staging_dirs(spanner_admin_instance_default_version): |
| 33 | + if library.parent.absolute() == "spanner_admin_instance": |
| 34 | + s.move(library, excludes=["google/cloud/spanner_admin_instance/**", "*.*", "docs/index.rst"]) |
| 35 | + |
| 36 | +s.remove_staging_dirs() |
| 37 | + |
| 38 | +for library in s.get_staging_dirs(spanner_admin_database_default_version): |
| 39 | + if library.parent.absolute() == "spanner_admin_database": |
| 40 | + s.move(library, excludes=["google/cloud/spanner_admin_database/**", "*.*", "docs/index.rst"]) |
| 41 | + |
| 42 | +s.remove_staging_dirs() |
| 43 | + |
| 44 | +# ---------------------------------------------------------------------------- |
| 45 | +# Add templated files |
| 46 | +# ---------------------------------------------------------------------------- |
| 47 | +templated_files = common.py_library(microgenerator=True, samples=True) |
| 48 | +s.move(templated_files, excludes=[".coveragerc", "noxfile.py"]) |
| 49 | + |
| 50 | +# Ensure CI runs on a new instance each time |
| 51 | +s.replace( |
| 52 | + ".kokoro/build.sh", |
| 53 | + "# Remove old nox", |
| 54 | + "# Set up creating a new instance for each system test run\n" |
| 55 | + "export GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE=true\n" |
| 56 | + "\n\g<0>", |
| 57 | +) |
| 58 | + |
| 59 | +# ---------------------------------------------------------------------------- |
| 60 | +# Samples templates |
| 61 | +# ---------------------------------------------------------------------------- |
| 62 | + |
| 63 | +python.py_samples() |
| 64 | + |
| 65 | +s.shell.run(["nox", "-s", "blacken"], hide_output=False) |
0 commit comments