Skip to content

Commit b6e59c4

Browse files
dmcppcheckclaude
andcommitted
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 <noreply@anthropic.com>
1 parent fdc1942 commit b6e59c4

1 file changed

Lines changed: 125 additions & 0 deletions

File tree

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
2+
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
3+
name: CI-buildtools
4+
5+
on:
6+
push:
7+
branches:
8+
- 'main'
9+
- 'releases/**'
10+
- '2.*'
11+
tags:
12+
- '2.*'
13+
pull_request:
14+
15+
permissions:
16+
contents: read
17+
packages: read
18+
19+
jobs:
20+
build_and_test:
21+
22+
strategy:
23+
matrix:
24+
image:
25+
- "ghcr.io/cppchecksolutions/buildtools-ubuntu-22.04:v3"
26+
- "ghcr.io/cppchecksolutions/buildtools-ubuntu-24.04:v3"
27+
- "ghcr.io/cppchecksolutions/buildtools-ubuntu-26.04:v3"
28+
fail-fast: false # Prefer quick result
29+
30+
runs-on: ubuntu-24.04
31+
32+
container:
33+
image: ${{ matrix.image }}
34+
credentials:
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
steps:
39+
- uses: actions/checkout@v6
40+
with:
41+
persist-credentials: false
42+
43+
# the buildtools images only contain the compilers and build tools
44+
- name: Install missing software
45+
run: |
46+
apt-get update
47+
apt-get install -y libpcre2-dev libxml2-utils python3-pytest python3-pytest-xdist python3-pytest-timeout python3-psutil python3-pygments
48+
49+
- name: Build cppcheck
50+
run: |
51+
make -j$(nproc) CXXOPTS="-Werror" HAVE_RULES=yes
52+
53+
- name: Build test
54+
run: |
55+
make -j$(nproc) CXXOPTS="-Werror" HAVE_RULES=yes testrunner
56+
57+
- name: Run test
58+
run: |
59+
make -j$(nproc) HAVE_RULES=yes test
60+
61+
- name: Run extra tests
62+
run: |
63+
test/scripts/generate_and_run_more_tests.sh
64+
65+
- name: Run test/cli
66+
run: |
67+
python3 -m pytest -Werror --strict-markers -vv -n auto test/cli
68+
69+
- name: Run cfg tests
70+
run: |
71+
make -j$(nproc) checkcfg
72+
73+
- name: Validate
74+
run: |
75+
make -j$(nproc) checkCWEEntries validateXML
76+
77+
- name: Test addons
78+
run: |
79+
set -x
80+
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety addons/test/threadsafety
81+
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety --std=c++03 addons/test/threadsafety
82+
./cppcheck --error-exitcode=1 --inline-suppr --addon=misra addons/test/misra/crash*.c
83+
./cppcheck --error-exitcode=1 --inline-suppr --addon=misra --enable=information addons/test/misra/config*.c
84+
85+
./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c
86+
cd addons/test
87+
# We'll force C89 standard to enable an additional verification for
88+
# rules 5.4 and 5.5 which have standard-dependent options.
89+
../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64
90+
python3 ../misra.py -verify misra/misra-test.c.dump
91+
# Test slight MISRA differences in C11 standard
92+
../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test-c11.c --std=c11 --platform=unix64
93+
python3 ../misra.py -verify misra/misra-test-c11.c.dump
94+
../../cppcheck --dump -DDUMMY --suppress=uninitvar --suppress=uninitStructMember --std=c89 misra/misra-test.h
95+
../../cppcheck --dump misra/misra-test.cpp
96+
python3 ../misra.py -verify misra/misra-test.cpp.dump
97+
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_ascii.txt -verify misra/misra-test.cpp.dump
98+
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_utf8.txt -verify misra/misra-test.cpp.dump
99+
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_windows1250.txt -verify misra/misra-test.cpp.dump
100+
../../cppcheck --addon=misra --enable=style --platform=avr8 --error-exitcode=1 misra/misra-test-avr8.c
101+
../../cppcheck --dump misc-test.cpp
102+
python3 ../misc.py -verify misc-test.cpp.dump
103+
../../cppcheck --dump naming_test.c
104+
python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump
105+
../../cppcheck --dump naming_test.cpp
106+
python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump
107+
108+
# TODO: run with "-n auto" when misra_test.py can be run in parallel
109+
# we cannot specify -Werror on Ubuntu 22.04 since xml/etree/ElementTree.py in Python 3.10 contains an unclosed file
110+
- name: Test addons (Python)
111+
run: |
112+
python3 -m pytest $PYTEST_WERROR --strict-markers -vv -n 1 addons/test
113+
env:
114+
PYTHONPATH: ./addons
115+
PYTEST_WERROR: ${{ !contains(matrix.image, '22.04') && '-Werror' || '' }}
116+
117+
- name: Test tools
118+
run: |
119+
python3 test/tools/test_matchcompiler.py
120+
test/tools/htmlreport/test_htmlreport.py
121+
test/tools/htmlreport/check.sh
122+
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
123+
rm -f test/tools/donate-cpu-server.log
124+
env:
125+
PYTHONPATH: ./tools

0 commit comments

Comments
 (0)