Skip to content

Commit c75988c

Browse files
authored
chore: migrate to owl bot (#186)
* chore: migrate to owl bot * chore: copy files from googleapis-gen ee56c3493ec6aeb237ff515ecea949710944a20f * chore: run the post processor
1 parent feca74d commit c75988c

File tree

13 files changed

+104
-349
lines changed

13 files changed

+104
-349
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
docker:
2+
digest: sha256:457583330eec64daa02aeb7a72a04d33e7be2428f646671ce4045dcbc0191b1e
3+
image: gcr.io/repo-automation-bots/owlbot-python:latest
4+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2021 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+
docker:
16+
image: gcr.io/repo-automation-bots/owlbot-python:latest
17+
18+
deep-remove-regex:
19+
- /owl-bot-staging
20+
21+
deep-preserve-regex:
22+
- /owl-bot-staging/v1p7beta1
23+
24+
deep-copy-regex:
25+
- source: /google/cloud/asset/(v.*)/.*-py/(.*)
26+
dest: /owl-bot-staging/$1/$2
27+
28+
begin-after-commit-hash: ee56c3493ec6aeb237ff515ecea949710944a20f
29+

packages/google-cloud-asset/.github/header-checker-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{"allowedCopyrightHolders": ["Google LLC"],
22
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
3-
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
3+
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt", "**/__init__.py", "samples/**/constraints.txt", "samples/**/constraints-test.txt"],
44
"sourceFileExtensions": [
55
"ts",
66
"js",

packages/google-cloud-asset/.kokoro/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools
2626
export PYTHONUNBUFFERED=1
2727

2828
# Move into the package, build the distribution and upload.
29-
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password")
29+
TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token")
3030
cd github/python-asset
3131
python3 setup.py sdist bdist_wheel
32-
twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/*
32+
twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*

packages/google-cloud-asset/.kokoro/release/common.cfg

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,8 @@ env_vars: {
2323
value: "github/python-asset/.kokoro/release.sh"
2424
}
2525

26-
# Fetch PyPI password
27-
before_action {
28-
fetch_keystore {
29-
keystore_resource {
30-
keystore_config_id: 73713
31-
keyname: "google_cloud_pypi_password"
32-
}
33-
}
34-
}
35-
3626
# Tokens needed to report release status back to GitHub
3727
env_vars: {
3828
key: "SECRET_MANAGER_KEYS"
39-
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
40-
}
29+
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token"
30+
}

packages/google-cloud-asset/.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ repos:
2626
hooks:
2727
- id: black
2828
- repo: https://gitlab.com/pycqa/flake8
29-
rev: 3.9.0
29+
rev: 3.9.1
3030
hooks:
3131
- id: flake8

packages/google-cloud-asset/CONTRIBUTING.rst

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,7 @@ Running System Tests
160160
auth settings and change some configuration in your project to
161161
run all the tests.
162162

163-
- System tests will be run against an actual project and
164-
so you'll need to provide some environment variables to facilitate
165-
authentication to your project:
166-
167-
- ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file;
168-
Such a file can be downloaded directly from the developer's console by clicking
169-
"Generate new JSON key". See private key
170-
`docs <https://cloud.google.com/storage/docs/authentication#generating-a-private-key>`__
171-
for more details.
172-
173-
- Once you have downloaded your json keys, set the environment variable
174-
``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file::
175-
176-
$ export GOOGLE_APPLICATION_CREDENTIALS="/Users/<your_username>/path/to/app_credentials.json"
177-
163+
- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication <https://cloud.google.com/docs/authentication/best-practices-applications#local_development_and_testing_with_the>`__. Some tests require a service account. For those tests see `Authenticating as a service account <https://cloud.google.com/docs/authentication/production>`__.
178164

179165
*************
180166
Test Coverage
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
div#python2-eol {
22
border-color: red;
33
border-width: medium;
4-
}
4+
}
55

66
/* Ensure minimum width for 'Parameters' / 'Returns' column */
77
dl.field-list > dt {
88
min-width: 100px
99
}
10+
11+
/* Insert space between methods for readability */
12+
dl.method {
13+
padding-top: 10px;
14+
padding-bottom: 10px
15+
}
16+
17+
/* Insert empty space between classes */
18+
dl.class {
19+
padding-bottom: 50px
20+
}

packages/google-cloud-asset/noxfile.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,9 @@ def lint(session):
6262
session.run("flake8", "google", "tests")
6363

6464

65-
@nox.session(python="3.6")
65+
@nox.session(python=DEFAULT_PYTHON_VERSION)
6666
def blacken(session):
67-
"""Run black.
68-
69-
Format code to uniform standard.
70-
71-
This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
72-
That run uses an image that doesn't have 3.6 installed. Before updating this
73-
check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
74-
"""
67+
"""Run black. Format code to uniform standard."""
7568
session.install(BLACK_VERSION)
7669
session.run(
7770
"black", *BLACK_PATHS,
@@ -131,9 +124,6 @@ def system(session):
131124
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
132125
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
133126
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
134-
# Sanity check: Only run tests if the environment variable is set.
135-
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
136-
session.skip("Credentials must be set via environment variable")
137127
# Install pyopenssl for mTLS testing.
138128
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
139129
session.install("pyopenssl")
Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,58 +20,52 @@
2020
from synthtool import gcp
2121
from synthtool.languages import python
2222

23-
gapic = gcp.GAPICBazel()
2423
common = gcp.CommonTemplates()
25-
versions = ["v1p1beta1", "v1p2beta1", "v1p4beta1", "v1p5beta1", "v1"]
2624

27-
excludes = ["setup.py", "nox*.py", "README.rst", "docs/conf.py", "docs/index.rst"]
25+
default_version = "v1"
2826

29-
# ----------------------------------------------------------------------------
30-
# Generate asset GAPIC layer
31-
# ----------------------------------------------------------------------------
32-
for version in versions:
33-
library = gapic.py_library(
34-
service="asset",
35-
version=version,
36-
bazel_target=f"//google/cloud/asset/{version}:asset-{version}-py",
27+
for library in s.get_staging_dirs(default_version):
28+
# Fix import of 'osconfig' type
29+
s.replace(
30+
library / f"google/cloud/asset_{library.name}/types/assets.py",
31+
f"from google\.cloud\.osconfig\.{library.name} import inventory_pb2 as inventory",
32+
f"from google.cloud.osconfig_{library.name} import Inventory"
3733
)
3834

39-
s.move(library, excludes=excludes)
35+
s.replace(
36+
library / f"google/cloud/asset_{library.name}/types/assets.py",
37+
"message=inventory\.Inventory,",
38+
"message=Inventory,"
39+
)
4040

41-
# Fix import of 'osconfig' type
42-
s.replace(
43-
"google/cloud/asset_v1/types/assets.py",
44-
"from google\.cloud\.osconfig\.v1 import inventory_pb2 as inventory",
45-
"from google.cloud.osconfig_v1 import Inventory"
46-
)
41+
# Remove broken `parse_asset_path` method
42+
# The resource pattern is '*' which breaks the regex match
43+
s.replace(
44+
library / "google/cloud/**/client.py",
45+
"""@staticmethod
46+
def parse_asset_path.*?@staticmethod""",
47+
"""@staticmethod""",
48+
flags=re.MULTILINE | re.DOTALL
49+
)
4750

48-
s.replace(
49-
"google/cloud/asset_v1/types/assets.py",
50-
"message=inventory\.Inventory,",
51-
"message=Inventory,"
52-
)
51+
s.replace(
52+
library / "google/cloud/**/async_client.py",
53+
"""parse_asset_path = staticmethod\(AssetServiceClient\.parse_asset_path\)""",
54+
""
55+
)
5356

54-
# Remove broken `parse_asset_path` method
55-
# The resource pattern is '*' which breaks the regex match
56-
s.replace(
57-
"google/cloud/**/client.py",
58-
"""@staticmethod
59-
def parse_asset_path.*?@staticmethod""",
60-
"""@staticmethod""",
61-
flags=re.MULTILINE | re.DOTALL
62-
)
57+
s.replace(
58+
library / "tests/unit/**/test_asset_service.py",
59+
"""def test_parse_asset_path.*?def""",
60+
"""def""",
61+
flags=re.MULTILINE | re.DOTALL,
62+
)
63+
64+
excludes = ["setup.py", "nox*.py", "README.rst", "docs/conf.py", "docs/index.rst"]
65+
s.move(library, excludes=excludes)
66+
67+
s.remove_staging_dirs()
6368

64-
s.replace(
65-
"google/cloud/**/async_client.py",
66-
"""parse_asset_path = staticmethod\(AssetServiceClient\.parse_asset_path\)""",
67-
""
68-
)
69-
s.replace(
70-
"tests/unit/**/test_asset_service.py",
71-
"""def test_parse_asset_path.*?def""",
72-
"""def""",
73-
flags=re.MULTILINE | re.DOTALL,
74-
)
7569
# ----------------------------------------------------------------------------
7670
# Add templated files
7771
# ----------------------------------------------------------------------------
@@ -92,4 +86,4 @@ def parse_asset_path.*?@staticmethod""",
9286
# https://github.com/googleapis/gapic-generator-python/issues/525
9387
s.replace("noxfile.py", '[\"\']-W[\"\']', '# "-W"')
9488

95-
s.shell.run(["nox", "-s", "blacken"], hide_output=False)
89+
s.shell.run(["nox", "-s", "blacken"], hide_output=False)

0 commit comments

Comments
 (0)