blob: fa88d24b2695f7de1a8bb90f20f114e29a8cb016 [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.
Bu Sun Kim65e33c02019-10-25 10:45:00 -070067 Format code to uniform standard.
Bu Sun Kim65e33c02019-10-25 10:45:00 -070068 This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
69 That run uses an image that doesn't have 3.6 installed. Before updating this
70 check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
71 """
72 session.install(BLACK_VERSION)
73 session.run("black", *BLACK_PATHS)
74
75
Tres Seaver6de753d2020-12-11 13:20:39 -050076@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
Bu Sun Kim65e33c02019-10-25 10:45:00 -070077def unit(session):
78 session.install(*TEST_DEPENDENCIES)
Christopher Wilcox7e152582020-09-28 15:27:20 -070079 session.install(*(ASYNC_DEPENDENCIES))
80 session.install(".")
81 session.run(
82 "pytest",
83 "--cov=google.auth",
84 "--cov=google.oauth2",
85 "--cov=tests",
86 "tests",
87 "tests_async",
88 )
89
90
Tres Seaver6de753d2020-12-11 13:20:39 -050091@nox.session(python=["2.7"])
Christopher Wilcox7e152582020-09-28 15:27:20 -070092def unit_prev_versions(session):
93 session.install(*TEST_DEPENDENCIES)
Bu Sun Kim65e33c02019-10-25 10:45:00 -070094 session.install(".")
95 session.run(
96 "pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
97 )
98
99
100@nox.session(python="3.7")
101def cover(session):
102 session.install(*TEST_DEPENDENCIES)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700103 session.install(*(ASYNC_DEPENDENCIES))
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700104 session.install(".")
105 session.run(
106 "pytest",
107 "--cov=google.auth",
108 "--cov=google.oauth2",
109 "--cov=tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -0700110 "--cov=tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700111 "--cov-report=",
112 "tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -0700113 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700114 )
115 session.run("coverage", "report", "--show-missing", "--fail-under=100")
116
117
118@nox.session(python="3.7")
119def docgen(session):
120 session.env["SPHINX_APIDOC_OPTIONS"] = "members,inherited-members,show-inheritance"
121 session.install(*TEST_DEPENDENCIES)
122 session.install("sphinx")
123 session.install(".")
124 session.run("rm", "-r", "docs/reference")
125 session.run(
126 "sphinx-apidoc",
127 "--output-dir",
128 "docs/reference",
129 "--separate",
130 "--module-first",
131 "google",
132 )
133
134
135@nox.session(python="3.7")
136def docs(session):
137 session.install("sphinx", "-r", "docs/requirements-docs.txt")
138 session.install(".")
139 session.run("make", "-C", "docs", "html")
140
141
142@nox.session(python="pypy")
143def pypy(session):
144 session.install(*TEST_DEPENDENCIES)
Tres Seaver3b3172e2020-10-22 16:05:20 -0400145 session.install(*ASYNC_DEPENDENCIES)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700146 session.install(".")
147 session.run(
Christopher Wilcox7e152582020-09-28 15:27:20 -0700148 "pytest",
149 "--cov=google.auth",
150 "--cov=google.oauth2",
151 "--cov=tests",
152 "tests",
153 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700154 )