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