-
Notifications
You must be signed in to change notification settings - Fork 1
/
presubmit.py
38 lines (28 loc) · 897 Bytes
/
presubmit.py
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
#!/usr/bin/env python3
import pytest
import subprocess
import sys
def check_for_modifications(message):
run = subprocess.run(["git", "ls-files", "-m"], stdout=subprocess.PIPE)
if len(run.stdout) > 0:
print("\n" + message)
sys.exit(1)
if __name__ == "__main__":
check_for_modifications(
"There are local modifications. Please stage them.")
subprocess.run(
[
sys.executable, "-m", "yapf", "--recursive", "--in-place",
"--parallel", "-vv", "."
],
check=True)
check_for_modifications("Python formatter made modifications.")
JS_FILES = ["game/game.js"]
subprocess.run(
["prettier", "--write", "--loglevel", "log"] + JS_FILES,
check=True,
shell=True)
check_for_modifications("Javascript formatter made modifications.")
subprocess.run(["eslint"] + JS_FILES, check=True, shell=True)
pytest.main(["-v"])
print("\nPresubmit OK")