forked from microsoft/CCF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-checks.sh
executable file
·62 lines (48 loc) · 1.54 KB
/
ci-checks.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
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
set -e
if [ "$1" == "-f" ]; then
FIX=1
else
FIX=0
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "Shell scripts"
find . -type f -regex ".*\.sh$" | grep -E -v "^./3rdparty/" | xargs shellcheck -s bash -e SC2044,SC2002,SC1091,SC2181
echo "TODOs"
"$SCRIPT_DIR"/check-todo.sh src
echo "C/C++ format"
if [ $FIX -ne 0 ]; then
"$SCRIPT_DIR"/check-format.sh -f src samples
else
"$SCRIPT_DIR"/check-format.sh src samples
fi
echo "Copyright notice headers"
python3.8 "$SCRIPT_DIR"/notice-check.py
echo "CMake format"
if [ $FIX -ne 0 ]; then
"$SCRIPT_DIR"/check-cmake-format.sh -f cmake samples src tests CMakeLists.txt
else
"$SCRIPT_DIR"/check-cmake-format.sh cmake samples src tests CMakeLists.txt
fi
# Virtual Environment w/ dependencies for Python steps
if [ ! -f "scripts/env/bin/activate" ]
then
python3.8 -m venv scripts/env
fi
source scripts/env/bin/activate
pip --disable-pip-version-check install -U black pylint mypy 1>/dev/null
echo "Python format"
if [ $FIX -ne 0 ]; then
black python/ tests/ scripts/*.py
else
black --check python/ tests/ scripts/*.py
fi
# Install test dependencies before linting
pip --disable-pip-version-check install -U -r tests/requirements.txt 1>/dev/null
pip --disable-pip-version-check install -U -r python/requirements.txt 1>/dev/null
echo "Python lint"
find tests/ python/ -type f -name "*.py" -exec python -m pylint {} +
echo "Python types"
mypy python/