1 name: Static checkers and verifiers
3 # "Pre-build" Scripts from TAOS-CI
4 # @todo Make this "reusable workflow" and publish for all projects.
6 ## Common variables and files
7 # - changed_file_list in GITHUB_ENV: the list of files updated in this pull-request.
14 simple_script_checkers:
15 runs-on: ubuntu-latest
18 - name: Preparing step 1... Checking out
19 uses: actions/checkout@v4
21 ref: ${{ github.event.pull_request.head.sha }}
22 fetch-depth: -${{ github.event.pull_request.commits }}
23 - name: Preparing step 2... Installing packages
24 run: sudo apt-get update && sudo apt-get install clang-format git grep gawk exuberant-ctags indent pylint rpmlint aha
25 - name: Preparing step 3... Identify changed files
29 git show --pretty="format:" --name-only --diff-filter=AMRC ${{ github.event.pull_request.head.sha}} -${{ github.event.pull_request.commits }} > ${tmpfile_pre}
31 ####### Screen out deleted files from the file list!!!
33 echo "::group::The list of changed files"
34 for file in `cat ${tmpfile_pre}`; do
35 if [[ -f $file ]]; then
37 echo "$file" >> $tmpfile
39 echo "$file is deleted."
43 echo "changed_file_list=${tmpfile}" >> "$GITHUB_ENV"
44 - name: /Checker/ clang-format for .cc/.hh/.hpp/.cpp files
45 # Originally from "pr-prebuild-clang"
48 echo "Check .clang-format file"
49 if [ ! -f ".clang-format" ]; then
50 echo "::error .clang-format file not found"
53 for file in `cat $changed_file_list`; do
55 if [[ "$file" =~ .*\.hh$ ]] || [[ "$file" =~ .*\.hpp ]] || [[ "$file" =~ .*\.cc$ ]] || [[ "$file" =~ .*\.cpp ]]; then
56 clang-format -i ${file}
59 git diff -- *.cc *.hh *.hpp *.cpp > .ci.clang-format.patch
60 SIZE=$(stat -c%s .ci.clang-format.patch)
61 if [[ $SIZE -ne 0 ]]; then
62 echo "::group::The clang-format complaints..."
63 cat .ci.clang-format.patch
65 echo "::error clang-format has found style errors in C++ files."
68 echo "clang-format shows no style errors."
69 - name: /Checker/ File size check
70 # Originally from "pr-prebuild-file-size"
72 for file in `cat $changed_file_list`; do
74 FILESIZE=$(stat -c%s "$file")
75 FILESIZE_NUM=`echo $FILESIZE | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'`
76 if [[ $FILESIZE -gt $[ 5*1024*1024 ] ]]; then
77 echo "::error $file is too large: $FILESIZE > 5MiB"
81 - name: /Checker/ Doxygen tag check
82 # Originally from "pr-prebuild-doxygen-tag"
85 bash .github/workflows/static.check.scripts/doxygen-tag.sh $changed_file_list 1
86 - name: /Checker/ Indent
87 # Originally from "pr-prebuild-indent"
90 bash .github/workflows/static.check.scripts/indent.sh $changed_file_list
91 - name: /Checker/ Pylint
92 # Originally from "pr-prebuild-pylint"
95 bash .github/workflows/static.check.scripts/pylint.sh $changed_file_list
96 - name: /Checker/ Newline
97 # Originally from "pr-prebuild-newline"
99 bash .github/workflows/static.check.scripts/newline.sh $changed_file_list
100 - name: /Checker/ RPM Spec
101 # Originally from "pr-prebuild-rpm-spec"
102 # Need "rpmlint", "aha"
103 # Tolerated errors: 40 (make it 0 someday!!!)
105 bash .github/workflows/static.check.scripts/rpm-spec.sh $changed_file_list 40