blob: aaf1bc57da31754c7314a8a4a1b45414448f9332 [file] [log] [blame]
Bu Sun Kim65e33c02019-10-25 10:45:00 -07001# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import nox
16
17TEST_DEPENDENCIES = [
18 "flask",
19 "mock",
20 "oauth2client",
21 "pytest",
22 "pytest-cov",
23 "pytest-localserver",
24 "requests",
25 "urllib3",
26 "cryptography",
27 "grpcio",
28]
29BLACK_VERSION = "black==19.3b0"
30BLACK_PATHS = ["google", "tests", "noxfile.py", "setup.py", "docs/conf.py"]
31
32
33@nox.session(python="3.7")
34def lint(session):
35 session.install("flake8", "flake8-import-order", "docutils", BLACK_VERSION)
36 session.install(".")
37 session.run("black", "--check", *BLACK_PATHS)
38 session.run(
39 "flake8",
40 "--import-order-style=google",
41 "--application-import-names=google,tests,system_tests",
42 "google",
43 "tests",
44 )
45 session.run(
46 "python", "setup.py", "check", "--metadata", "--restructuredtext", "--strict"
47 )
48
49
50@nox.session(python="3.6")
51def blacken(session):
52 """Run black.
53
54 Format code to uniform standard.
55
56 This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
57 That run uses an image that doesn't have 3.6 installed. Before updating this
58 check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
59 """
60 session.install(BLACK_VERSION)
61 session.run("black", *BLACK_PATHS)
62
63
64@nox.session(python=["2.7", "3.5", "3.6", "3.7"])
65def unit(session):
66 session.install(*TEST_DEPENDENCIES)
67 session.install(".")
68 session.run(
69 "pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
70 )
71
72
73@nox.session(python="3.7")
74def cover(session):
75 session.install(*TEST_DEPENDENCIES)
76 session.install(".")
77 session.run(
78 "pytest",
79 "--cov=google.auth",
80 "--cov=google.oauth2",
81 "--cov=tests",
82 "--cov-report=",
83 "tests",
84 )
85 session.run("coverage", "report", "--show-missing", "--fail-under=100")
86
87
88@nox.session(python="3.7")
89def docgen(session):
90 session.env["SPHINX_APIDOC_OPTIONS"] = "members,inherited-members,show-inheritance"
91 session.install(*TEST_DEPENDENCIES)
92 session.install("sphinx")
93 session.install(".")
94 session.run("rm", "-r", "docs/reference")
95 session.run(
96 "sphinx-apidoc",
97 "--output-dir",
98 "docs/reference",
99 "--separate",
100 "--module-first",
101 "google",
102 )
103
104
105@nox.session(python="3.7")
106def docs(session):
107 session.install("sphinx", "-r", "docs/requirements-docs.txt")
108 session.install(".")
109 session.run("make", "-C", "docs", "html")
110
111
112@nox.session(python="pypy")
113def pypy(session):
114 session.install(*TEST_DEPENDENCIES)
115 session.install(".")
116 session.run(
117 "pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
118 )