From 7197a001ffb6d8ce7b0b9b11c280f0c536c1033a Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 5 Jan 2023 15:56:31 -0500 Subject: [PATCH] feat(python): add support for python 3.11 (#1742) * feat: add support for python 3.11 * add kokoro configs for python 3.11 --- synthtool/gcp/common.py | 2 +- .../.kokoro/samples/python3.11/common.cfg | 51 +++++++++++++++++++ .../.kokoro/samples/python3.11/continuous.cfg | 6 +++ .../samples/python3.11/periodic-head.cfg | 18 +++++++ .../.kokoro/samples/python3.11/periodic.cfg | 13 +++++ .../.kokoro/samples/python3.11/presubmit.cfg | 6 +++ .../templates/python_samples/noxfile.py.j2 | 2 +- synthtool/languages/python_mono_repo.py | 2 +- 8 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/common.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/continuous.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic-head.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/presubmit.cfg diff --git a/synthtool/gcp/common.py b/synthtool/gcp/common.py index 8d1d77629..b7a5a59b2 100644 --- a/synthtool/gcp/common.py +++ b/synthtool/gcp/common.py @@ -265,7 +265,7 @@ def py_library(self, **kwargs) -> Path: if "default_python_version" not in kwargs: kwargs["default_python_version"] = "3.8" if "unit_test_python_versions" not in kwargs: - kwargs["unit_test_python_versions"] = ["3.7", "3.8", "3.9", "3.10"] + kwargs["unit_test_python_versions"] = ["3.7", "3.8", "3.9", "3.10", "3.11"] if "system_test_python_versions" not in kwargs: kwargs["system_test_python_versions"] = ["3.8"] diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/common.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/common.cfg new file mode 100644 index 000000000..49eaf8117 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/common.cfg @@ -0,0 +1,51 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Specify which tests to run +env_vars: { + key: "RUN_TESTS_SESSION" + value: "py-3.11" +} + +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-311" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/test-samples.sh" +} +{% if custom_samples_dockerfile %} +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/{{ metadata['repo']['repo'].split('/')[1] }}-samples-docker" +} + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_DOCKERFILE" + value: ".kokoro/docker/samples/Dockerfile" +} +{% else %} +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker" +} +{% endif %} +# Download secrets for samples +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/continuous.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/continuous.cfg new file mode 100644 index 000000000..a1c8d9759 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/continuous.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic-head.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic-head.cfg new file mode 100644 index 000000000..da31f1cdf --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic-head.cfg @@ -0,0 +1,18 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/test-samples-against-head.sh" +} +{% if custom_samples_dockerfile %} +# Upload the docker image after successful builds. +env_vars: { + key: "TRAMPOLINE_IMAGE_UPLOAD" + value: "true" +} +{% endif %} \ No newline at end of file diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic.cfg new file mode 100644 index 000000000..f7ea9d9b9 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/periodic.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "False" +} +{% if custom_samples_dockerfile %} +# Upload the docker image after successful builds. +env_vars: { + key: "TRAMPOLINE_IMAGE_UPLOAD" + value: "true" +} +{% endif %} \ No newline at end of file diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/presubmit.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/presubmit.cfg new file mode 100644 index 000000000..a1c8d9759 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.11/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/synthtool/gcp/templates/python_samples/noxfile.py.j2 b/synthtool/gcp/templates/python_samples/noxfile.py.j2 index f5c32b227..7c8a63994 100644 --- a/synthtool/gcp/templates/python_samples/noxfile.py.j2 +++ b/synthtool/gcp/templates/python_samples/noxfile.py.j2 @@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] +ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] diff --git a/synthtool/languages/python_mono_repo.py b/synthtool/languages/python_mono_repo.py index 61f2aa4c4..bca47ccfd 100644 --- a/synthtool/languages/python_mono_repo.py +++ b/synthtool/languages/python_mono_repo.py @@ -195,7 +195,7 @@ def owlbot_main(package_dir: str) -> None: relative_dir=f"packages/{Path(package_dir).name}", microgenerator=True, default_python_version="3.9", - unit_test_python_versions=["3.7", "3.8", "3.9", "3.10"], + unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11"], cov_level=100, versions=gcp.common.detect_versions( path=f"{package_dir}/google", default_first=True