Skip to content

Commit 37d33fc

Browse files
yoshi-automationbusunkim96daniel-sanche
authored
fix(deps): fix minimum required version of google-api-core (#244)
* chore(python): add kokoro configs for periodic builds against head This change should be non-destructive. Note for library repo maintainers: After applying this change, you can easily add (or change) periodic builds against head by adding config files in google3. See python-pubsub repo for example. Source-Author: Takashi Matsuo <[email protected]> Source-Date: Fri Mar 19 11:17:59 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: 79c8dd7ee768292f933012d3a69a5b4676404cda Source-Link: googleapis/synthtool@79c8dd7 * chore(deps): update precommit hook pycqa/flake8 to v3.9.0 [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pycqa/flake8](https://gitlab.com/pycqa/flake8) | repository | minor | `3.8.4` -> `3.9.0` | --- ### Release Notes <details> <summary>pycqa/flake8</summary> ### [`v3.9.0`](https://gitlab.com/pycqa/flake8/compare/3.8.4...3.9.0) [Compare Source](https://gitlab.com/pycqa/flake8/compare/3.8.4...3.9.0) </details> --- ### Renovate configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/synthtool). Source-Author: WhiteSource Renovate <[email protected]> Source-Date: Tue Mar 23 17:38:03 2021 +0100 Source-Repo: googleapis/synthtool Source-Sha: f5c5904fb0c6aa3b3730eadf4e5a4485afc65726 Source-Link: googleapis/synthtool@f5c5904 * test(python): use constraints files to check dependency lower bounds Use a constraints file when installing dependencies for system and unit tests nox sessions. https://pip.pypa.io/en/stable/user_guide/#constraints-files > Constraints files are requirements files that **only control which version of a requirement is installed, not whether it is installed or not**. Their syntax and contents is nearly identical to Requirements Files. There is one key difference: Including a package in a constraints file does not trigger installation of the package. ``` testing ├── constraints-3.10.txt ├── constraints-3.11.txt ├── constraints-3.6.txt ├── constraints-3.7.txt ├── constraints-3.8.txt └── constraints-3.9.txt ``` Going forward, one constraints file (currently 3.6) will be populated with every library requirement and extra listed in the `setup.py`. The constraints file will pin each requirement to the lower bound. This ensures that library maintainers will see test failures if they forget to update a lower bound on a dependency. See googleapis/python-bigquery#263 for an example Source-Author: Bu Sun Kim <[email protected]> Source-Date: Tue Mar 23 10:52:02 2021 -0600 Source-Repo: googleapis/synthtool Source-Sha: 86ed43d4f56e6404d068e62e497029018879c771 Source-Link: googleapis/synthtool@86ed43d * fix: update minimum version of google-api-core Co-authored-by: Bu Sun Kim <[email protected]> Co-authored-by: Daniel Sanche <[email protected]>
1 parent 79b37c3 commit 37d33fc

11 files changed

+216
-91
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}
7+
8+
env_vars: {
9+
key: "TRAMPOLINE_BUILD_FILE"
10+
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}
7+
8+
env_vars: {
9+
key: "TRAMPOLINE_BUILD_FILE"
10+
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}
7+
8+
env_vars: {
9+
key: "TRAMPOLINE_BUILD_FILE"
10+
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
11+
}

.kokoro/test-samples-against-head.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# A customized test runner for samples.
17+
#
18+
# For periodic builds, you can specify this file for testing against head.
19+
20+
# `-e` enables the script to automatically fail when a command fails
21+
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
22+
set -eo pipefail
23+
# Enables `**` to include files nested inside sub-folders
24+
shopt -s globstar
25+
26+
cd github/python-logging
27+
28+
exec .kokoro/test-samples-impl.sh

.kokoro/test-samples-impl.sh

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
# Copyright 2021 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
17+
# `-e` enables the script to automatically fail when a command fails
18+
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
19+
set -eo pipefail
20+
# Enables `**` to include files nested inside sub-folders
21+
shopt -s globstar
22+
23+
# Exit early if samples directory doesn't exist
24+
if [ ! -d "./samples" ]; then
25+
echo "No tests run. `./samples` not found"
26+
exit 0
27+
fi
28+
29+
# Disable buffering, so that the logs stream through.
30+
export PYTHONUNBUFFERED=1
31+
32+
# Debug: show build environment
33+
env | grep KOKORO
34+
35+
# Install nox
36+
python3.6 -m pip install --upgrade --quiet nox
37+
38+
# Use secrets acessor service account to get secrets
39+
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
40+
gcloud auth activate-service-account \
41+
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
42+
--project="cloud-devrel-kokoro-resources"
43+
fi
44+
45+
# This script will create 3 files:
46+
# - testing/test-env.sh
47+
# - testing/service-account.json
48+
# - testing/client-secrets.json
49+
./scripts/decrypt-secrets.sh
50+
51+
source ./testing/test-env.sh
52+
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json
53+
54+
# For cloud-run session, we activate the service account for gcloud sdk.
55+
gcloud auth activate-service-account \
56+
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"
57+
58+
export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json
59+
60+
echo -e "\n******************** TESTING PROJECTS ********************"
61+
62+
# Switch to 'fail at end' to allow all tests to complete before exiting.
63+
set +e
64+
# Use RTN to return a non-zero value if the test fails.
65+
RTN=0
66+
ROOT=$(pwd)
67+
# Find all requirements.txt in the samples directory (may break on whitespace).
68+
for file in samples/**/requirements.txt; do
69+
cd "$ROOT"
70+
# Navigate to the project folder.
71+
file=$(dirname "$file")
72+
cd "$file"
73+
74+
echo "------------------------------------------------------------"
75+
echo "- testing $file"
76+
echo "------------------------------------------------------------"
77+
78+
# Use nox to execute the tests for the project.
79+
python3.6 -m nox -s "$RUN_TESTS_SESSION"
80+
EXIT=$?
81+
82+
# If this is a periodic build, send the test log to the FlakyBot.
83+
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
84+
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
85+
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
86+
$KOKORO_GFILE_DIR/linux_amd64/flakybot
87+
fi
88+
89+
if [[ $EXIT -ne 0 ]]; then
90+
RTN=1
91+
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
92+
else
93+
echo -e "\n Testing completed.\n"
94+
fi
95+
96+
done
97+
cd "$ROOT"
98+
99+
# Workaround for Kokoro permissions issue: delete secrets
100+
rm testing/{test-env.sh,client-secrets.json,service-account.json}
101+
102+
exit "$RTN"

.kokoro/test-samples.sh

+16-80
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
# The default test runner for samples.
17+
#
18+
# For periodic builds, we rewinds the repo to the latest release, and
19+
# run test-samples-impl.sh.
1620

1721
# `-e` enables the script to automatically fail when a command fails
1822
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
@@ -24,87 +28,19 @@ cd github/python-logging
2428

2529
# Run periodic samples tests at latest release
2630
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
31+
# preserving the test runner implementation.
32+
cp .kokoro/test-samples-impl.sh "${TMPDIR}/test-samples-impl.sh"
33+
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
34+
echo "Now we rewind the repo back to the latest release..."
2735
LATEST_RELEASE=$(git describe --abbrev=0 --tags)
2836
git checkout $LATEST_RELEASE
29-
fi
30-
31-
# Exit early if samples directory doesn't exist
32-
if [ ! -d "./samples" ]; then
33-
echo "No tests run. `./samples` not found"
34-
exit 0
35-
fi
36-
37-
# Disable buffering, so that the logs stream through.
38-
export PYTHONUNBUFFERED=1
39-
40-
# Debug: show build environment
41-
env | grep KOKORO
42-
43-
# Install nox
44-
python3.6 -m pip install --upgrade --quiet nox
45-
46-
# Use secrets acessor service account to get secrets
47-
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
48-
gcloud auth activate-service-account \
49-
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
50-
--project="cloud-devrel-kokoro-resources"
51-
fi
52-
53-
# This script will create 3 files:
54-
# - testing/test-env.sh
55-
# - testing/service-account.json
56-
# - testing/client-secrets.json
57-
./scripts/decrypt-secrets.sh
58-
59-
source ./testing/test-env.sh
60-
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json
61-
62-
# For cloud-run session, we activate the service account for gcloud sdk.
63-
gcloud auth activate-service-account \
64-
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"
65-
66-
export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json
67-
68-
echo -e "\n******************** TESTING PROJECTS ********************"
69-
70-
# Switch to 'fail at end' to allow all tests to complete before exiting.
71-
set +e
72-
# Use RTN to return a non-zero value if the test fails.
73-
RTN=0
74-
ROOT=$(pwd)
75-
# Find all requirements.txt in the samples directory (may break on whitespace).
76-
for file in samples/**/requirements.txt; do
77-
cd "$ROOT"
78-
# Navigate to the project folder.
79-
file=$(dirname "$file")
80-
cd "$file"
81-
82-
echo "------------------------------------------------------------"
83-
echo "- testing $file"
84-
echo "------------------------------------------------------------"
85-
86-
# Use nox to execute the tests for the project.
87-
python3.6 -m nox -s "$RUN_TESTS_SESSION"
88-
EXIT=$?
89-
90-
# If this is a periodic build, send the test log to the FlakyBot.
91-
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
92-
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
93-
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
94-
$KOKORO_GFILE_DIR/linux_amd64/flakybot
37+
echo "The current head is: "
38+
echo $(git rev-parse --verify HEAD)
39+
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
40+
# move back the test runner implementation if there's no file.
41+
if [ ! -f .kokoro/test-samples-impl.sh ]; then
42+
cp "${TMPDIR}/test-samples-impl.sh" .kokoro/test-samples-impl.sh
9543
fi
44+
fi
9645

97-
if [[ $EXIT -ne 0 ]]; then
98-
RTN=1
99-
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
100-
else
101-
echo -e "\n Testing completed.\n"
102-
fi
103-
104-
done
105-
cd "$ROOT"
106-
107-
# Workaround for Kokoro permissions issue: delete secrets
108-
rm testing/{test-env.sh,client-secrets.json,service-account.json}
109-
110-
exit "$RTN"
46+
exec .kokoro/test-samples-impl.sh

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ repos:
1212
hooks:
1313
- id: black
1414
- repo: https://gitlab.com/pycqa/flake8
15-
rev: 3.8.4
15+
rev: 3.9.0
1616
hooks:
1717
- id: flake8

noxfile.py

+25-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from __future__ import absolute_import
2020
import os
21+
import pathlib
2122
import shutil
2223

2324
import nox
@@ -30,6 +31,8 @@
3031
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
3132
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
3233

34+
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
35+
3336
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
3437
nox.options.sessions = [
3538
"unit",
@@ -84,11 +87,24 @@ def lint_setup_py(session):
8487

8588
def default(session):
8689
# Install all test dependencies, then install this package in-place.
87-
session.install("asyncmock", "pytest-asyncio")
8890

89-
session.install("mock", "pytest", "pytest-cov", "flask", "webob", "django")
91+
constraints_path = str(
92+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
93+
)
94+
session.install("asyncmock", "pytest-asyncio", "-c", constraints_path)
9095

91-
session.install("-e", ".")
96+
session.install(
97+
"mock",
98+
"pytest",
99+
"pytest-cov",
100+
"flask",
101+
"webob",
102+
"django",
103+
"-c",
104+
constraints_path,
105+
)
106+
107+
session.install("-e", ".", "-c", constraints_path)
92108

93109
# Run py.test against the unit tests.
94110
session.run(
@@ -115,6 +131,9 @@ def unit(session):
115131
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
116132
def system(session):
117133
"""Run the system test suite."""
134+
constraints_path = str(
135+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
136+
)
118137
system_test_path = os.path.join("tests", "system.py")
119138
system_test_folder_path = os.path.join("tests", "system")
120139

@@ -147,8 +166,10 @@ def system(session):
147166
"google-cloud-pubsub",
148167
"google-cloud-storage",
149168
"google-cloud-testutils",
169+
"-c",
170+
constraints_path,
150171
)
151-
session.install("-e", ".")
172+
session.install("-e", ".", "-c", constraints_path)
152173

153174
# Run py.test against the system tests.
154175
if system_test_exists:

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# 'Development Status :: 5 - Production/Stable'
3030
release_status = "Development Status :: 5 - Production/Stable"
3131
dependencies = [
32-
"google-api-core[grpc] >= 1.22.0, < 2.0.0dev",
32+
"google-api-core[grpc] >= 1.22.2, < 2.0.0dev",
3333
"google-cloud-core >= 1.4.1, < 2.0dev",
3434
"proto-plus >= 1.11.0",
3535
]

0 commit comments

Comments
 (0)