From f34642214dff2e349898e745a20d8662b11ad1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 19 Nov 2026 08:23:23 +0100 Subject: [PATCH 1/4] CI: build and test in the buildtools Ubuntu images Add a CI-buildtools workflow. It runs on the ghcr.io/cppchecksolutions/buildtools-ubuntu-{22.04,24.04,26.04}:v3 images and runs testrunner, the extra tests, test/cli, test/cfg, XML validation, the addons tests and test/tools. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/cppchecksolutions-build.yml | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 .github/workflows/cppchecksolutions-build.yml diff --git a/.github/workflows/cppchecksolutions-build.yml b/.github/workflows/cppchecksolutions-build.yml new file mode 100644 index 00000000000..71b9be849e6 --- /dev/null +++ b/.github/workflows/cppchecksolutions-build.yml @@ -0,0 +1,125 @@ +# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners +name: cppchecksolutions-build + +on: + push: + branches: + - 'main' + - 'releases/**' + - '2.*' + tags: + - '2.*' + pull_request: + +permissions: + contents: read + packages: read + +jobs: + build_and_test: + + strategy: + matrix: + image: + - "ghcr.io/cppchecksolutions/buildtools-ubuntu-22.04:v3" + - "ghcr.io/cppchecksolutions/buildtools-ubuntu-24.04:v3" + - "ghcr.io/cppchecksolutions/buildtools-ubuntu-26.04:v1" + fail-fast: false # Prefer quick result + + runs-on: ubuntu-24.04 + + container: + image: ${{ matrix.image }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + + # the buildtools images only contain the compilers and build tools + - name: Install missing software + run: | + apt-get update + apt-get install -y libpcre2-dev libxml2-utils python3-pytest python3-pytest-xdist python3-pytest-timeout python3-psutil python3-pygments + + - name: Build cppcheck + run: | + make -j$(nproc) CXXOPTS="-Werror" HAVE_RULES=yes + + - name: Build test + run: | + make -j$(nproc) CXXOPTS="-Werror" HAVE_RULES=yes testrunner + + - name: Run test + run: | + make -j$(nproc) HAVE_RULES=yes test + + - name: Run extra tests + run: | + test/scripts/generate_and_run_more_tests.sh + + - name: Run test/cli + run: | + python3 -m pytest -Werror --strict-markers -vv -n auto test/cli + + - name: Run cfg tests + run: | + make -j$(nproc) checkcfg + + - name: Validate + run: | + make -j$(nproc) checkCWEEntries validateXML + + - name: Test addons + run: | + set -x + ./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety addons/test/threadsafety + ./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety --std=c++03 addons/test/threadsafety + ./cppcheck --error-exitcode=1 --inline-suppr --addon=misra addons/test/misra/crash*.c + ./cppcheck --error-exitcode=1 --inline-suppr --addon=misra --enable=information addons/test/misra/config*.c + + ./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c + cd addons/test + # We'll force C89 standard to enable an additional verification for + # rules 5.4 and 5.5 which have standard-dependent options. + ../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 + python3 ../misra.py -verify misra/misra-test.c.dump + # Test slight MISRA differences in C11 standard + ../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test-c11.c --std=c11 --platform=unix64 + python3 ../misra.py -verify misra/misra-test-c11.c.dump + ../../cppcheck --dump -DDUMMY --suppress=uninitvar --suppress=uninitStructMember --std=c89 misra/misra-test.h + ../../cppcheck --dump misra/misra-test.cpp + python3 ../misra.py -verify misra/misra-test.cpp.dump + python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_ascii.txt -verify misra/misra-test.cpp.dump + python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_utf8.txt -verify misra/misra-test.cpp.dump + python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_windows1250.txt -verify misra/misra-test.cpp.dump + ../../cppcheck --addon=misra --enable=style --platform=avr8 --error-exitcode=1 misra/misra-test-avr8.c + ../../cppcheck --dump misc-test.cpp + python3 ../misc.py -verify misc-test.cpp.dump + ../../cppcheck --dump naming_test.c + python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump + ../../cppcheck --dump naming_test.cpp + python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump + + # TODO: run with "-n auto" when misra_test.py can be run in parallel + # we cannot specify -Werror on Ubuntu 22.04 since xml/etree/ElementTree.py in Python 3.10 contains an unclosed file + - name: Test addons (Python) + run: | + python3 -m pytest $PYTEST_WERROR --strict-markers -vv -n 1 addons/test + env: + PYTHONPATH: ./addons + PYTEST_WERROR: ${{ !contains(matrix.image, '22.04') && '-Werror' || '' }} + + - name: Test tools + run: | + python3 test/tools/test_matchcompiler.py + test/tools/htmlreport/test_htmlreport.py + test/tools/htmlreport/check.sh + python3 -m pytest -Werror --strict-markers -vv test/tools/reduce_test.py test/tools/donate_cpu_lib_test.py test/tools/donate_cpu_server_test.py + rm -f test/tools/donate-cpu-server.log + env: + PYTHONPATH: ./tools From 5000735c709ac8c780c53e27cd8599b948be6286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 19 Nov 2026 11:41:18 +0100 Subject: [PATCH 2/4] CI: install strace in the buildtools images Co-Authored-By: Claude Opus 5.5 --- .github/workflows/cppchecksolutions-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppchecksolutions-build.yml b/.github/workflows/cppchecksolutions-build.yml index 71b9be849e6..b4010f20f88 100644 --- a/.github/workflows/cppchecksolutions-build.yml +++ b/.github/workflows/cppchecksolutions-build.yml @@ -44,7 +44,7 @@ jobs: - name: Install missing software run: | apt-get update - apt-get install -y libpcre2-dev libxml2-utils python3-pytest python3-pytest-xdist python3-pytest-timeout python3-psutil python3-pygments + apt-get install -y libpcre2-dev libxml2-utils python3-pytest python3-pytest-xdist python3-pytest-timeout python3-psutil python3-pygments strace - name: Build cppcheck run: | From cf6114f94d33ca921a43f118ec7fadaefd1a4cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 19 Nov 2026 13:31:59 +0100 Subject: [PATCH 3/4] tidy: htmlreport check --- .github/workflows/cppchecksolutions-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppchecksolutions-build.yml b/.github/workflows/cppchecksolutions-build.yml index b4010f20f88..6887f05e973 100644 --- a/.github/workflows/cppchecksolutions-build.yml +++ b/.github/workflows/cppchecksolutions-build.yml @@ -44,7 +44,7 @@ jobs: - name: Install missing software run: | apt-get update - apt-get install -y libpcre2-dev libxml2-utils python3-pytest python3-pytest-xdist python3-pytest-timeout python3-psutil python3-pygments strace + apt-get install -y libpcre2-dev libxml2-utils python3-pytest python3-pytest-xdist python3-pytest-timeout python3-psutil python3-pygments strace tidy - name: Build cppcheck run: | From 0fc6becebcb2ee81a49fd3b5d59ede07582aebc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 20 Nov 2026 11:52:08 +0100 Subject: [PATCH 4/4] Update .github/workflows/cppchecksolutions-build.yml Co-authored-by: William Jakobsson <50847546+wjakobsson@users.noreply.github.com> --- .github/workflows/cppchecksolutions-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppchecksolutions-build.yml b/.github/workflows/cppchecksolutions-build.yml index 6887f05e973..4f2a3d3a6b7 100644 --- a/.github/workflows/cppchecksolutions-build.yml +++ b/.github/workflows/cppchecksolutions-build.yml @@ -36,7 +36,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 with: persist-credentials: false