Skip to content

Commit 794dbb2

Browse files
committed
Add CodeChecker static analyzer in CI
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
1 parent b9285b5 commit 794dbb2

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/codechecker.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CodeChecker Analysis
2+
3+
on:
4+
push:
5+
# branches: [main]
6+
pull_request:
7+
# branches: [main]
8+
9+
env:
10+
LLVM_VERSION: 22
11+
12+
jobs:
13+
analyze:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
18+
- name: Install dependencies
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y build-essential python3-pip wget lsb-release software-properties-common gnupg
22+
wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
23+
# Temporary fix to install clang-22
24+
sed -i 's/LLVM_VERSION_PATTERNS\[22\]=\"\"/LLVM_VERSION_PATTERNS[22]=\"-22\"/' /tmp/llvm.sh
25+
sudo bash /tmp/llvm.sh ${{ env.LLVM_VERSION }}
26+
# sudo ln -sf /usr/bin/clang-${{ env.LLVM_VERSION }} /usr/bin/clang
27+
# sudo ln -sf /usr/bin/clang++-${{ env.LLVM_VERSION }} /usr/bin/clang++
28+
pip3 install --break-system-packages codechecker
29+
# echo "$HOME/.local/bin" >> "$GITHUB_PATH"
30+
31+
- name: Build with compile commands
32+
run: |
33+
mkdir build && cd build
34+
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
35+
36+
- name: Run CodeChecker analyze
37+
run: |
38+
CodeChecker analyze build/compile_commands.json \
39+
--analyzers clangsa \
40+
--output ./reports
41+
42+
- name: Parse results
43+
run: CodeChecker parse ./reports
44+
45+
- name: Generate HTML report
46+
if: failure()
47+
run: |
48+
CodeChecker parse ./reports \
49+
--export html \
50+
--output ./reports-html
51+
52+
- name: Upload report
53+
if: failure()
54+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
55+
with:
56+
name: codechecker-report
57+
path: ./reports-html

0 commit comments

Comments
 (0)