Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: creates linting-typing.cfg in presubmit #1881

Merged
merged 17 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .kokoro/presubmit/linting-typing.cfg
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Only run these nox sessions.
env_vars: {
key: "NOX_SESSION"
value: "lint lint_setup_py blacken mypy mypy_samples pytype"
}
chalmerlowe marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions .kokoro/presubmit/presubmit.cfg
Expand Up @@ -9,3 +9,7 @@ env_vars: {
key: "RUN_SNIPPETS_TESTS"
value: "false"
}
env_vars: {
key: "RUN_LINTING_TYPING_TESTS"
value: "false"
chalmerlowe marked this conversation as resolved.
Show resolved Hide resolved
}
24 changes: 24 additions & 0 deletions noxfile.py
Expand Up @@ -132,6 +132,10 @@ def unit_noextras(session):
def mypy(session):
"""Run type checks with mypy."""

# Check the value of `RUN_LINTING_TYPING_TESTS` env var. It defaults to true.
if os.environ.get("RUN_LINTING_TYPING_TESTS", "true") == "false":
session.skip("RUN_LINTING_TYPING_TESTS is set to false, skipping")

session.install("-e", ".[all]")
session.install(MYPY_VERSION)

Expand All @@ -153,6 +157,10 @@ def pytype(session):
# recent version avoids the error until a possibly better fix is found.
# https://github.com/googleapis/python-bigquery/issues/655

# Check the value of `RUN_LINTING_TYPING_TESTS` env var. It defaults to true.
if os.environ.get("RUN_LINTING_TYPING_TESTS", "true") == "false":
session.skip("RUN_LINTING_TYPING_TESTS is set to false, skipping")

session.install("attrs==20.3.0")
session.install("-e", ".[all]")
session.install(PYTYPE_VERSION)
Expand Down Expand Up @@ -213,6 +221,10 @@ def system(session):
def mypy_samples(session):
"""Run type checks with mypy."""

# Check the value of `RUN_LINTING_TYPING_TESTS` env var. It defaults to true.
if os.environ.get("RUN_LINTING_TYPING_TESTS", "true") == "false":
session.skip("RUN_LINTING_TYPING_TESTS is set to false, skipping")

session.install("pytest")
for requirements_path in CURRENT_DIRECTORY.glob("samples/*/requirements.txt"):
session.install("-r", str(requirements_path))
Expand Down Expand Up @@ -394,6 +406,10 @@ def lint(session):
serious code quality issues.
"""

# Check the value of `RUN_LINTING_TYPING_TESTS` env var. It defaults to true.
if os.environ.get("RUN_LINTING_TYPING_TESTS", "true") == "false":
session.skip("RUN_LINTING_TYPING_TESTS is set to false, skipping")

session.install("flake8", BLACK_VERSION)
session.install("-e", ".")
session.run("flake8", os.path.join("google", "cloud", "bigquery"))
Expand All @@ -408,6 +424,10 @@ def lint(session):
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""

# Check the value of `RUN_LINTING_TYPING_TESTS` env var. It defaults to true.
if os.environ.get("RUN_LINTING_TYPING_TESTS", "true") == "false":
session.skip("RUN_LINTING_TYPING_TESTS is set to false, skipping")

session.install("docutils", "Pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")

Expand All @@ -418,6 +438,10 @@ def blacken(session):
Format code to uniform standard.
"""

# Check the value of `RUN_LINTING_TYPING_TESTS` env var. It defaults to true.
if os.environ.get("RUN_LINTING_TYPING_TESTS", "true") == "false":
session.skip("RUN_LINTING_TYPING_TESTS is set to false, skipping")

session.install(BLACK_VERSION)
session.run("black", *BLACK_PATHS)

Expand Down