|
| 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: Generate compile_commands.json |
| 23 | + run: | |
| 24 | + ./bootstrap |
| 25 | + mkdir build |
| 26 | + cd build |
| 27 | + ../configure \ |
| 28 | + --enable-debug=yes \ |
| 29 | + --enable-unit \ |
| 30 | + --enable-integration \ |
| 31 | + --with-integrationtcti=swtpm \ |
| 32 | + --enable-self-generated-certificate \ |
| 33 | + --with-crypto=ossl |
| 34 | + make -j compile_commands.json |
| 35 | +
|
| 36 | + - name: Fix action paths for codechecker-analysis-action |
| 37 | + run: | |
| 38 | + mkdir -p /home/runner/work |
| 39 | + ln -s /__w/_actions /home/runner/work/_actions |
| 40 | +
|
| 41 | + - name: Apply workarounds for LLVM installation in codechecker-analysis-action |
| 42 | + run: | |
| 43 | + apt-get update |
| 44 | + apt-get install -y clang clang-tidy software-properties-common sudo |
| 45 | + # Rename binaries so we can register them with update-alternatives |
| 46 | + mv /usr/bin/clang /usr/bin/clang-distro |
| 47 | + mv /usr/bin/clang-tidy /usr/bin/clang-tidy-distro |
| 48 | + # Register them so get-llvm.sh's update-alternatives --query calls don't fail |
| 49 | + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-distro 100 |
| 50 | + update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-distro 100 |
| 51 | +
|
| 52 | + - name: Set analyzers exclusively to Clang Static Analyzer |
| 53 | + run: | |
| 54 | + cat > /tmp/codechecker.json <<EOF |
| 55 | + { |
| 56 | + "analyze": ["--analyzers", "clangsa"] |
| 57 | + } |
| 58 | + EOF |
| 59 | +
|
| 60 | + - uses: whisperity/codechecker-analysis-action@v1 |
| 61 | + id: codechecker |
| 62 | + with: |
| 63 | + logfile: ${{ github.workspace }}/build/compile_commands.json |
| 64 | + ctu: true |
| 65 | + config: /tmp/codechecker.json |
| 66 | + |
| 67 | + - uses: actions/upload-artifact@v7 |
| 68 | + with: |
| 69 | + name: "CodeChecker Bug Reports" |
| 70 | + path: ${{ steps.codechecker.outputs.result-html-dir }} |
| 71 | + |
| 72 | + - name: "Break build on warnings" |
| 73 | + if: ${{ steps.codechecker.outputs.warnings == 'true' }} |
| 74 | + run: exit 1 |
0 commit comments