blob: b92f4939deb8ee5a86ac7f9db88288539b796e36 [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",
Peter Lamutd86d7b82019-12-12 01:33:45 +010019 "freezegun",
Bu Sun Kim65e33c02019-10-25 10:45:00 -070020 "mock",
21 "oauth2client",
arithmetic1728bb9215a2020-03-20 09:49:44 -070022 "pyopenssl",
Bu Sun Kim65e33c02019-10-25 10:45:00 -070023 "pytest",
24 "pytest-cov",
25 "pytest-localserver",
26 "requests",
27 "urllib3",
28 "cryptography",
Brent Shafferbc0ec932020-02-13 14:11:34 -080029 "responses",
Bu Sun Kim65e33c02019-10-25 10:45:00 -070030 "grpcio",
31]
Christopher Wilcox7e152582020-09-28 15:27:20 -070032
David Buxtonb790e652020-10-29 21:38:01 +000033ASYNC_DEPENDENCIES = ["pytest-asyncio", "aioresponses", "asynctest"]
Christopher Wilcox7e152582020-09-28 15:27:20 -070034
Bu Sun Kim65e33c02019-10-25 10:45:00 -070035BLACK_VERSION = "black==19.3b0"
Christopher Wilcox7e152582020-09-28 15:27:20 -070036BLACK_PATHS = [
37 "google",
38 "tests",
39 "tests_async",
40 "noxfile.py",
41 "setup.py",
42 "docs/conf.py",
43]
Bu Sun Kim65e33c02019-10-25 10:45:00 -070044
45
46@nox.session(python="3.7")
47def lint(session):
48 session.install("flake8", "flake8-import-order", "docutils", BLACK_VERSION)
49 session.install(".")
50 session.run("black", "--check", *BLACK_PATHS)
51 session.run(
52 "flake8",
53 "--import-order-style=google",
54 "--application-import-names=google,tests,system_tests",
55 "google",
56 "tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -070057 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -070058 )
59 session.run(
60 "python", "setup.py", "check", "--metadata", "--restructuredtext", "--strict"
61 )
62
63
64@nox.session(python="3.6")
65def blacken(session):
66 """Run black.
67
68 Format code to uniform standard.
69
70 This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
71 That run uses an image that doesn't have 3.6 installed. Before updating this
72 check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
73 """
74 session.install(BLACK_VERSION)
75 session.run("black", *BLACK_PATHS)
76
77
Christopher Wilcox7e152582020-09-28 15:27:20 -070078@nox.session(python=["3.6", "3.7", "3.8"])
Bu Sun Kim65e33c02019-10-25 10:45:00 -070079def unit(session):
80 session.install(*TEST_DEPENDENCIES)
Christopher Wilcox7e152582020-09-28 15:27:20 -070081 session.install(*(ASYNC_DEPENDENCIES))
82 session.install(".")
83 session.run(
84 "pytest",
85 "--cov=google.auth",
86 "--cov=google.oauth2",
87 "--cov=tests",
88 "tests",
89 "tests_async",
90 )
91
92
93@nox.session(python=["2.7", "3.5"])
94def unit_prev_versions(session):
95 session.install(*TEST_DEPENDENCIES)
Bu Sun Kim65e33c02019-10-25 10:45:00 -070096 session.install(".")
97 session.run(
98 "pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
99 )
100
101
102@nox.session(python="3.7")
103def cover(session):
104 session.install(*TEST_DEPENDENCIES)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700105 session.install(*(ASYNC_DEPENDENCIES))
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700106 session.install(".")
107 session.run(
108 "pytest",
109 "--cov=google.auth",
110 "--cov=google.oauth2",
111 "--cov=tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -0700112 "--cov=tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700113 "--cov-report=",
114 "tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -0700115 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700116 )
117 session.run("coverage", "report", "--show-missing", "--fail-under=100")
118
119
120@nox.session(python="3.7")
121def docgen(session):
122 session.env["SPHINX_APIDOC_OPTIONS"] = "members,inherited-members,show-inheritance"
123 session.install(*TEST_DEPENDENCIES)
124 session.install("sphinx")
125 session.install(".")
126 session.run("rm", "-r", "docs/reference")
127 session.run(
128 "sphinx-apidoc",
129 "--output-dir",
130 "docs/reference",
131 "--separate",
132 "--module-first",
133 "google",
134 )
135
136
137@nox.session(python="3.7")
138def docs(session):
139 session.install("sphinx", "-r", "docs/requirements-docs.txt")
140 session.install(".")
141 session.run("make", "-C", "docs", "html")
142
143
144@nox.session(python="pypy")
145def pypy(session):
146 session.install(*TEST_DEPENDENCIES)
Tres Seaver3b3172e2020-10-22 16:05:20 -0400147 session.install(*ASYNC_DEPENDENCIES)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700148 session.install(".")
149 session.run(
Christopher Wilcox7e152582020-09-28 15:27:20 -0700150 "pytest",
151 "--cov=google.auth",
152 "--cov=google.oauth2",
153 "--cov=tests",
154 "tests",
155 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700156 )