2121import nox
2222
2323
24+ DEFAULT_PYTHON_VERSION = "3.8"
25+ SYSTEM_TEST_PYTHON_VERSIONS = ["2.7" , "3.8" ]
26+ UNIT_TEST_PYTHON_VERSIONS = ["2.7" , "3.5" , "3.6" , "3.7" , "3.8" ]
2427LOCAL_DEPS = ()
2528
26- @nox .session (python = "3.7" )
29+ @nox .session (python = DEFAULT_PYTHON_VERSION )
2730def lint (session ):
2831 """Run linters.
2932
@@ -56,7 +59,7 @@ def blacken(session):
5659 )
5760
5861
59- @nox .session (python = "3.7" )
62+ @nox .session (python = DEFAULT_PYTHON_VERSION )
6063def lint_setup_py (session ):
6164 """Verify that setup.py is valid (including RST check)."""
6265 session .install ("docutils" , "pygments" )
@@ -85,13 +88,26 @@ def default(session):
8588 )
8689
8790
88- @nox .session (python = [ "2.7" , "3.5" , "3.6" , "3.7" ] )
91+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
8992def unit (session ):
9093 """Run the unit test suite."""
9194 default (session )
9295
9396
94- @nox .session (python = ["2.7" , "3.7" ])
97+ @nox .session (python = DEFAULT_PYTHON_VERSION )
98+ def cover (session ):
99+ """Run the final coverage report.
100+
101+ This outputs the coverage report aggregating coverage from the unit
102+ test runs (not system test runs), and then erases coverage data.
103+ """
104+ session .install ("coverage" , "pytest-cov" )
105+ session .run ("coverage" , "report" , "--show-missing" , "--fail-under=99" )
106+
107+ session .run ("coverage" , "erase" )
108+
109+
110+ @nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
95111def system (session ):
96112 """Run the system test suite."""
97113 system_test_path = os .path .join ("tests" , "system.py" )
@@ -124,19 +140,35 @@ def system(session):
124140 session .run ("py.test" , "--quiet" , system_test_folder_path , * session .posargs )
125141
126142
127- @nox .session (python = "3.7" )
128- def cover (session ):
129- """Run the final coverage report.
143+ @nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
144+ def snippets (session ):
145+ """Run the documentation example snippets."""
146+ # Sanity check: Only run snippets system tests if the environment variable
147+ # is set.
148+ if not os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" , "" ):
149+ session .skip ("Credentials must be set via environment variable." )
130150
131- This outputs the coverage report aggregating coverage from the unit
132- test runs (not system test runs), and then erases coverage data.
133- """
134- session .install ("coverage" , "pytest-cov" )
135- session .run ("coverage" , "report" , "--show-missing" , "--fail-under=99" )
151+ # Install all test dependencies, then install local packages in place.
152+ session .install ("mock" , "pytest" )
153+ for local_dep in LOCAL_DEPS :
154+ session .install ("-e" , local_dep )
155+ session .install ("-e" , "test_utils/" )
156+ session .install ("-e" , "." )
157+ session .run (
158+ "py.test" ,
159+ "--quiet" ,
160+ os .path .join ("docs" , "snippets.py" ),
161+ * session .posargs
162+ )
163+ session .run (
164+ "py.test" ,
165+ "--quiet" ,
166+ os .path .join ("docs" , "snippets_table.py" ),
167+ * session .posargs
168+ )
136169
137- session .run ("coverage" , "erase" )
138170
139- @nox .session (python = "3.7" )
171+ @nox .session (python = DEFAULT_PYTHON_VERSION )
140172def docs (session ):
141173 """Build the docs for this library."""
142174
@@ -157,29 +189,34 @@ def docs(session):
157189 os .path .join ("docs" , "_build" , "html" , "" ),
158190 )
159191
160- @nox .session (python = ['2.7' , '3.7' ])
161- def snippets (session ):
162- """Run the documentation example snippets."""
163- # Sanity check: Only run snippets system tests if the environment variable
164- # is set.
165- if not os .environ .get ('GOOGLE_APPLICATION_CREDENTIALS' , '' ):
166- session .skip ('Credentials must be set via environment variable.' )
192+ @nox .session (python = DEFAULT_PYTHON_VERSION )
193+ def docfx (session ):
194+ """Build the docfx yaml files for this library."""
167195
168- # Install all test dependencies, then install local packages in place.
169- session .install ('mock' , 'pytest' )
170- for local_dep in LOCAL_DEPS :
171- session .install ('-e' , local_dep )
172- session .install ('-e' , 'test_utils/' )
173- session .install ('-e' , '.' )
174- session .run (
175- 'py.test' ,
176- '--quiet' ,
177- os .path .join ('docs' , 'snippets.py' ),
178- * session .posargs
179- )
196+ session .install ("-e" , "." )
197+ session .install ("sphinx" , "alabaster" , "recommonmark" , "sphinx-docfx-yaml" )
198+
199+ shutil .rmtree (os .path .join ("docs" , "_build" ), ignore_errors = True )
180200 session .run (
181- 'py.test' ,
182- '--quiet' ,
183- os .path .join ('docs' , 'snippets_table.py' ),
184- * session .posargs
201+ "sphinx-build" ,
202+ "-T" , # show full traceback on exception
203+ "-N" , # no colors
204+ "-D" ,
205+ (
206+ "extensions=sphinx.ext.autodoc,"
207+ "sphinx.ext.autosummary,"
208+ "docfx_yaml.extension,"
209+ "sphinx.ext.intersphinx,"
210+ "sphinx.ext.coverage,"
211+ "sphinx.ext.napoleon,"
212+ "sphinx.ext.todo,"
213+ "sphinx.ext.viewcode,"
214+ "recommonmark"
215+ ),
216+ "-b" ,
217+ "html" ,
218+ "-d" ,
219+ os .path .join ("docs" , "_build" , "doctrees" , "" ),
220+ os .path .join ("docs" , "" ),
221+ os .path .join ("docs" , "_build" , "html" , "" ),
185222 )
0 commit comments