From c84fdcd8f0797d97f9214fab06da124078dda09d Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Wed, 7 Sep 2022 15:57:41 +1000 Subject: [PATCH] Add quiet option to script --- .github/workflows/misra.yml | 3 ++- misra/check_misra.sh | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/misra.yml b/.github/workflows/misra.yml index 6549c32b..1deac12c 100644 --- a/.github/workflows/misra.yml +++ b/.github/workflows/misra.yml @@ -30,8 +30,9 @@ jobs: cd $GITHUB_WORKSPACE/misra/ mkdir .results chmod +x check_misra.sh - ./check_misra.sh -c /usr/bin -o ./.results + ./check_misra.sh -c /usr/bin -o ./.results -q echo "Scan complete" + echo $NumViolations echo "VIOLATIONS=$NumViolations" >> $GITHUB_ENV - name: Save output to Gist diff --git a/misra/check_misra.sh b/misra/check_misra.sh index 65facb8d..42850b98 100755 --- a/misra/check_misra.sh +++ b/misra/check_misra.sh @@ -7,6 +7,7 @@ source_folder="$script_folder/../speeduino" # -s, --source file_exts="ino" # -e, --exts out_folder="$script_folder/.results" # -o, --out cppcheck_path="" # -c, --cppcheck +quiet=0 # -q, --quiet function parse_command_line() { while [ $# -gt 0 ] ; do @@ -15,6 +16,7 @@ function parse_command_line() { -e | --exts) file_exts="$2" ;; -o | --out) out_folder="$2" ;; -c | --cppcheck) cppcheck_path="$2" ;; + -q | --quiet) quiet=1 ;; -*) echo "Unknown option: " $1 exit 1 @@ -70,7 +72,9 @@ rm -f "$result_file" run_cppcheck error_count="$(process_cpp_results)" -cat "$result_file" +if [ $quiet -eq 0 ]; then + cat "$result_file" +fi echo $error_count MISRA violations echo $error_count > ".results/error_count.txt"