[Add]tools for continuous integration
This commit is contained in:
parent
2e6f2b6793
commit
684f049fca
28
tools/ci/format_check.py
Normal file
28
tools/ci/format_check.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
|
from yapf.yapflib.yapf_api import FormatFile
|
||||||
|
|
||||||
|
logger = logging.Logger(__file__)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
has_changed = False
|
||||||
|
for root, dir, filenames in os.walk("vnpy"):
|
||||||
|
for filename in filenames:
|
||||||
|
basename, ext = os.path.splitext(filename)
|
||||||
|
if ext == ".py":
|
||||||
|
path = os.path.join(root, filename)
|
||||||
|
reformatted_code, encoding, changed = FormatFile(
|
||||||
|
filename=path,
|
||||||
|
style_config=".style.yapf",
|
||||||
|
print_diff=True,
|
||||||
|
verify=False,
|
||||||
|
in_place=False,
|
||||||
|
logger=None,
|
||||||
|
)
|
||||||
|
if changed:
|
||||||
|
has_changed = True
|
||||||
|
logger.warning("File {} not formatted!".format(path))
|
||||||
|
else:
|
||||||
|
logger.info("File {} is formatted!".format(path))
|
||||||
|
exit(has_changed)
|
0
tools/ci/requirements.txt
Normal file
0
tools/ci/requirements.txt
Normal file
Loading…
Reference in New Issue
Block a user