Skip to content

Commit 758a7cd

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

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/codechecker.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
pip3 install --break-system-packages codechecker
27+
28+
- name: Build with compile commands
29+
env:
30+
CC: clang-${{ env.LLVM_VERSION }}
31+
CXX: clang++-${{ env.LLVM_VERSION }}
32+
run: |
33+
mkdir build && cd build
34+
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
35+
36+
- name: Restore analysis cache
37+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
38+
with:
39+
path: ./reports
40+
key: codechecker-${{ hashFiles('src/**', 'include/**') }}
41+
restore-keys: codechecker-
42+
43+
- name: Run CodeChecker analyze
44+
run: |
45+
CodeChecker analyze build/compile_commands.json \
46+
--analyzers clangsa \
47+
--output ./reports
48+
49+
- name: Run CodeChecker CTU analyze
50+
run: |
51+
CodeChecker analyze build/compile_commands.json \
52+
--analyzers clangsa \
53+
--ctu-all \
54+
--output ./reports-ctu
55+
56+
- name: Parse results
57+
run: CodeChecker parse ./reports ./reports-ctu
58+
59+
- name: Generate HTML report
60+
if: failure()
61+
run: |
62+
CodeChecker parse ./reports ./reports-ctu \
63+
--export html \
64+
--output ./reports-html
65+
66+
- name: Upload report
67+
if: failure()
68+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
69+
with:
70+
name: codechecker-report
71+
path: ./reports-html

0 commit comments

Comments
 (0)