blob: bcea1fbc8cd2ed0da43f1721e16be3059109be6f [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]
32BLACK_VERSION = "black==19.3b0"
33BLACK_PATHS = ["google", "tests", "noxfile.py", "setup.py", "docs/conf.py"]
34
35
36@nox.session(python="3.7")
37def lint(session):
38 session.install("flake8", "flake8-import-order", "docutils", BLACK_VERSION)
39 session.install(".")
40 session.run("black", "--check", *BLACK_PATHS)
41 session.run(
42 "flake8",
43 "--import-order-style=google",
44 "--application-import-names=google,tests,system_tests",
45 "google",
46 "tests",
47 )
48 session.run(
49 "python", "setup.py", "check", "--metadata", "--restructuredtext", "--strict"
50 )
51
52
53@nox.session(python="3.6")
54def blacken(session):
55 """Run black.
56
57 Format code to uniform standard.
58
59 This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
60 That run uses an image that doesn't have 3.6 installed. Before updating this
61 check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
62 """
63 session.install(BLACK_VERSION)
64 session.run("black", *BLACK_PATHS)
65
66
67@nox.session(python=["2.7", "3.5", "3.6", "3.7"])
68def unit(session):
69 session.install(*TEST_DEPENDENCIES)
70 session.install(".")
71 session.run(
72 "pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
73 )
74
75
76@nox.session(python="3.7")
77def cover(session):
78 session.install(*TEST_DEPENDENCIES)
79 session.install(".")
80 session.run(
81 "pytest",
82 "--cov=google.auth",
83 "--cov=google.oauth2",
84 "--cov=tests",
85 "--cov-report=",
86 "tests",
87 )
88 session.run("coverage", "report", "--show-missing", "--fail-under=100")
89
90
91@nox.session(python="3.7")
92def docgen(session):
93 session.env["SPHINX_APIDOC_OPTIONS"] = "members,inherited-members,show-inheritance"
94 session.install(*TEST_DEPENDENCIES)
95 session.install("sphinx")
96 session.install(".")
97 session.run("rm", "-r", "docs/reference")
98 session.run(
99 "sphinx-apidoc",
100 "--output-dir",
101 "docs/reference",
102 "--separate",
103 "--module-first",
104 "google",
105 )
106
107
108@nox.session(python="3.7")
109def docs(session):
110 session.install("sphinx", "-r", "docs/requirements-docs.txt")
111 session.install(".")
112 session.run("make", "-C", "docs", "html")
113
114
115@nox.session(python="pypy")
116def pypy(session):
117 session.install(*TEST_DEPENDENCIES)
118 session.install(".")
119 session.run(
120 "pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
121 )