diff --git a/packages/grafeas/noxfile.py b/packages/grafeas/noxfile.py index e887520f7c31..4cccb7aab04f 100644 --- a/packages/grafeas/noxfile.py +++ b/packages/grafeas/noxfile.py @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Generated by synthtool. DO NOT EDIT! + from __future__ import absolute_import import os import shutil @@ -21,20 +23,24 @@ import nox -@nox.session(python="3.7") +BLACK_VERSION = "black==19.10b0" +BLACK_PATHS = ["docs", "grafeas", "tests", "noxfile.py", "setup.py"] + +DEFAULT_PYTHON_VERSION = "3.8" +SYSTEM_TEST_PYTHON_VERSIONS = ["2.7", "3.8"] +UNIT_TEST_PYTHON_VERSIONS = ["2.7", "3.5", "3.6", "3.7", "3.8"] + + +@nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.install("flake8", "black") + session.install("flake8", BLACK_VERSION) session.run( - "black", - "--check", - "grafeas", - "tests", - "docs", + "black", "--check", *BLACK_PATHS, ) session.run("flake8", "grafeas", "tests") @@ -44,21 +50,18 @@ def blacken(session): """Run black. Format code to uniform standard. - + This currently uses Python 3.6 due to the automated Kokoro run of synthtool. That run uses an image that doesn't have 3.6 installed. Before updating this check the state of the `gcp_ubuntu_config` we use for that Kokoro run. """ - session.install("black") + session.install(BLACK_VERSION) session.run( - "black", - "grafeas", - "tests", - "docs", + "black", *BLACK_PATHS, ) -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" session.install("docutils", "pygments") @@ -85,13 +88,13 @@ def default(session): ) -@nox.session(python=["2.7", "3.5", "3.6", "3.7"]) +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) def unit(session): """Run the unit test suite.""" default(session) -@nox.session(python=["2.7", "3.7"]) +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" system_test_path = os.path.join("tests", "system.py") @@ -111,7 +114,9 @@ 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( + "mock", "pytest", "google-cloud-testutils", + ) session.install("-e", ".") # Run py.test against the system tests. @@ -121,7 +126,7 @@ def system(session): session.run("py.test", "--quiet", system_test_folder_path, *session.posargs) -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def cover(session): """Run the final coverage report. @@ -129,25 +134,28 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=78") + session.run("coverage", "report", "--show-missing", "--fail-under=76") session.run("coverage", "erase") -@nox.session(python="3.7") + +@nox.session(python=DEFAULT_PYTHON_VERSION) def docs(session): """Build the docs for this library.""" - session.install('-e', '.') - session.install('sphinx<3.0.0', 'alabaster', 'recommonmark') + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") - shutil.rmtree(os.path.join('docs', '_build'), ignore_errors=True) + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( - 'sphinx-build', - '-W', # warnings as errors - '-T', # show full traceback on exception - '-N', # no colors - '-b', 'html', - '-d', os.path.join('docs', '_build', 'doctrees', ''), - os.path.join('docs', ''), - os.path.join('docs', '_build', 'html', ''), + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), ) diff --git a/packages/grafeas/synth.py b/packages/grafeas/synth.py index 106781cebaed..041670a52d95 100644 --- a/packages/grafeas/synth.py +++ b/packages/grafeas/synth.py @@ -357,13 +357,18 @@ def from_service_account_file\(cls, filename, \*args, \*\*kwargs\): # ---------------------------------------------------------------------------- # Add templated files # ---------------------------------------------------------------------------- -templated_files = common.py_library(unit_cov_level=78, cov_level=78) +templated_files = common.py_library(cov_level=76) s.move(templated_files) # TODO(busunkim): Use latest sphinx after microgenerator transition s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') # Library code is in "grafeas" instead of "google" -s.reaplce("noxfile.py", """['"]google['"]""", "grafeas") +s.replace("noxfile.py", """['"]google['"]""", '''"grafeas"''') +s.replace("noxfile.py", + '''"--cov=google.cloud.grafeas", + \s+"--cov=google.cloud",''', + '''"--cov=grafeas",''' +) s.shell.run(["nox", "-s", "blacken"], hide_output=False)