From a8d481d914acd9e133fbbd1130d670874e1413bd Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 17 Dec 2025 15:07:57 +0100 Subject: [PATCH] add static analysis --- jenkins/README.md | 6 +++++ jenkins/build-opm-module.sh | 46 +++++++++++++++++++++++++++++++++++++ jenkins/static_analysis.sh | 8 +++++++ 3 files changed, 60 insertions(+) create mode 100755 jenkins/static_analysis.sh diff --git a/jenkins/README.md b/jenkins/README.md index 5bfc46c3be7..15a88700b15 100644 --- a/jenkins/README.md +++ b/jenkins/README.md @@ -9,3 +9,9 @@ This expects to run on a jenkins instance with opm-common as the 'origin' remote It will build and test opm-common. It can be used both for post-merge builds of the master branch and for a github pull request builder job. + +**static_analysis.sh**: +This expects to run on a jenkins instance with opm-common as the 'origin' remote. + +It will run and build opm-common using various configurations, and then +run static analysis. diff --git a/jenkins/build-opm-module.sh b/jenkins/build-opm-module.sh index 36541bf0293..5829c768b3d 100755 --- a/jenkins/build-opm-module.sh +++ b/jenkins/build-opm-module.sh @@ -309,3 +309,49 @@ function build_module_full { test $? -eq 0 || exit 1 fi } + +# Run static analysis checks for a given module +# Assumes coverage_gcov, debug_iterator and clang_lto build configurations +# has been built. +# $1 - Name of main module +function run_static_analysis { + if test -d $WORKSPACE/coverage_gcov + then + pushd $WORKSPACE/coverage_gcov/build-$1 + gcovr -j$TESTTHREADS --xml -r /build -o /build/coverage.xml + popd + fi + + if test -d $WORKSPACE/debug_iterator + then + pushd $WORKSPACE/debug_iterator/build-$1 + ninja doc + popd + fi + + COMPILE_COMMANDS=$WORKSPACE/clang_lto/build-$1/compile_commands.json + if test -d $WORKSPACE/clang_lto + then + pushd $WORKSPACE + infer run \ + --compilation-database $COMPILE_COMMANDS \ + --keep-going \ + --pmd-xml \ + -j $TESTTHREADS + popd + + run-clang-tidy -checks='clang-analyzer.*' \ + -p $WORKSPACE/clang_lto/build-$1/ \ + -j$TESTTHREADS | tee $WORKSPACE/clang-tidy-report.log + + cppcheck --project=${COMPILE_COMMANDS} \ + -q \ + --force \ + --enable=all \ + --xml \ + --xml-version=2 \ + -i$WORKSPACE/tests/material/test_fluidmatrixinteractions.cpp \ + -j$TESTTHREADS \ + --output-file=$WORKSPACE/cppcheck-result.xml + fi +} diff --git a/jenkins/static_analysis.sh b/jenkins/static_analysis.sh new file mode 100755 index 00000000000..99bf2565e98 --- /dev/null +++ b/jenkins/static_analysis.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +source ${TOOLCHAIN_DIR}/build-configurations-sca.sh +source `dirname $0`/build-opm-module.sh + +$WORKSPACE/jenkins/build.sh + +run_static_analysis opm-common