forked from umrover/mrover-ros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle.sh
executable file
·52 lines (42 loc) · 1.41 KB
/
style.sh
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
#!/usr/bin/env bash
# Print each command, fail on unset variables
set -xu
# Style check C++ with clang-format
clang_format_executable=clang-format-12
clang_format_executable_path=$(which "$clang_format_executable")
if [ ! -x "$clang_format_executable_path" ]; then
echo "[Error] Please install clang-format with: sudo apt install $clang_format_executable"
exit 1
fi
echo "Style checking C++ ..."
find . -regex '.*\.\(cpp\|hpp\|h\)' -exec "$clang_format_executable_path" --dry-run -style=file -i {} \;
echo "Done"
# Style check Python with black
black_executable=black
black_executable_path=$(which "$black_executable")
if [ ! -x "$black_executable_path" ]; then
echo "[Error] Please run pip3 install -r requirements.txt"
exit 1
fi
if ! black --version | grep -q 'black, 22.8.0'; then
echo "[Error] Wrong black version"
exit 1
fi
# TODO: don't hardcode settings!
echo "Style checking Python with black ..."
"$black_executable_path" --check --diff --line-length=120 src scripts
echo "Done"
# Style check Python with mypy
mypy_executable=mypy
mypy_executable_path=$(which "$mypy_executable")
if [ ! -x "$mypy_executable_path" ]; then
echo "[Error] Please run pip3 install -r requirements.txt"
exit 1
fi
if ! mypy --version | grep -q 'mypy 0.971'; then
echo "[Error] Wrong mypy version"
exit 1
fi
echo "Style checking Python with mypy ..."
"$mypy_executable_path" --config-file mypy.ini --check src scripts
echo "Done"