Skip to content

Commit 31835ee

Browse files
committed
Run CodeChecker in CI.
Signed-off-by: Moritz Buhl <moritz.buhl@infineon.com>
1 parent 6c0e832 commit 31835ee

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/codechecker.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 Infineon Technologies AG
2+
#
3+
# SPDX-License-Identifier: BSD-2-Clause
4+
5+
name: CodeChecker Analysis
6+
on:
7+
[push, pull_request]
8+
jobs:
9+
codechecker-analysis:
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ghcr.io/tpm2-software/ubuntu-24.04
13+
steps:
14+
- name: "Check out repository"
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Trust workspace for bootstrap
20+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
21+
22+
- name: Run bootstrap and configure
23+
run: |
24+
DOCKER_BUILD_DIR=$GITHUB_WORKSPACE .ci/docker-prelude.sh
25+
./bootstrap
26+
mkdir build
27+
cd build
28+
../configure --enable-unit --disable-hardening
29+
30+
- name: Fix action and repository paths for codechecker-analysis-action
31+
run: |
32+
mkdir -p /home/runner/work
33+
ln -s /__w/_actions /home/runner/work/_actions
34+
ln -s /__w/tpm2-tools /home/runner/work/tpm2-tools
35+
36+
- name: Apply workarounds for LLVM installation in codechecker-analysis-action
37+
run: |
38+
apt-get update
39+
apt-get install -y clang clang-tidy software-properties-common sudo
40+
# Rename binaries so we can register them with update-alternatives
41+
mv /usr/bin/clang /usr/bin/clang-distro
42+
mv /usr/bin/clang-tidy /usr/bin/clang-tidy-distro
43+
# Register them so get-llvm.sh's update-alternatives --query calls don't fail
44+
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-distro 100
45+
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-distro 100
46+
47+
- name: Set analyzers exclusively to Clang Static Analyzer
48+
run: |
49+
cat > /tmp/codechecker.json <<EOF
50+
{
51+
"analyze": ["--analyzers", "clangsa"]
52+
}
53+
EOF
54+
55+
- uses: whisperity/codechecker-analysis-action@v1
56+
id: codechecker
57+
with:
58+
build-command: "cd ${{ github.workspace }}/build; make -j$(nproc)"
59+
ctu: true
60+
config: /tmp/codechecker.json
61+
62+
- uses: actions/upload-artifact@v7
63+
with:
64+
name: "CodeChecker Bug Reports"
65+
path: ${{ steps.codechecker.outputs.result-html-dir }}
66+
67+
- name: "Break build on warnings"
68+
if: ${{ steps.codechecker.outputs.warnings == 'true' }}
69+
run: exit 1

0 commit comments

Comments
 (0)