Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 95b7b62

Browse files
yoshi-automationtswastbusunkim96
authored
test(python): use constraints files to check dependency lower bounds (#56)
* changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * 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: add version range for grpc-google-iam-v1 * chore: exclude tarfile Co-authored-by: Tim Swast <[email protected]> Co-authored-by: Bu Sun Kim <[email protected]>
1 parent c0bf925 commit 95b7b62

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

.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

+14-8
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,13 +87,15 @@ 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(
90-
"mock", "pytest", "pytest-cov",
91+
constraints_path = str(
92+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
9193
)
94+
session.install("asyncmock", "pytest-asyncio", "-c", constraints_path)
9295

93-
session.install("-e", ".")
96+
session.install("mock", "pytest", "pytest-cov", "-c", constraints_path)
97+
98+
session.install("-e", ".", "-c", constraints_path)
9499

95100
# Run py.test against the unit tests.
96101
session.run(
@@ -117,6 +122,9 @@ def unit(session):
117122
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
118123
def system(session):
119124
"""Run the system test suite."""
125+
constraints_path = str(
126+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
127+
)
120128
system_test_path = os.path.join("tests", "system.py")
121129
system_test_folder_path = os.path.join("tests", "system")
122130

@@ -141,10 +149,8 @@ def system(session):
141149

142150
# Install all test dependencies, then install this package into the
143151
# virtualenv's dist-packages.
144-
session.install(
145-
"mock", "pytest", "google-cloud-testutils",
146-
)
147-
session.install("-e", ".")
152+
session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path)
153+
session.install("-e", ".", "-c", constraints_path)
148154

149155
# Run py.test against the system tests.
150156
if system_test_exists:

setup.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@
4040
platforms="Posix; MacOS X; Windows",
4141
include_package_data=True,
4242
install_requires=(
43-
"google-api-core >= 1.21.0, < 2.0.0dev",
43+
"google-api-core >= 1.22.2, < 2.0.0dev",
4444
"proto-plus >= 1.4.0",
45-
"grpc-google-iam-v1",
46-
"libcst >= 0.2.5",
45+
"grpc-google-iam-v1 >= 0.12.3, < 0.13.0dev",
4746
),
4847
python_requires=">=3.6",
49-
scripts=["scripts/fixup_keywords.py"],
5048
classifiers=[
5149
"Development Status :: 4 - Beta",
5250
"Intended Audience :: Developers",

synth.metadata

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
"git": {
2020
"name": "synthtool",
2121
"remote": "https://github.com/googleapis/synthtool.git",
22-
"sha": "79c8dd7ee768292f933012d3a69a5b4676404cda"
22+
"sha": "86ed43d4f56e6404d068e62e497029018879c771"
2323
}
2424
},
2525
{
2626
"git": {
2727
"name": "synthtool",
2828
"remote": "https://github.com/googleapis/synthtool.git",
29-
"sha": "79c8dd7ee768292f933012d3a69a5b4676404cda"
29+
"sha": "86ed43d4f56e6404d068e62e497029018879c771"
3030
}
3131
}
3232
],
@@ -98,6 +98,7 @@
9898
"CONTRIBUTING.rst",
9999
"LICENSE",
100100
"MANIFEST.in",
101+
"bigquery-connection-v1-py.tar.gz",
101102
"docs/_static/custom.css",
102103
"docs/_templates/layout.html",
103104
"docs/bigquery_connection_v1/connection_service.rst",

synth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
bazel_target=f"//google/cloud/bigquery/connection/v1:bigquery-connection-v1-py"
3232
)
3333

34-
s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"])
34+
s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst", "*.tar.gz"])
3535

3636
# ----------------------------------------------------------------------------
3737
# Add templated files

testing/constraints-3.6.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#
66
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
77
# Then this file should have foo==1.14.0
8-
google-api-core==1.21.0
8+
google-api-core==1.22.2
99
proto-plus==1.4.0
10-
grpc-google-iam-v1==0.9.0
11-
libcst==0.2.5
10+
grpc-google-iam-v1==0.12.3

0 commit comments

Comments
 (0)