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