blob: 388814491b741ed107ab8ce742725d41838237ac [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
Tres Seaver05f95242020-10-26 20:52:11 -040033ASYNC_DEPENDENCIES = [
34 "pytest-asyncio",
35 "aiohttp < 3.7.0dev",
36 "aioresponses",
37 "asynctest",
38]
Christopher Wilcox7e152582020-09-28 15:27:20 -070039
Bu Sun Kim65e33c02019-10-25 10:45:00 -070040BLACK_VERSION = "black==19.3b0"
Christopher Wilcox7e152582020-09-28 15:27:20 -070041BLACK_PATHS = [
42 "google",
43 "tests",
44 "tests_async",
45 "noxfile.py",
46 "setup.py",
47 "docs/conf.py",
48]
Bu Sun Kim65e33c02019-10-25 10:45:00 -070049
50
51@nox.session(python="3.7")
52def lint(session):
53 session.install("flake8", "flake8-import-order", "docutils", BLACK_VERSION)
54 session.install(".")
55 session.run("black", "--check", *BLACK_PATHS)
56 session.run(
57 "flake8",
58 "--import-order-style=google",
59 "--application-import-names=google,tests,system_tests",
60 "google",
61 "tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -070062 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -070063 )
64 session.run(
65 "python", "setup.py", "check", "--metadata", "--restructuredtext", "--strict"
66 )
67
68
69@nox.session(python="3.6")
70def blacken(session):
71 """Run black.
72
73 Format code to uniform standard.
74
75 This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
76 That run uses an image that doesn't have 3.6 installed. Before updating this
77 check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
78 """
79 session.install(BLACK_VERSION)
80 session.run("black", *BLACK_PATHS)
81
82
Christopher Wilcox7e152582020-09-28 15:27:20 -070083@nox.session(python=["3.6", "3.7", "3.8"])
Bu Sun Kim65e33c02019-10-25 10:45:00 -070084def unit(session):
85 session.install(*TEST_DEPENDENCIES)
Christopher Wilcox7e152582020-09-28 15:27:20 -070086 session.install(*(ASYNC_DEPENDENCIES))
87 session.install(".")
88 session.run(
89 "pytest",
90 "--cov=google.auth",
91 "--cov=google.oauth2",
92 "--cov=tests",
93 "tests",
94 "tests_async",
95 )
96
97
98@nox.session(python=["2.7", "3.5"])
99def unit_prev_versions(session):
100 session.install(*TEST_DEPENDENCIES)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700101 session.install(".")
102 session.run(
103 "pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
104 )
105
106
107@nox.session(python="3.7")
108def cover(session):
109 session.install(*TEST_DEPENDENCIES)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700110 session.install(*(ASYNC_DEPENDENCIES))
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700111 session.install(".")
112 session.run(
113 "pytest",
114 "--cov=google.auth",
115 "--cov=google.oauth2",
116 "--cov=tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -0700117 "--cov=tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700118 "--cov-report=",
119 "tests",
Christopher Wilcox7e152582020-09-28 15:27:20 -0700120 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700121 )
122 session.run("coverage", "report", "--show-missing", "--fail-under=100")
123
124
125@nox.session(python="3.7")
126def docgen(session):
127 session.env["SPHINX_APIDOC_OPTIONS"] = "members,inherited-members,show-inheritance"
128 session.install(*TEST_DEPENDENCIES)
129 session.install("sphinx")
130 session.install(".")
131 session.run("rm", "-r", "docs/reference")
132 session.run(
133 "sphinx-apidoc",
134 "--output-dir",
135 "docs/reference",
136 "--separate",
137 "--module-first",
138 "google",
139 )
140
141
142@nox.session(python="3.7")
143def docs(session):
144 session.install("sphinx", "-r", "docs/requirements-docs.txt")
145 session.install(".")
146 session.run("make", "-C", "docs", "html")
147
148
149@nox.session(python="pypy")
150def pypy(session):
151 session.install(*TEST_DEPENDENCIES)
Tres Seaver3b3172e2020-10-22 16:05:20 -0400152 session.install(*ASYNC_DEPENDENCIES)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700153 session.install(".")
154 session.run(
Christopher Wilcox7e152582020-09-28 15:27:20 -0700155 "pytest",
156 "--cov=google.auth",
157 "--cov=google.oauth2",
158 "--cov=tests",
159 "tests",
160 "tests_async",
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700161 )