-
Notifications
You must be signed in to change notification settings - Fork 14
/
dev_setup.py
53 lines (41 loc) · 1.25 KB
/
dev_setup.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Create a pre-commit hook for this repo,
which runs code linters and formatters automatically before commits"""
import os
import stat
def main():
"""Generate the content of the pre-commit file, and create the file"""
content = """\
#!/bin/sh
set -e
echo "-------------------------------"
echo "Reset GCP values in config files"
echo "-------------------------------"
cd configuration
python3 gcp_update.py --reset
cd ..
echo "-------------------------------"
echo "Black"
echo "-------------------------------"
black --line-length 100 ./
echo "-------------------------------"
echo "Pylint"
echo "-------------------------------"
for i in $(find ./ -type f -name "*.py"); do
pylint --rcfile=./sysconfig/pylintrc $i
done
echo "-------------------------------"
echo "Yamllint"
echo "-------------------------------"
yamllint --strict -c ./sysconfig/yamllint.yml ./
echo "-------------------------------"
echo "Ansible-lint"
echo "-------------------------------"
ansible-lint --profile production --strict"""
target = ".git/hooks/pre-commit"
with open(target, mode="w", encoding="utf-8") as f:
f.write(content)
f.close()
st = os.stat(target)
os.chmod(target, st.st_mode | stat.S_IEXEC)
if __name__ == "__main__":
main()