Skip to content

Commit d966512

Browse files
chore(python): update dependencies in /.kokoro (#266)
Source-Link: googleapis/synthtool@db94845 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:a8a80fc6456e433df53fc2a0d72ca0345db0ddefb409f1b75b118dfd1babd952 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 74cc2df commit d966512

File tree

8 files changed

+391
-72
lines changed

8 files changed

+391
-72
lines changed

packages/google-cloud-dns/.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:98f3afd11308259de6e828e37376d18867fd321aba07826e29e4f8d9cab56bad
17-
# created: 2024-02-27T15:56:18.442440378Z
16+
digest: sha256:a8a80fc6456e433df53fc2a0d72ca0345db0ddefb409f1b75b118dfd1babd952
17+
# created: 2024-03-15T16:25:47.905264637Z

packages/google-cloud-dns/.kokoro/build.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
3333
# Setup project id.
3434
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")
3535

36-
# Remove old nox
37-
python3 -m pip uninstall --yes --quiet nox-automation
38-
39-
# Install nox
40-
python3 -m pip install --upgrade --quiet nox
41-
python3 -m nox --version
42-
4336
# If this is a continuous build, send the test log to the FlakyBot.
4437
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
4538
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then

packages/google-cloud-dns/.kokoro/docker/docs/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
8080
# Test pip
8181
RUN python3 -m pip
8282

83+
# Install build requirements
84+
COPY requirements.txt /requirements.txt
85+
RUN python3 -m pip install --require-hashes -r requirements.txt
86+
8387
CMD ["python3.8"]
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
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+
from __future__ import print_function
16+
17+
import glob
18+
import os
19+
from pathlib import Path
20+
import sys
21+
from typing import Callable, Dict, Optional
22+
23+
import nox
24+
25+
26+
# WARNING - WARNING - WARNING - WARNING - WARNING
27+
# WARNING - WARNING - WARNING - WARNING - WARNING
28+
# DO NOT EDIT THIS FILE EVER!
29+
# WARNING - WARNING - WARNING - WARNING - WARNING
30+
# WARNING - WARNING - WARNING - WARNING - WARNING
31+
32+
BLACK_VERSION = "black==22.3.0"
33+
ISORT_VERSION = "isort==5.10.1"
34+
35+
# Copy `noxfile_config.py` to your directory and modify it instead.
36+
37+
# `TEST_CONFIG` dict is a configuration hook that allows users to
38+
# modify the test configurations. The values here should be in sync
39+
# with `noxfile_config.py`. Users will copy `noxfile_config.py` into
40+
# their directory and modify it.
41+
42+
TEST_CONFIG = {
43+
# You can opt out from the test for specific Python versions.
44+
"ignored_versions": [],
45+
# Old samples are opted out of enforcing Python type hints
46+
# All new samples should feature them
47+
"enforce_type_hints": False,
48+
# An envvar key for determining the project id to use. Change it
49+
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
50+
# build specific Cloud project. You can also use your own string
51+
# to use your own Cloud project.
52+
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
53+
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
54+
# If you need to use a specific version of pip,
55+
# change pip_version_override to the string representation
56+
# of the version number, for example, "20.2.4"
57+
"pip_version_override": None,
58+
# A dictionary you want to inject into your test. Don't put any
59+
# secrets here. These values will override predefined values.
60+
"envs": {},
61+
}
62+
63+
64+
try:
65+
# Ensure we can import noxfile_config in the project's directory.
66+
sys.path.append(".")
67+
from noxfile_config import TEST_CONFIG_OVERRIDE
68+
except ImportError as e:
69+
print("No user noxfile_config found: detail: {}".format(e))
70+
TEST_CONFIG_OVERRIDE = {}
71+
72+
# Update the TEST_CONFIG with the user supplied values.
73+
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
74+
75+
76+
def get_pytest_env_vars() -> Dict[str, str]:
77+
"""Returns a dict for pytest invocation."""
78+
ret = {}
79+
80+
# Override the GCLOUD_PROJECT and the alias.
81+
env_key = TEST_CONFIG["gcloud_project_env"]
82+
# This should error out if not set.
83+
ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]
84+
85+
# Apply user supplied envs.
86+
ret.update(TEST_CONFIG["envs"])
87+
return ret
88+
89+
90+
# DO NOT EDIT - automatically generated.
91+
# All versions used to test samples.
92+
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
93+
94+
# Any default versions that should be ignored.
95+
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
96+
97+
TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])
98+
99+
INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in (
100+
"True",
101+
"true",
102+
)
103+
104+
# Error if a python version is missing
105+
nox.options.error_on_missing_interpreters = True
106+
107+
#
108+
# Style Checks
109+
#
110+
111+
112+
# Linting with flake8.
113+
#
114+
# We ignore the following rules:
115+
# E203: whitespace before ‘:’
116+
# E266: too many leading ‘#’ for block comment
117+
# E501: line too long
118+
# I202: Additional newline in a section of imports
119+
#
120+
# We also need to specify the rules which are ignored by default:
121+
# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121']
122+
FLAKE8_COMMON_ARGS = [
123+
"--show-source",
124+
"--builtin=gettext",
125+
"--max-complexity=20",
126+
"--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py",
127+
"--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202",
128+
"--max-line-length=88",
129+
]
130+
131+
132+
@nox.session
133+
def lint(session: nox.sessions.Session) -> None:
134+
if not TEST_CONFIG["enforce_type_hints"]:
135+
session.install("flake8")
136+
else:
137+
session.install("flake8", "flake8-annotations")
138+
139+
args = FLAKE8_COMMON_ARGS + [
140+
".",
141+
]
142+
session.run("flake8", *args)
143+
144+
145+
#
146+
# Black
147+
#
148+
149+
150+
@nox.session
151+
def blacken(session: nox.sessions.Session) -> None:
152+
"""Run black. Format code to uniform standard."""
153+
session.install(BLACK_VERSION)
154+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
155+
156+
session.run("black", *python_files)
157+
158+
159+
#
160+
# format = isort + black
161+
#
162+
163+
@nox.session
164+
def format(session: nox.sessions.Session) -> None:
165+
"""
166+
Run isort to sort imports. Then run black
167+
to format code to uniform standard.
168+
"""
169+
session.install(BLACK_VERSION, ISORT_VERSION)
170+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
171+
172+
# Use the --fss option to sort imports using strict alphabetical order.
173+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
174+
session.run("isort", "--fss", *python_files)
175+
session.run("black", *python_files)
176+
177+
178+
#
179+
# Sample Tests
180+
#
181+
182+
183+
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
184+
185+
186+
def _session_tests(
187+
session: nox.sessions.Session, post_install: Callable = None
188+
) -> None:
189+
# check for presence of tests
190+
test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob("**/test_*.py", recursive=True)
191+
test_list.extend(glob.glob("**/tests", recursive=True))
192+
193+
if len(test_list) == 0:
194+
print("No tests found, skipping directory.")
195+
return
196+
197+
if TEST_CONFIG["pip_version_override"]:
198+
pip_version = TEST_CONFIG["pip_version_override"]
199+
session.install(f"pip=={pip_version}")
200+
"""Runs py.test for a particular project."""
201+
concurrent_args = []
202+
if os.path.exists("requirements.txt"):
203+
if os.path.exists("constraints.txt"):
204+
session.install("-r", "requirements.txt", "-c", "constraints.txt")
205+
else:
206+
session.install("-r", "requirements.txt")
207+
with open("requirements.txt") as rfile:
208+
packages = rfile.read()
209+
210+
if os.path.exists("requirements-test.txt"):
211+
if os.path.exists("constraints-test.txt"):
212+
session.install(
213+
"-r", "requirements-test.txt", "-c", "constraints-test.txt"
214+
)
215+
else:
216+
session.install("-r", "requirements-test.txt")
217+
with open("requirements-test.txt") as rtfile:
218+
packages += rtfile.read()
219+
220+
if INSTALL_LIBRARY_FROM_SOURCE:
221+
session.install("-e", _get_repo_root())
222+
223+
if post_install:
224+
post_install(session)
225+
226+
if "pytest-parallel" in packages:
227+
concurrent_args.extend(['--workers', 'auto', '--tests-per-worker', 'auto'])
228+
elif "pytest-xdist" in packages:
229+
concurrent_args.extend(['-n', 'auto'])
230+
231+
session.run(
232+
"pytest",
233+
*(PYTEST_COMMON_ARGS + session.posargs + concurrent_args),
234+
# Pytest will return 5 when no tests are collected. This can happen
235+
# on travis where slow and flaky tests are excluded.
236+
# See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
237+
success_codes=[0, 5],
238+
env=get_pytest_env_vars(),
239+
)
240+
241+
242+
@nox.session(python=ALL_VERSIONS)
243+
def py(session: nox.sessions.Session) -> None:
244+
"""Runs py.test for a sample using the specified version of Python."""
245+
if session.python in TESTED_VERSIONS:
246+
_session_tests(session)
247+
else:
248+
session.skip(
249+
"SKIPPED: {} tests are disabled for this sample.".format(session.python)
250+
)
251+
252+
253+
#
254+
# Readmegen
255+
#
256+
257+
258+
def _get_repo_root() -> Optional[str]:
259+
""" Returns the root folder of the project. """
260+
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
261+
p = Path(os.getcwd())
262+
for i in range(10):
263+
if p is None:
264+
break
265+
if Path(p / ".git").exists():
266+
return str(p)
267+
# .git is not available in repos cloned via Cloud Build
268+
# setup.py is always in the library's root, so use that instead
269+
# https://github.com/googleapis/synthtool/issues/792
270+
if Path(p / "setup.py").exists():
271+
return str(p)
272+
p = p.parent
273+
raise Exception("Unable to detect repository root.")
274+
275+
276+
GENERATED_READMES = sorted([x for x in Path(".").rglob("*.rst.in")])
277+
278+
279+
@nox.session
280+
@nox.parametrize("path", GENERATED_READMES)
281+
def readmegen(session: nox.sessions.Session, path: str) -> None:
282+
"""(Re-)generates the readme for a sample."""
283+
session.install("jinja2", "pyyaml")
284+
dir_ = os.path.dirname(path)
285+
286+
if os.path.exists(os.path.join(dir_, "requirements.txt")):
287+
session.install("-r", os.path.join(dir_, "requirements.txt"))
288+
289+
in_file = os.path.join(dir_, "README.rst.in")
290+
session.run(
291+
"python", _get_repo_root() + "/scripts/readme-gen/readme_gen.py", in_file
292+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nox
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.9
3+
# by the following command:
4+
#
5+
# pip-compile --allow-unsafe --generate-hashes requirements.in
6+
#
7+
argcomplete==3.2.3 \
8+
--hash=sha256:bf7900329262e481be5a15f56f19736b376df6f82ed27576fa893652c5de6c23 \
9+
--hash=sha256:c12355e0494c76a2a7b73e3a59b09024ca0ba1e279fb9ed6c1b82d5b74b6a70c
10+
# via nox
11+
colorlog==6.8.2 \
12+
--hash=sha256:3e3e079a41feb5a1b64f978b5ea4f46040a94f11f0e8bbb8261e3dbbeca64d44 \
13+
--hash=sha256:4dcbb62368e2800cb3c5abd348da7e53f6c362dda502ec27c560b2e58a66bd33
14+
# via nox
15+
distlib==0.3.8 \
16+
--hash=sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784 \
17+
--hash=sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64
18+
# via virtualenv
19+
filelock==3.13.1 \
20+
--hash=sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e \
21+
--hash=sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c
22+
# via virtualenv
23+
nox==2024.3.2 \
24+
--hash=sha256:e53514173ac0b98dd47585096a55572fe504fecede58ced708979184d05440be \
25+
--hash=sha256:f521ae08a15adbf5e11f16cb34e8d0e6ea521e0b92868f684e91677deb974553
26+
# via -r requirements.in
27+
packaging==24.0 \
28+
--hash=sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5 \
29+
--hash=sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9
30+
# via nox
31+
platformdirs==4.2.0 \
32+
--hash=sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068 \
33+
--hash=sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768
34+
# via virtualenv
35+
virtualenv==20.25.1 \
36+
--hash=sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a \
37+
--hash=sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197
38+
# via nox
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gcp-docuploader
2-
gcp-releasetool>=1.10.5 # required for compatibility with cryptography>=39.x
2+
gcp-releasetool>=2 # required for compatibility with cryptography>=42.x
33
importlib-metadata
44
typing-extensions
55
twine
@@ -8,3 +8,4 @@ setuptools
88
nox>=2022.11.21 # required to remove dependency on py
99
charset-normalizer<3
1010
click<8.1.0
11+
cryptography>=42.0.5

0 commit comments

Comments
 (0)