File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed
Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1515 steps :
1616 - uses : actions/checkout@v2
1717 - name : apt
18- run : sudo apt-get install g++ cmake lcov libboost-all-dev
18+ run : sudo apt-get install g++ cmake lcov libboost-all-dev clang-format
1919 - name : submodule
2020 run : git submodule update --init --recursive
21+ - name : lint
22+ run : bash linter.sh
2123 - name : test
2224 run : ./build.sh -t
Original file line number Diff line number Diff line change 99 packages : clang-format colordiff lcov libboost-all-dev
1010
1111script :
12+ - bash linter.sh
1213 - ./build.sh -t
1314 - ./build.sh -c
1415
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ COLOR_REST=' \e[0m' ;
3+ COLOR_BLUE=' \e[1;34m' ;
4+
5+ DIFF_EXE=" "
6+ CLANG_FORMATTER=" "
7+ AUTO_FIX=" false"
8+
9+ if [ " ${1} " == ' -i' ]; then
10+ AUTO_FIX=" true"
11+ fi
12+
13+ if command -v colordiff > /dev/null; then
14+ DIFF_EXE=$( command -v colordiff)
15+ elif command -v diff > /dev/null; then
16+ DIFF_EXE=$( command -v diff)
17+ fi
18+
19+ if command -v clang-format > /dev/null; then
20+ CLANG_FORMATTER=$( command -v clang-format)
21+ else
22+ echo -e " Missing clang-format, please install it with: \n ${COLOR_BLUE} sudo apt-get install clang-format${COLOR_REST} "
23+ exit 1
24+ fi
25+
26+ file_list=$( find ini test \( -name ' *.h' -or -name ' *.cpp' \) )
27+ return_code=0
28+ for f in ${file_list} ; do
29+ checker_cmd=" ${DIFF_EXE} -u <(cat ${f} ) <(${CLANG_FORMATTER} ${f} -style=file)"
30+ if ! diff=$( bash -c " ${checker_cmd} " ) ; then
31+ echo -e " >>>>> In file ${COLOR_BLUE}${f}${COLOR_REST} <<<<<"
32+ echo " ${diff} " | tail -n +4
33+ return_code=1
34+ if [ " ${AUTO_FIX} " == " true" ]; then
35+ bash -c " ${CLANG_FORMATTER} ${f} -i -style=file"
36+ echo -e " >>>>> Auto-format ${COLOR_BLUE}${f}${COLOR_REST} done. <<<<<"
37+ fi
38+ fi
39+ done
40+
41+ exit ${return_code}
You can’t perform that action at this time.
0 commit comments