-
Notifications
You must be signed in to change notification settings - Fork 9
/
ci_tests
executable file
·62 lines (47 loc) · 1.54 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
59
60
61
62
#!/usr/bin/env python3
"""Run everything that needs to pass for CI to be green.
This is executed by GitHub actions against Python 3.7 - 3.12 on both Windows and Ubuntu.
PYTHON_ARGCOMPLETE_OK
"""
import os
from pathlib import Path
from shutil import rmtree
from subprocess import CalledProcessError, DEVNULL, run
from milc import cli
cli.milc_options(name='ci_tests', author='MILC', version='1.9.0')
@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, stdin=DEVNULL)
if result.returncode != 0:
build_ok = False
cli.log.info('Running flake8...')
cmd = ['flake8']
result = run(cmd, stdin=DEVNULL)
if result.returncode != 0:
build_ok = False
cli.log.info('Running yapf...')
cmd = ['yapf', '-q', '-r', '--exclude', 'venv/**', '--exclude', '.venv/**', '.']
result = run(cmd, stdin=DEVNULL)
if result.returncode != 0:
build_ok = False
cli.log.error('Improperly formatted code. Please run this: yapf -i -r .')
cli.log.info('Running mypy...')
cmd = ['mypy', '--strict', 'milc']
result = run(cmd, stdin=DEVNULL)
if result.returncode != 0:
build_ok = False
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)