forked from JacobDomagala/StaticAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
47 lines (36 loc) · 1.59 KB
/
entrypoint.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
#!/bin/bash
export TERM=xterm-color
print_to_console=${INPUT_FORCE_CONSOLE_PRINT}
if [ $print_to_console = true ]; then
echo "The 'force_console_print' option is enabled. Printing output to console."
elif [ -z "$INPUT_PR_NUM" ]; then
echo "Pull request number input is not present. Printing output to console."
print_to_console=true
else
echo "Pull request numer is ${INPUT_PR_NUM}"
fi
if [ -n "$INPUT_APT_PCKGS" ]; then
apt-get update && eval apt-get install -y "$INPUT_APT_PCKGS"
fi
if [ -n "$INPUT_INIT_SCRIPT" ]; then
chmod +x "$INPUT_INIT_SCRIPT"
# shellcheck source=/dev/null
source "$INPUT_INIT_SCRIPT"
fi
mkdir build && cd build || exit
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "$INPUT_CMAKE_ARGS" ..
files_to_check=$(python3 /get_files_to_check.py -exclude="$INPUT_EXCLUDE_DIR" -json="compile_commands.json")
echo "== clang-tidy config:"
eval clang-tidy-12 -dump-config
# Excludes for clang-tidy are handled in python script
echo "== Running clang analysis... (clang-tidy \"$INPUT_CLANG_TIDY_ARGS\" -p \"$(pwd)\" \"$files_to_check\")"
eval clang-tidy-12 "$INPUT_CLANG_TIDY_ARGS" -p "$(pwd)" "$files_to_check" -- >"clang_tidy.txt"
echo "== Done."
echo "== Running cppcheck analysis..."
if [ -z "$INPUT_EXCLUDE_DIR" ]; then
eval cppcheck --project=compile_commands.json "$INPUT_CPPCHECK_ARGS" --output-file=cppcheck.txt
else
eval cppcheck --project=compile_commands.json "$INPUT_CPPCHECK_ARGS" --output-file=cppcheck.txt -i"$GITHUB_WORKSPACE/$INPUT_EXCLUDE_DIR"
fi
echo "== Done."
python3 /run_static_analysis.py -cc cppcheck.txt -ct clang_tidy.txt -o $print_to_console