forked from clueboard/milc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_tests
executable file
·53 lines (39 loc) · 1.25 KB
/
ci_tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""Run everything that needs to pass for CI to be green.
This is executed by GitHub actions against Python 3.5, 3.6, 3.7, and 3.8 on both Windows and Ubuntu.
PYTHON_ARGCOMPLETE_OK
"""
import os
from pathlib import Path
from shutil import rmtree
from subprocess import CalledProcessError, run
os.environ['MILC_APP_NAME'] = 'ci_tests'
os.environ['MILC_APP_AUTHOR'] = 'MILC'
from milc import cli
@cli.entrypoint('Run CI Tests...')
def main(cli):
build_ok = True
if Path('build').exists():
rmtree('build')
cli.log.info('Running flake8...')
cmd = ['flake8']
result = run(cmd)
if result.returncode != 0:
build_ok = False
cli.log.info('Running yapf...')
cmd = ['yapf', '-q', '-r', '.']
result = run(cmd)
if result.returncode != 0:
build_ok = False
cli.log.error('Improperly formatted code. Please run this: yapf -i -r .')
cli.log.info('Running nose2 tests...')
cmd = ['nose2']
result = run(cmd)
if result.returncode != 0:
build_ok = False
cli.log.error('Tests are not passing! Please fix them before opening a PR.')
if build_ok:
cli.log.info('{fg_green}All tests passed!')
return build_ok
if __name__ == '__main__':
cli()