1515import fnmatch
1616import os
1717
18+ import nox
19+
1820
1921def _list_files (folder , pattern ):
2022 """Lists all files below the given folder that match the pattern."""
@@ -24,7 +26,8 @@ def _list_files(folder, pattern):
2426 yield os .path .join (root , filename )
2527
2628
27- def session_check_requirements (session ):
29+ @nox .session
30+ def check_requirements (session ):
2831 """Checks for out of date requirements and optionally updates them."""
2932 session .install ('gcp-devrel-py-tools' )
3033
@@ -37,3 +40,44 @@ def session_check_requirements(session):
3740
3841 for reqfile in reqfiles :
3942 session .run ('gcp-devrel-py-tools' , command , reqfile )
43+
44+
45+ @nox .session
46+ def lint (session ):
47+ session .install ('flake8' , 'flake8-import-order' )
48+ session .run (
49+ 'flake8' ,
50+ '--import-order-style=google' ,
51+ 'scripts' ,
52+ 'nox.py' ,
53+ )
54+
55+
56+ @nox .session
57+ @nox .parametrize ('version' , ['3.4' , '3.5' , '3.6' ])
58+ def tests (session , version ):
59+ session .interpreter = 'python' + version
60+ session .install ('-r' , 'scripts/requirements-test.txt' )
61+ session .run (
62+ 'py.test' ,
63+ '--ignore=scripts/testdata' ,
64+ '--cov=scripts' ,
65+ '--cov-append' ,
66+ '--cov-config=.coveragerc' ,
67+ '--cov-report=' , # Report generated below
68+ 'scripts' ,
69+ env = {'PYTHONPATH' : '' }
70+ )
71+
72+
73+ @nox .session
74+ def cover (session ):
75+ """Run the final coverage report.
76+
77+ This outputs the coverage report aggregating coverage from the unit
78+ test runs (not system test runs), and then erases coverage data.
79+ """
80+ session .interpreter = 'python3.6'
81+ session .install ('coverage' , 'pytest-cov' )
82+ session .run ('coverage' , 'report' , '--show-missing' , '--fail-under=97' )
83+ session .run ('coverage' , 'erase' )
0 commit comments