1414import nox
1515
1616
17- supported_pythons = ["3.7" , "3.8" ]
18- system_test_pythons = ["3.7" , "3.8" ]
19- latest_python = "3.8"
17+ BLACK_VERSION = "black==19.10b0"
18+ BLACK_PATHS = ["docs" , "pandas_gbq" , "tests" , "noxfile.py" , "setup.py" ]
2019
21- # Use a consistent version of black so CI is deterministic.
22- # Should match Stickler: https://stickler-ci.com/docs#black
23- black_package = "black==20.8b1"
20+ DEFAULT_PYTHON_VERSION = "3.8"
21+ SYSTEM_TEST_PYTHON_VERSIONS = [ "3.8" ]
22+ UNIT_TEST_PYTHON_VERSIONS = [ "3.7" , "3.8" , "3.9" ]
2423
2524
26- @nox .session (python = latest_python )
25+ # Error if a python version is missing
26+ nox .options .error_on_missing_interpreters = True
27+
28+
29+ @nox .session (python = DEFAULT_PYTHON_VERSION )
2730def lint (session ):
28- session .install (black_package , "flake8" )
29- session .run ("flake8" , "pandas_gbq" )
30- session .run ("flake8" , "tests" )
31- session .run ("black" , "--check" , "." )
31+ """Run linters.
32+ Returns a failure if the linters find linting errors or sufficiently
33+ serious code quality issues.
34+ """
35+ session .install ("flake8" , BLACK_VERSION )
36+ session .run (
37+ "black" , "--check" , * BLACK_PATHS ,
38+ )
39+ session .run ("flake8" , "pandas_gbq" , "tests" )
3240
3341
34- @nox .session (python = latest_python )
42+ @nox .session (python = DEFAULT_PYTHON_VERSION )
3543def blacken (session ):
36- session .install (black_package )
37- session .run ("black" , "." )
44+ """Run black. Format code to uniform standard."""
45+ session .install (BLACK_VERSION )
46+ session .run (
47+ "black" , * BLACK_PATHS ,
48+ )
49+
3850
51+ @nox .session (python = DEFAULT_PYTHON_VERSION )
52+ def lint_setup_py (session ):
53+ """Verify that setup.py is valid (including RST check)."""
54+ session .install ("docutils" , "pygments" )
55+ session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
3956
40- @nox .session (python = supported_pythons )
57+
58+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
4159def unit (session ):
4260 session .install ("pytest" , "pytest-cov" )
4361 session .install (
@@ -56,18 +74,23 @@ def unit(session):
5674 "--cov=tests.unit" ,
5775 "--cov-report" ,
5876 "xml:/tmp/pytest-cov.xml" ,
59- * session .posargs
77+ * session .posargs ,
6078 )
6179
6280
63- @nox .session (python = latest_python )
81+ @nox .session (python = DEFAULT_PYTHON_VERSION )
6482def cover (session ):
83+ """Run the final coverage report.
84+ This outputs the coverage report aggregating coverage from the unit
85+ test runs (not system test runs), and then erases coverage data.
86+ """
6587 session .install ("coverage" , "pytest-cov" )
6688 session .run ("coverage" , "report" , "--show-missing" , "--fail-under=73" )
89+
6790 session .run ("coverage" , "erase" )
6891
6992
70- @nox .session (python = latest_python )
93+ @nox .session (python = DEFAULT_PYTHON_VERSION )
7194def docs (session ):
7295 """Build the docs."""
7396
@@ -89,7 +112,7 @@ def docs(session):
89112 )
90113
91114
92- @nox .session (python = system_test_pythons )
115+ @nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
93116def system (session ):
94117 session .install ("pytest" , "pytest-cov" )
95118 session .install (
@@ -111,5 +134,5 @@ def system(session):
111134 os .path .join ("." , "tests" , "system" ),
112135 os .path .join ("." , "samples" , "tests" ),
113136 "-v" ,
114- * additional_args
137+ * additional_args ,
115138 )
0 commit comments