Skip to content

Commit 72259bf

Browse files
authored
chore: Add Owlbot configuration (#10221)
- Redo of #10011 and #10219
1 parent aaa077e commit 72259bf

File tree

5 files changed

+88
-2
lines changed

5 files changed

+88
-2
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2023 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/cloud-devrel-public-resources/owlbot-python:latest
17+
digest: sha256:240b5bcc2bafd450912d2da2be15e62bc6de2cf839823ae4bf94d4f392b451dc

.github/.OwlBot.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2023 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/cloud-devrel-public-resources/owlbot-python:latest

.repo-metadata.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"default_version": "v1",
3+
"name": "python-docs-samples",
4+
"name_pretty": "Google Cloud Python Samples",
5+
"issue_tracker": "https://github.com/GoogleCloudPlatform/python-docs-samples/issues",
6+
"language": "python",
7+
"repo": "GoogleCloudPlatform/python-docs-samples"
8+
}

AUTHORING_GUIDE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,26 @@ outside the scope of PEP 8, such as the “too many arguments” or “too many
151151
local variables” warnings.
152152

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

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

159159
If you have pyenv configured:
160+
160161
```sh
161162
nox -s blacken
162163
```
163164

164165
If you only have docker:
165-
```
166+
167+
```sh
166168
cd proj_directory
167169
../scripts/run_tests_local.sh . blacken
168170
```
169171

172+
Owlbot is an automated tool that will run the `blacken` session automatically on new pull requests.
173+
170174
In addition to the syntax guidelines covered in PEP 8, samples should strive
171175
to follow the Pythonic philosophy outlined in the
172176
[PEP 20 - Zen of Python](https://www.python.org/dev/peps/pep-0020/) as well

owlbot.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2023 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+
import synthtool as s
16+
import synthtool.gcp as gcp
17+
18+
templated_files = gcp.CommonTemplates().py_library()
19+
20+
# Copy the standard noxfile from templated_files
21+
s.move(templated_files / "noxfile.py")
22+
23+
# Update BLACK_PATHS in order to run black on all files
24+
s.replace(
25+
"noxfile.py",
26+
r"""LINT_PATHS = \["docs", "google", "tests", "noxfile.py", "setup.py"\]""",
27+
r"""LINT_PATHS = ["."]""",
28+
)
29+
30+
# TODO: Remove once https://github.com/googleapis/synthtool/pull/1811 is merged.
31+
s.replace(
32+
"noxfile.py",
33+
r"""BLACK_VERSION = "black==22.3.0"\nISORT_VERSION = "isort==5.10.1""",
34+
r"""BLACK_VERSION = "black[jupyter]==23.3.0"\nISORT_VERSION = "isort==5.11.0""",
35+
)
36+
37+
# ----------------------------------------------------------------------------
38+
# Run blacken session
39+
# ----------------------------------------------------------------------------
40+
41+
s.shell.run(["nox", "-s", "blacken"], hide_output=False)

0 commit comments

Comments
 (0)