From 31dec1ff272774e4e6522b327d7324540a8cbfa4 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 2 Apr 2021 16:50:49 -0700 Subject: [PATCH] Test: update constraints files and use precommit hook (#81) * chore(deps): update precommit hook pycqa/flake8 to v3.9.0 * test(python): use constraints files to check dependency lower bounds --- .../.pre-commit-config.yaml | 2 +- packages/google-cloud-container/noxfile.py | 22 ++++++++++++------- .../google-cloud-container/synth.metadata | 2 +- .../testing/constraints-3.6.txt | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/google-cloud-container/.pre-commit-config.yaml b/packages/google-cloud-container/.pre-commit-config.yaml index a9024b15d725..32302e4883a1 100644 --- a/packages/google-cloud-container/.pre-commit-config.yaml +++ b/packages/google-cloud-container/.pre-commit-config.yaml @@ -12,6 +12,6 @@ repos: hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + rev: 3.9.0 hooks: - id: flake8 diff --git a/packages/google-cloud-container/noxfile.py b/packages/google-cloud-container/noxfile.py index 9fafb0c28f60..2efbe2b5ff38 100644 --- a/packages/google-cloud-container/noxfile.py +++ b/packages/google-cloud-container/noxfile.py @@ -18,6 +18,7 @@ from __future__ import absolute_import import os +import pathlib import shutil import nox @@ -30,6 +31,8 @@ SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ "unit", @@ -84,13 +87,15 @@ def lint_setup_py(session): def default(session): # Install all test dependencies, then install this package in-place. - session.install("asyncmock", "pytest-asyncio") - session.install( - "mock", "pytest", "pytest-cov", + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) + session.install("asyncmock", "pytest-asyncio", "-c", constraints_path) - session.install("-e", ".") + session.install("mock", "pytest", "pytest-cov", "-c", constraints_path) + + session.install("-e", ".", "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -117,6 +122,9 @@ def unit(session): @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) system_test_path = os.path.join("tests", "system.py") system_test_folder_path = os.path.join("tests", "system") @@ -141,10 +149,8 @@ def system(session): # Install all test dependencies, then install this package into the # virtualenv's dist-packages. - session.install( - "mock", "pytest", "google-cloud-testutils", - ) - session.install("-e", ".") + session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) + session.install("-e", ".", "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/packages/google-cloud-container/synth.metadata b/packages/google-cloud-container/synth.metadata index 8b5c788a6855..3082d2db019d 100644 --- a/packages/google-cloud-container/synth.metadata +++ b/packages/google-cloud-container/synth.metadata @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "79c8dd7ee768292f933012d3a69a5b4676404cda" + "sha": "86ed43d4f56e6404d068e62e497029018879c771" } } ], diff --git a/packages/google-cloud-container/testing/constraints-3.6.txt b/packages/google-cloud-container/testing/constraints-3.6.txt index af597f7a6501..399fa9e88e71 100644 --- a/packages/google-cloud-container/testing/constraints-3.6.txt +++ b/packages/google-cloud-container/testing/constraints-3.6.txt @@ -5,7 +5,7 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.21.2 +google-api-core==1.26.3 grpc-google-iam-v1==0.12.3 proto-plus==1.4.0 libcst==0.2.5 \ No newline at end of file