-
Notifications
You must be signed in to change notification settings - Fork 74
158 lines (152 loc) · 6.78 KB
/
static.check.yml
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Static checkers and verifiers
# "Pre-build" Scripts from TAOS-CI
# @todo Make this "reusable workflow" and publish for all projects.
## Common variables and files
# - changed_file_list in GITHUB_ENV: the list of files updated in this pull-request.
on:
pull_request:
branches: [ main ]
jobs:
simple_script_checkers:
runs-on: ubuntu-latest
name: Static checks
steps:
- name: Preparing step 1... Checking out
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: -${{ github.event.pull_request.commits }}
- name: Preparing step 2... Installing packages
run: sudo apt-get update && sudo apt-get install clang-format git grep gawk exuberant-ctags indent pylint rpmlint aha cppcheck aspell doxygen sloccount shellcheck flawfinder
- name: Preparing step 3... Identify changed files
run: |
tmpfile_pre=$(mktemp)
tmpfile=$(mktemp)
git show --pretty="format:" --name-only --diff-filter=AMRC ${{ github.event.pull_request.head.sha}} -${{ github.event.pull_request.commits }} > ${tmpfile_pre}
####### Screen out deleted files from the file list!!!
echo "::group::The list of changed files"
for file in `cat ${tmpfile_pre}`; do
if [[ -f $file ]]; then
echo "$file"
echo "$file" >> $tmpfile
else
echo "$file is deleted."
fi
done
echo "::endgroup::"
echo "changed_file_list=${tmpfile}" >> "$GITHUB_ENV"
- name: /Checker/ clang-format for .cc/.hh/.hpp/.cpp files
# Originally from "pr-prebuild-clang"
# Need "clang-format"
run: |
echo "Check .clang-format file"
if [ ! -f ".clang-format" ]; then
echo "::error .clang-format file not found"
exit 1
fi
for file in `cat $changed_file_list`; do
echo "Checking $file"
if [[ "$file" =~ .*\.hh$ ]] || [[ "$file" =~ .*\.hpp ]] || [[ "$file" =~ .*\.cc$ ]] || [[ "$file" =~ .*\.cpp ]]; then
clang-format -i ${file}
fi
done
git diff -- *.cc *.hh *.hpp *.cpp > .ci.clang-format.patch
SIZE=$(stat -c%s .ci.clang-format.patch)
if [[ $SIZE -ne 0 ]]; then
echo "::group::The clang-format complaints..."
cat .ci.clang-format.patch
echo "::endgroup::"
echo "::error clang-format has found style errors in C++ files."
exit 1
fi
echo "clang-format shows no style errors."
- name: /Checker/ File size check
# Originally from "pr-prebuild-file-size"
run: |
for file in `cat $changed_file_list`; do
echo "Checking $file"
FILESIZE=$(stat -c%s "$file")
FILESIZE_NUM=`echo $FILESIZE | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'`
if [[ $FILESIZE -gt $[ 5*1024*1024 ] ]]; then
echo "::error $file is too large: $FILESIZE > 5MiB"
exit 1
fi
done
- name: /Checker/ Doxygen tag check
# Originally from "pr-prebuild-doxygen-tag"
# Need "grep"
run: |
bash .github/workflows/static.check.scripts/doxygen-tag.sh $changed_file_list 1
- name: /Checker/ Indent check
# Originally from "pr-prebuild-indent"
# Need "indent"
run: |
bash .github/workflows/static.check.scripts/indent.sh $changed_file_list
- name: /Checker/ Pylint
# Originally from "pr-prebuild-pylint"
# Need "pylint"
run: |
bash .github/workflows/static.check.scripts/pylint.sh $changed_file_list
- name: /Checker/ Incorrect newlines
# Originally from "pr-prebuild-newline"
run: |
bash .github/workflows/static.check.scripts/newline.sh $changed_file_list
- name: /Checker/ RPM spec lint
# Originally from "pr-prebuild-rpm-spec"
# Need "rpmlint", "aha"
# Tolerated errors: 40 (make it 0 someday!!!)
run: |
bash .github/workflows/static.check.scripts/rpm-spec.sh $changed_file_list 40
- name: /Checker/ CPPCheck errors
# Originally from "pr-prebuild-cppcheck"
# Need "cppcheck"
run: |
bash .github/workflows/static.check.scripts/cppcheck.sh $changed_file_list 0
- name: /Checker/ Commit without proper message
# Originally from "pr-prebuild-nobody"
run: |
bash .github/workflows/static.check.scripts/nobody.sh ${{ github.event.pull_request.commits }}
- name: /Checker/ Timestamp from the future
# Originally from "pr-prebuild-timestamp"
run: |
bash .github/workflows/static.check.scripts/timestamp.sh ${{ github.event.pull_request.commits }}
- name: /Checker/ Executable bits in source code files
# Originally from "pr-prebuild-executable"
run: |
bash .github/workflows/static.check.scripts/executable.sh $changed_file_list
- name: /Checker/ Hardcoded paths
# Originally from "pr-prebuild-hardcoded-path"
run: |
bash .github/workflows/static.check.scripts/hardcoded-path.sh $changed_file_list
- name: /Checker/ Misspelling
# Originally from "pr-prebuild-misspelling"
run: |
bash .github/workflows/static.check.scripts/misspelling.sh $changed_file_list
- name: /Checker/ Doxygen build test
# Originally from "pr-prebuild-doxygen-build"
run: |
bash .github/workflows/static.check.scripts/doxygen-build.sh $changed_file_list
- name: /Checker/ sloccount limit
# Originally from "pr-prebuild-sloccount"
run: |
bash .github/workflows/static.check.scripts/sloccount.sh $changed_file_list
- name: /Checker/ prohibited words
# Originally from "pr-prebuild-prohibited-words"
run: |
bash .github/workflows/static.check.scripts/prohibited-words.sh $changed_file_list
- name: /Checker/ signed-off-by required
# Originally from "pr-prebuild-signed-off-by"
run: |
bash .github/workflows/static.check.scripts/signed-off-by.sh ${{ github.event.pull_request.commits }}
- name: /Checker/ shellcheck for shell scripts
# Originally from "pr-prebuild-shellcheck"
run: |
bash .github/workflows/static.check.scripts/shellcheck.sh $changed_file_list
- name: /Checker/ flawfinder for C/C++ files
# Originally from "pr-prebuild-flawfinder"
run: |
bash .github/workflows/static.check.scripts/flawfinder.sh $changed_file_list 1
- name: /Checker/ covertity for C/C++ files
# Originally from "pr-prebuild-coverity"
run: |
#bash .github/workflows/static.check.scripts/coverity.sh $changed_file_list