forked from clueboard/milc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_tests
executable file
·58 lines (43 loc) · 1.32 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
54
55
56
57
58
#!/usr/bin/env python3
"""Run everything that needs to pass for CI to be green.
This is executed by GitHub actions against Python 3.6, 3.7, 3.8, and 3.9 on both Windows and Ubuntu.
PYTHON_ARGCOMPLETE_OK
"""
import os
from pathlib import Path
from shutil import rmtree
from subprocess import CalledProcessError, run
from milc import set_metadata
set_metadata(name='ci_tests', author='MILC', version='1.3.0')
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 nose2 tests...')
cmd = ['nose2']
result = run(cmd)
if result.returncode != 0:
build_ok = False
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 .')
if build_ok:
cli.log.info('{fg_green}All tests passed!')
return True
cli.log.error('Tests are not passing! Please fix them before opening a PR.')
return False
if __name__ == '__main__':
if cli():
exit(0)
else:
exit(1)