Skip to content

chore: Add Owlbot configuration #10221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 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/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:240b5bcc2bafd450912d2da2be15e62bc6de2cf839823ae4bf94d4f392b451dc
16 changes: 16 additions & 0 deletions .github/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 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/cloud-devrel-public-resources/owlbot-python:latest
8 changes: 8 additions & 0 deletions .repo-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"default_version": "v1",
"name": "python-docs-samples",
"name_pretty": "Google Cloud Python Samples",
"issue_tracker": "https://github.com/GoogleCloudPlatform/python-docs-samples/issues",
"language": "python",
"repo": "GoogleCloudPlatform/python-docs-samples"
}
8 changes: 6 additions & 2 deletions AUTHORING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,26 @@ outside the scope of PEP 8, such as the “too many arguments” or “too many
local variables” warnings.

The use of [Black](https://pypi.org/project/black/) to standardize code
formatting and simplify diffs is recommended, but optional.
formatting and simplify diffs is recommended.

The default noxfile has `blacken` session for convenience. Here are
some examples.

If you have pyenv configured:

```sh
nox -s blacken
```

If you only have docker:
```

```sh
cd proj_directory
../scripts/run_tests_local.sh . blacken
```

Owlbot is an automated tool that will run the `blacken` session automatically on new pull requests.

In addition to the syntax guidelines covered in PEP 8, samples should strive
to follow the Pythonic philosophy outlined in the
[PEP 20 - Zen of Python](https://www.python.org/dev/peps/pep-0020/) as well
Expand Down
41 changes: 41 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 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.

import synthtool as s
import synthtool.gcp as gcp

templated_files = gcp.CommonTemplates().py_library()

# Copy the standard noxfile from templated_files
s.move(templated_files / "noxfile.py")

# Update BLACK_PATHS in order to run black on all files
s.replace(
"noxfile.py",
r"""LINT_PATHS = \["docs", "google", "tests", "noxfile.py", "setup.py"\]""",
r"""LINT_PATHS = ["."]""",
)

# TODO: Remove once https://github.com/googleapis/synthtool/pull/1811 is merged.
s.replace(
"noxfile.py",
r"""BLACK_VERSION = "black==22.3.0"\nISORT_VERSION = "isort==5.10.1""",
r"""BLACK_VERSION = "black[jupyter]==23.3.0"\nISORT_VERSION = "isort==5.11.0""",
)

# ----------------------------------------------------------------------------
# Run blacken session
# ----------------------------------------------------------------------------

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