-
Notifications
You must be signed in to change notification settings - Fork 381
206 lines (189 loc) · 7.58 KB
/
config_coverage.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: checker-config-coverage
on:
push:
paths:
- '.github/workflows/config_coverage.yml'
- '.github/workflows/config_label_check.py'
- 'config/labels/analyzers/clang-tidy.json'
- 'config/labels/analyzers/clangsa.json'
- 'config/labels/analyzers/cppcheck.json'
pull_request:
paths:
- '.github/workflows/config_coverage.yml'
- '.github/workflows/config_label_check.py'
- 'config/labels/analyzers/clang-tidy.json'
- 'config/labels/analyzers/clangsa.json'
- 'config/labels/analyzers/cppcheck.json'
schedule:
# Run every Sunday at 21:30 (to latest master at that time).
- cron: '30 21 * * SUN'
# Allow running this job manually from either API or GitHub UI.
workflow_dispatch:
jobs:
checker-config-coverage:
name: "Config coverage of checkers"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: "Install dependencies"
run: |
# Some packages, e.g. build-essential and curl are available
# implicitly in GitHub Actions-specific images.
sudo apt-get -qy update
sudo apt-get -y --no-install-recommends install \
gcc-multilib \
python3-dev \
python3-venv
# Unfortunately, there is no "daily" Cppcheck PPA or Linux binary source,
# so we have to build this manually. Luckily, it seems to be a trivial
# enough process.
#
# We do this BEFORE grabbing Clang, so a potentially broken Clang binary
# won't miscompile Cppcheck itself.
- name: "Download Cppcheck source code"
uses: actions/checkout@v3
with:
repository: "danmar/cppcheck"
path: "cppcheck"
- name: "Build Cppcheck"
run: |
set +e # Do not hard exit on an erroring call!
pushd cppcheck
# Note: Cppcheck's compilation would require CMake, but a new enough
# version is automatically present in the GitHub Actions-specific
# image.
echo "::group::Building Cppcheck"
mkdir Build
pushd Build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -- -j $(nproc)
if [[ $? -eq 0 ]]
then
export CPPCHECK_BUILD_SUCCESSFUL=YES
fi
popd # Build
if [[ x"$CPPCHECK_BUILD_SUCCESSFUL"y == "xYESy" ]]
then
sudo update-alternatives --install \
/usr/bin/cppcheck cppcheck "$(pwd)/Build/bin/cppcheck" 10000
echo "::endgroup::"
echo "Installed Cppcheck:"
update-alternatives --query cppcheck
else
echo "::endgroup::"
echo "::notice title=Cppcheck failed to build locally::Coverage will check using Ubuntu official Cppcheck release instead."
sudo apt-get install -y --no-install-recommends \
cppcheck
fi
popd # cppcheck
- name: "Get latest LLVM binary package from the community PPA"
run: |
export DISTRO_FANCYNAME="$(lsb_release -c | awk '{ print $2 }')"
echo "::group::Setup LLVM PPA"
curl -sL http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository -y "deb http://apt.llvm.org/$DISTRO_FANCYNAME/ llvm-toolchain-$DISTRO_FANCYNAME main"
echo "::endgroup::"
# Get the largest Clang package number available.
export LLVM_VER="$(apt-cache search --full 'clang-[[:digit:]]*$' | grep '^Package: clang' | cut -d ' ' -f 2 | sort -V | tail -n 1 | sed 's/clang-//')"
echo "::group::Install Clang and Clang-Tidy version ${LLVM_VER}"
sudo apt-get -y --no-install-recommends install \
clang-$LLVM_VER \
clang-tidy-$LLVM_VER
sudo update-alternatives --install \
/usr/bin/clang clang /usr/bin/clang-$LLVM_VER 10000
sudo update-alternatives --install \
/usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$LLVM_VER 10000
echo "::endgroup::"
echo "Installed Clang:"
update-alternatives --query clang
update-alternatives --query clang-tidy
- name: "Package CodeChecker"
id: codechecker
run: |
pushd analyzer
echo "::group::venv"
make venv
source venv/bin/activate
echo "::endgroup::"
echo "::group::CodeChecker package"
make standalone_package
deactivate
echo "::endgroup::"
echo "CODECHECKER_PATH=$(readlink -f ./build/CodeChecker/bin)" >> "$GITHUB_OUTPUT"
popd # analyzer
- name: "Dump checker list"
run: |
export PATH="${{ steps.codechecker.outputs.CODECHECKER_PATH }}:$PATH"
CodeChecker analyzers --details
CodeChecker checkers \
--analyzer clangsa clang-tidy cppcheck \
--output rows \
> checker_list_normal.txt
CodeChecker checkers \
--analyzer clangsa clang-tidy cppcheck \
--warnings \
--output rows \
> checker_list_diagnostics.txt
- name: "Perform checker config coverage check (--warnings)"
continue-on-error: true
run: |
set +e # Do not hard exit on an erroring call!
.github/workflows/config_label_check.py \
"checker_list_diagnostics.txt" \
"config/labels/analyzers/clangsa.json" \
"config/labels/analyzers/clang-tidy.json" \
"config/labels/analyzers/cppcheck.json" \
--existing-filter "clang-diagnostic-" \
--new-filter "clang-diagnostic-"
EXIT_STATUS=$?
echo "Coverage check returned: $EXIT_STATUS."
# Explicitly check if the bit for "8" is set in the result,
# indicating new checkers without severity set.
if [[ $(($EXIT_STATUS & 8)) -eq 8 ]]
then
echo "::warning title=New unconfigured diagnostics::The checker label config files lack some new diagnostic report (\"warning\") kinds."
exit 0
elif [[ $EXIT_STATUS -eq 1 || $EXIT_STATUS -eq 2 ]]
then
# Script execution error.
exit $EXIT_STATUS
else
# We do not wish to fail if only removed checkers are reported.
exit 0
fi
- name: "Perform checker config coverage check"
run: |
set +e # Do not hard exit on an erroring call!
.github/workflows/config_label_check.py \
"checker_list_normal.txt" \
"config/labels/analyzers/clangsa.json" \
"config/labels/analyzers/clang-tidy.json" \
"config/labels/analyzers/cppcheck.json" \
--existing-ignore "clang-diagnostic-" \
--new-ignore \
"clang-diagnostic-" \
"alpha." \
"apiModeling." \
"debug." \
"optin.osx." \
"osx." \
"darwin-" \
"objc-"
EXIT_STATUS=$?
echo "Coverage check returned: $EXIT_STATUS."
# Explicitly check if the bit for "8" is set in the result,
# indicating new checkers without severity set.
if [[ $(($EXIT_STATUS & 8)) -eq 8 ]]
then
exit 8
elif [[ $EXIT_STATUS -eq 1 || $EXIT_STATUS -eq 2 ]]
then
# Script execution error.
exit $EXIT_STATUS
else
# We do not wish to fail if only removed checkers are reported.
exit 0
fi