Static Analysis using CodeChecker :) #13
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # JULEA - Flexible storage framework | |
| # Copyright (C) 2026 Jan Frase | |
| # | |
| # This program is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU Lesser General Public License as published by | |
| # the Free Software Foundation, either version 3 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # This program is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| # GNU Lesser General Public License for more details. | |
| # | |
| # You should have received a copy of the GNU Lesser General Public License | |
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| name: static-analysis | |
| on: [push, pull_request] | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| # This job is responsible for running Codechecker. | |
| code-checker: | |
| name: Code checker | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 60 | |
| env: | |
| JULEA_SPACK_DIR: /julea-dependencies | |
| steps: | |
| # First, checkout julea. | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| show-progress: false | |
| # Get the dependencies. | |
| - name: Install dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt --yes --no-install-recommends install meson ninja-build pkgconf libglib2.0-dev libbson-dev libfabric-dev libgdbm-dev liblmdb-dev libsqlite3-dev libleveldb-dev libmongoc-dev libmariadb-dev librocksdb-dev libfuse3-dev libopen-trace-format-dev librados-dev | |
| # Then, generate compile_commands.json. | |
| - name: Generate compile_commands.json | |
| env: | |
| CC: clang | |
| run: | | |
| . scripts/environment.sh | |
| meson setup bld | |
| # Install CodeChecker, gcc and cppcheck. | |
| - name: Install CodeChecker | |
| run: | | |
| pip install codechecker | |
| sudo apt install --yes --no-install-recommends cppcheck gcc | |
| - name: Install Infer | |
| run: | | |
| VERSION=1.3.0; \ | |
| curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux-x86_64-v$VERSION.tar.xz" \ | |
| | sudo tar -C /opt -xJ && \ | |
| sudo ln -s "/opt/infer-linux-x86_64-v$VERSION/bin/infer" /usr/local/bin/infer | |
| # Run the analysis. | |
| - name: Run CodeChecker | |
| run: CodeChecker analyze ./bld/compile_commands.json -o results --ctu || true | |
| # All of this only runs if its a PR | |
| - name: Calculate the diff | |
| if: github.event_name == 'pull_request' | |
| # It checks out the branch to be merged into, generates the compile_commands.json for that branch, and then runs CodeChecker on that branch. | |
| # It then compares the results of the two branches, via CodeChecker cmd diff. | |
| # Due to GitHub Actions being generally annoying this comes with some code duplication and assumes that the dependencies work for both branches. | |
| run: | | |
| git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1 | |
| git checkout FETCH_HEAD | |
| . scripts/environment.sh | |
| meson setup bld_base | |
| CodeChecker analyze ./bld_base/compile_commands.json -o results_base --ctu || true | |
| CodeChecker cmd diff --basename ./results_base --newname ./results -o results_diff || true | |
| CodeChecker parse --export html --output ./reports_html ./results_diff || true | |
| # Parse the results and generate an HTML report. | |
| # Only for pushes | |
| - name: Generate HTML report | |
| if: github.event_name == 'push' | |
| run: | | |
| # The parse command returns with exit code 2 if it finds any bugs. | |
| # Thus, we ignore the exit code with "|| true", to avoid failing the workflow. | |
| CodeChecker parse --export html --output ./reports_html ./results || true | |
| # Lastly, upload the results to the CI. | |
| - name: Upload results | |
| uses: actions/upload-artifact@v7.0.1 | |
| with: | |
| name: "CodeChecker Bug Reports" | |
| path: ./reports_html |