Skip to content

Commit

Permalink
[WIP] cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA committed Dec 30, 2024
1 parent f28bfbc commit 508896f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,33 @@ jobs:
bash -cxe "SHOW_TIMINGS=1 tools/ci/actions/runner.sh test_prefix $dir"; \
done
cppcheck:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'run-cppcheck')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Packages
run: |
sudo apt-get update -y && sudo apt-get install -y bear clang cppcheck
- name: configure tree
run: |
CONFIG_ARG='CC=clang' MAKE_ARG=-j bash -xe tools/ci/actions/runner.sh configure
- name: Build with compilation database
# https://clang.llvm.org/docs/JSONCompilationDatabase.html
# https://github.com/rizsotto/Bear
run: |
MAKE_ARG=-j bash -xe tools/ci/actions/runner.sh build-compilation-database
- name: cppcheck
run: |
mkdir _build
cppcheck --project=compile_commands.json --cppcheck-build-dir=_build \
-j$(nproc) --clang --check-level=exhaustive --enable=all \
-iyacc \
--library=posix.cfg
i386:
runs-on: ubuntu-latest
container:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ _build
META
# Ignore foo.depend, but not .depend
?*.depend
compile_commands.json

# local to root directory

Expand Down
9 changes: 9 additions & 0 deletions tools/ci/actions/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ Build () {
fi
}

BuildCompilationDatabase () {
local failed
bear -- $MAKE_WARN || failed=$?
if ((failed)); then
exit $failed
fi
}

Test () {
if [ "$1" = "sequential" ]; then
echo Running the testsuite sequentially
Expand Down Expand Up @@ -204,6 +212,7 @@ BasicCompiler () {
case $1 in
configure) Configure;;
build) Build;;
build-compilation-database) BuildCompilationDatabase;;
test) Test parallel;;
test_sequential) Test sequential;;
test_prefix) TestPrefix $2;;
Expand Down

0 comments on commit 508896f

Please sign in to comment.