Skip to content

Commit

Permalink
Add samples lint session
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Nov 24, 2023
1 parent 6006240 commit 61890c3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .kokoro/samples/lint/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ action {
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "lint"
}


# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def authenticate_implicit_with_adc(project_id="your-google-cloud-project-id"):
print(bucket.name)
print("Listed all storage buckets.")

# [END auth_cloud_implicit_adc]
# [END auth_cloud_implicit_adc]
43 changes: 40 additions & 3 deletions samples/cloud-client/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import pathlib
import shutil

import nox

Expand All @@ -33,6 +31,35 @@
"docs/conf.py",
]


# Error if a python version is missing
nox.options.error_on_missing_interpreters = True

#
# Style Checks
#


# Linting with flake8.
#
# We ignore the following rules:
# E203: whitespace before ‘:’
# E266: too many leading ‘#’ for block comment
# E501: line too long
# I202: Additional newline in a section of imports
#
# We also need to specify the rules which are ignored by default:
# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121']
FLAKE8_COMMON_ARGS = [
"--show-source",
"--builtin=gettext",
"--max-complexity=20",
"--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py",
"--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202",
"--max-line-length=88",
]


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
def unit(session):
# constraints_path = str(
Expand All @@ -45,4 +72,14 @@ def unit(session):
f"--junitxml=unit_{session.python}_sponge_log.xml",
"snippets_test.py",
# "tests_async",
)
)


@nox.session
def lint(session: nox.sessions.Session) -> None:
session.install("flake8")

args = FLAKE8_COMMON_ARGS + [
".",
]
session.run("flake8", *args)

0 comments on commit 61890c3

Please sign in to comment.