1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
|
# 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: CI-unixish
on:
push:
branches:
- 'main'
- 'releases/**'
- '2.*'
tags:
- '2.*'
pull_request:
permissions:
contents: read
jobs:
build_cmake_tinyxml2:
strategy:
matrix:
os: [ubuntu-22.04, macos-15]
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
env:
# TODO: figure out why there are cache misses with PCH enabled
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
- name: Install missing software on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install libxml2-utils libtinyxml2-dev
# qt6-tools-dev-tools for lprodump
# qt6-l10n-tools for lupdate
sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev
# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils qt@6 tinyxml2 pcre
- name: CMake build on ubuntu (with GUI / system tinyxml2)
if: contains(matrix.os, 'ubuntu')
run: |
cmake -S . -B cmake.output.tinyxml2 -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build cmake.output.tinyxml2 -- -j$(nproc)
- name: CMake build on macos (with GUI / system tinyxml2)
if: contains(matrix.os, 'macos')
run: |
cmake -S . -B cmake.output.tinyxml2 -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6
cmake --build cmake.output.tinyxml2 -- -j$(nproc)
- name: Run CMake test (system tinyxml2)
run: |
cmake --build cmake.output.tinyxml2 --target check -- -j$(nproc)
build_cmake:
strategy:
matrix:
os: [ubuntu-22.04, macos-15]
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
env:
# TODO: figure out why there are cache misses with PCH enabled
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
# TODO: move latest compiler to separate step
# TODO: bail out on warnings with latest GCC
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
if: false # matrix.os == 'ubuntu-22.04'
with:
version: 13
platform: x64
- name: Select compiler
if: false # matrix.os == 'ubuntu-22.04'
run: |
echo "CXX=g++-13" >> $GITHUB_ENV
- name: Install missing software on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install libxml2-utils
# qt6-tools-dev-tools for lprodump
# qt6-l10n-tools for lupdate
sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev
# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils qt@6 pcre
- name: Run CMake on ubuntu (with GUI)
if: contains(matrix.os, 'ubuntu')
run: |
cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install
- name: Run CMake on macos (with GUI)
if: contains(matrix.os, 'macos')
run: |
cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6
- name: Run CMake build
run: |
cmake --build cmake.output -- -j$(nproc)
- name: Run CMake test
run: |
cmake --build cmake.output --target check -- -j$(nproc)
- name: Run CTest
run: |
pushd cmake.output
ctest --output-on-failure -j$(nproc)
- name: Run CMake install
run: |
cmake --build cmake.output --target install
- name: Run CMake on ubuntu (no CLI)
if: matrix.os == 'ubuntu-22.04'
run: |
cmake -S . -B cmake.output_nocli -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off
- name: Run CMake on ubuntu (no CLI / with tests)
if: matrix.os == 'ubuntu-22.04'
run: |
# the test and CLI code are too intertwined so for now we need to reject that
if cmake -S . -B cmake.output_nocli_tests -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DBUILD_CLI=Off; then
exit 1
else
exit 0
fi
- name: Run CMake on ubuntu (no CLI / with GUI)
if: matrix.os == 'ubuntu-22.04'
run: |
cmake -S . -B cmake.output_nocli_gui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=On
- name: Run CMake on ubuntu (no GUI)
if: matrix.os == 'ubuntu-22.04'
run: |
cmake -S . -B cmake.output_nogui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off
- name: Run CMake on ubuntu (no GUI / with triage)
if: matrix.os == 'ubuntu-22.04'
run: |
# cannot build triage without GUI
if cmake -S . -B cmake.output_nogui_triage -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then
exit 1
else
exit 0
fi
- name: Run CMake on ubuntu (no CLI / no GUI)
if: matrix.os == 'ubuntu-22.04'
run: |
cmake -S . -B cmake.output_nocli_nogui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off
build_cmake_cxxstd:
strategy:
matrix:
os: [ubuntu-22.04, macos-15]
cxxstd: [14, 17, 20]
# FIXME: macos-15 fails to compile with C++20
#
# /Users/runner/work/cppcheck/cppcheck/cmake.output/gui/test/projectfile/moc_testprojectfile.cpp:84:1: error: 'constinit' specifier is incompatible with C++ standards before C++20 [-Werror,-Wc++20-compat]
# 84 | Q_CONSTINIT const QMetaObject TestProjectFile::staticMetaObject = { {
# | ^
# /opt/homebrew/opt/qt/lib/QtCore.framework/Headers/qcompilerdetection.h:1409:23: note: expanded from macro 'Q_CONSTINIT'
exclude:
- os: macos-15
cxxstd: 20
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
env:
# TODO: figure out why there are cache misses with PCH enabled
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}-${{ matrix.cxxstd }}
- name: Install missing software on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install libxml2-utils
# qt6-tools-dev-tools for lprodump
# qt6-l10n-tools for lupdate
sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev
# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils qt@6 pcre
- name: Run CMake on ubuntu (with GUI)
if: contains(matrix.os, 'ubuntu')
run: |
cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Run CMake on macos (with GUI)
if: contains(matrix.os, 'macos')
run: |
cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6
- name: Run CMake build
run: |
cmake --build cmake.output -- -j$(nproc)
build_uchar:
strategy:
matrix:
os: [ubuntu-22.04, macos-15]
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
brew install coreutils
- name: Build with Unsigned char
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
make -j$(nproc) CXXOPTS="-Werror -funsigned-char" testrunner
- name: Test with Unsigned char
run: |
./testrunner
build_mathlib:
strategy:
matrix:
os: [ubuntu-22.04, macos-15]
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
brew install coreutils
- name: Build with TEST_MATHLIB_VALUE
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
make -j$(nproc) CXXOPTS="-Werror" CPPOPTS=-DTEST_MATHLIB_VALUE all
- name: Test with TEST_MATHLIB_VALUE
run: |
make -j$(nproc) test
check_nonneg:
strategy:
matrix:
os: [ubuntu-22.04, macos-15]
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
# coreutils contains "g++" (default is "c++") and "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
brew install coreutils
- name: Check syntax with NONNEG
run: |
make check-nonneg CXXOPTS="-Werror"
build_cmake_boost:
strategy:
matrix:
os: [macos-15] # non-macos platforms are already built with Boost in other contexts
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
env:
# TODO: figure out why there are cache misses with PCH enabled
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
- name: Run CMake on macOS (force Boost)
run: |
# make sure we fail when Boost is requested and not available.
# will fail because no package configuration is available.
if cmake -S . -B cmake.output.boost-force-noavail -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On; then
exit 1
else
exit 0
fi
# coreutils contains "nproc"
- name: Install missing software on macOS
run: |
brew install coreutils boost
- name: Run CMake on macOS (force Boost)
run: |
cmake -S . -B cmake.output.boost-force -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On
- name: Run CMake on macOS (no Boost)
run: |
# make sure Boost is not used when disabled even though it is available
cmake -S . -B cmake.output.boost-no -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=Off
if grep -q '\-DHAVE_BOOST' ./cmake.output.boost-no/compile_commands.json; then
exit 1
else
exit 0
fi
- name: Run CMake on macOS (with Boost)
run: |
cmake -S . -B cmake.output.boost -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
grep -q '\-DHAVE_BOOST' ./cmake.output.boost/compile_commands.json
- name: Build with CMake on macOS (with Boost)
run: |
cmake --build cmake.output.boost -- -j$(nproc)
build_cmake_minimum: # TODO: move to docker workflow?
runs-on: ubuntu-22.04 # use the oldest available runner
env:
CMAKE_VERSION: 3.22
CMAKE_VERSION_FULL: 3.22.6
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install missing software
run: |
sudo apt-get update
sudo apt-get install libxml2-utils
# qt6-tools-dev-tools for lprodump
# qt6-l10n-tools for lupdate
sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev
- name: Install CMake
run: |
wget https://cmake.org/files/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64.tar.gz
tar xf cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64.tar.gz
- name: Run CMake (without GUI)
run: |
export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH
cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On
- name: Run CMake (with GUI)
run: |
export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH
cmake -S . -B cmake.output.gui -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On
build:
strategy:
matrix:
os: [ubuntu-22.04, macos-15]
include:
- xdist_n: auto
# FIXME: test_color_tty fails with xdist - see #13278
- os: macos-15
xdist_n: '1'
fail-fast: false # Prefer quick result
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
- name: Install missing software on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install libxml2-utils
# packages for strict cfg checks
- name: Install missing software on ubuntu 22.04 (cfg)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get install libcairo2-dev libcurl4-openssl-dev liblua5.3-dev libssl-dev libsqlite3-dev libcppunit-dev libsigc++-2.0-dev libgtk-3-dev libboost-all-dev libselinux-dev libwxgtk3.0-gtk3-dev xmlstarlet qtbase5-dev
# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils pcre gnu-sed
- name: Install missing Python packages on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install pytest-xdist
python3 -m pip install psutil
# we need to use -break-system-packages --user because the common approaches do not work.
# using pip works but it appears to install the packages into a different Python installation so they are not found later on.
# using python3 -m pip without the additional flags fails since the packages are being managed by a different tool (brew) and that lacks some of the packages.
# using pipx also does not work.
- name: Install missing Python packages on macos
if: contains(matrix.os, 'macos')
run: |
python3 -m pip install --break-system-packages --user pip --upgrade
python3 -m pip install --break-system-packages --user pytest
python3 -m pip install --break-system-packages --user pytest-timeout
python3 -m pip install --break-system-packages --user pytest-xdist
python3 -m pip install --break-system-packages --user psutil
- name: Build cppcheck
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
make -j$(nproc) CXXOPTS="-Werror" HAVE_RULES=yes
- name: Build test
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
make -j$(nproc) CXXOPTS="-Werror" HAVE_RULES=yes testrunner
- name: Run test
run: |
make -j$(nproc) HAVE_RULES=yes test
# requires "gnu-sed" installed on macos
- 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 ${{ matrix.xdist_n }} test/cli
# TODO: use the step below instead
# do not use pushd in this step since we go below the working directory
- name: Run test/cli (symlink)
run: |
cd ..
ln -s cppcheck 'cpp check'
cd 'cpp check/test/cli'
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }}
# FIXME: proj2_test.py fails because of the relative path cleanups in ImportProject::setRelativePaths()
# It fails because the application path used as base path has its symlink resolved by getcwd().
- name: Run test/cli (symlink)
if: false
run: |
ln -s . 'cpp check'
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} 'cpp check/test/cli'
- name: Run test/cli (-j2)
run: |
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} test/cli
env:
TEST_CPPCHECK_INJECT_J: 2
- name: Run test/cli (--clang)
if: false
run: |
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} test/cli
env:
TEST_CPPCHECK_INJECT_CLANG: clang
- name: Run test/cli (--cppcheck-build-dir)
run: |
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} test/cli
env:
TEST_CPPCHECK_INJECT_BUILDDIR: injected
- name: Run cfg tests
if: matrix.os != 'ubuntu-22.04'
run: |
make -j$(nproc) checkcfg
- name: Run cfg tests (strict)
if: matrix.os == 'ubuntu-22.04'
run: |
make -j$(nproc) checkcfg
env:
STRICT: 1
- name: Run --dump test
run: |
./cppcheck test/testpreprocessor.cpp --dump
xmllint --noout test/testpreprocessor.cpp.dump
- name: Validate
run: |
make -j$(nproc) checkCWEEntries validateXML
- name: Test install
run: |
# this is only to test the "install" target - since we did not build with FILESDIR it would not work as intended
make DESTDIR=cppcheck-make-install FILESDIR=/share/Cppcheck install
rm -rf cppcheck-make-install
- name: Test Signalhandler
run: |
cmake -S . -B build.cmake.signal -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On
cmake --build build.cmake.signal --target test-signalhandler -- -j$(nproc)
# TODO: how to run this without copying the file?
cp build.cmake.signal/bin/test-s* .
python3 -m pytest -Werror --strict-markers -vv test/signal/test-signalhandler.py
rm test-signalhandler
# no unix backtrace support on MacOs
- name: Test Stacktrace
if: contains(matrix.os, 'ubuntu')
run: |
cmake -S . -B build.cmake.stack -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On
cmake --build build.cmake.stack --target test-stacktrace -- -j$(nproc)
# TODO: how to run this without copying the file?
cp build.cmake.stack/bin/test-s* .
python3 -m pytest -Werror --strict-markers -vv test/signal/test-stacktrace.py
rm test-stacktrace
# TODO: move to scriptcheck.yml so these are tested with all Python versions?
- 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
pushd 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
# TODO: do we need to verify something here?
../../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
- name: test addons (Python)
if: matrix.os != 'ubuntu-22.04'
run: |
python3 -m pytest -Werror --strict-markers -vv -n 1 addons/test
env:
PYTHONPATH: ./addons
# TODO: run with "-n auto" when misra_test.py can be run in parallel
# we cannot specify -Werror since xml/etree/ElementTree.py in Python 3.10 contains an unclosed file
- name: test addons (Python)
if: matrix.os == 'ubuntu-22.04'
run: |
python3 -m pytest --strict-markers -vv -n 1 addons/test
env:
PYTHONPATH: ./addons
- name: Build democlient
if: matrix.os == 'ubuntu-22.04'
run: |
warnings="-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar"
g++ $warnings -c -Ilib -Iexternals/tinyxml2 democlient/democlient.cpp
- name: Test disabled executors
if: matrix.os == 'ubuntu-22.04'
run: |
g++ -Ilib -c cli/threadexecutor.cpp -DDISALLOW_THREAD_EXECUTOR
test -z "$(nm threadexecutor.o)"
g++ -Ilib -c cli/processexecutor.cpp -DDISALLOW_PROCESS_EXECUTOR
test -z "$(nm processexecutor.o)"
# TODO: test NO_* defines
- name: Show all ignored files
if: false # TODO: currently lists all the contents of ignored folders - we only need what actually matched
run: |
git ls-files --others --ignored --exclude-standard
- name: Check for changed and unversioned files
run: |
# TODO: how to do this with a single command?
git status --ignored=no
git status --ignored=no | grep -q 'working tree clean'
selfcheck:
needs: build # wait for all tests to be successful first
runs-on: ubuntu-22.04 # run on the latest image only
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
- name: Install missing software on ubuntu
run: |
sudo apt-get update
# qt6-tools-dev-tools for lprodump
# qt6-l10n-tools for lupdate
sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev
sudo apt-get install libboost-container-dev
- name: Self check (build)
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
# compile with verification and ast matchers
make -j$(nproc) CXXOPTS="-Werror -g -O2" CPPOPTS="-DCHECK_INTERNAL -DHAVE_BOOST" MATCHCOMPILER=yes VERIFY=1
- name: CMake
run: |
cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On
- name: Generate dependencies
run: |
# make sure auto-generated GUI files exist
make -C cmake.output autogen
make -C cmake.output gui-build-deps triage-build-ui-deps
- name: Self check
run: |
./selfcheck.sh
|