Skip to content

Commit

Permalink
chore: fix typo in synth.py (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
busunkim96 authored Jul 1, 2020
1 parent 97fb5e2 commit 1e7577b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 33 deletions.
70 changes: 39 additions & 31 deletions packages/grafeas/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,33 @@
# 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

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")

Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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.
Expand All @@ -121,33 +126,36 @@ 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.
This outputs the coverage report aggregating coverage from the unit
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", ""),
)
9 changes: 7 additions & 2 deletions packages/grafeas/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 1e7577b

Please sign in to comment.