tools/ci/docker/linux/Dockerfile: Install CodeChecker and requirements(clang, clang-tidy)
.github/workflows/build.yml: added CodeChecker support for GitHub Workflow tools/testbuild.sh: added support for CodeChecker checks - Added support for CodeChecker checks. - Generate inspection reports and summaries. - After the task is executed, the logs are compressed and the database is packaged. Signed-off-by: xinbingnan <xinbingnan@xiaomi.com>
This commit is contained in:
parent
c860a6e5f1
commit
d8cff7d17a
3 changed files with 61 additions and 4 deletions
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
|
@ -122,7 +122,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
boards: [arm-01, arm-02, arm-03, arm-04, arm-05, arm-06, arm-07, arm-08, arm-09, arm-10, arm-11, arm-12, arm-13, other, risc-v, sim-01, sim-02, xtensa]
|
||||
boards: [arm-01, arm-02, arm-03, arm-04, arm-05, arm-06, arm-07, arm-08, arm-09, arm-10, arm-11, arm-12, arm-13, other, risc-v, sim-01, sim-02, xtensa, codechecker]
|
||||
|
||||
steps:
|
||||
- name: Download Source Artifact
|
||||
|
@ -160,10 +160,15 @@ jobs:
|
|||
git config --global --add safe.directory /github/workspace/sources/nuttx
|
||||
git config --global --add safe.directory /github/workspace/sources/apps
|
||||
cd sources/nuttx/tools/ci
|
||||
./cibuild.sh -A -R -c testlist/${{matrix.boards}}.dat
|
||||
if [ "X${{matrix.boards}}" = "Xcodechecker" ]; then
|
||||
./cibuild.sh -A -R -c --codechecker testlist/${{matrix.boards}}.dat
|
||||
else
|
||||
./cibuild.sh -A -R -c testlist/${{matrix.boards}}.dat
|
||||
fi
|
||||
ccache -s
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: linux-builds
|
||||
path: buildartifacts/
|
||||
|
|
4
tools/ci/testlist/codechecker.dat
Normal file
4
tools/ci/testlist/codechecker.dat
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Select a random set of targets to check. If you need to check a specific target, write the target list in this file.
|
||||
# Make sure that the compilation check time does not exceed the average time.
|
||||
|
||||
/arm/sama5/sama5d4-ek/configs/nxwm,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI
|
|
@ -36,6 +36,7 @@ PRINTLISTONLY=0
|
|||
GITCLEAN=0
|
||||
SAVEARTIFACTS=0
|
||||
CHECKCLEAN=1
|
||||
CODECHECKER=0
|
||||
RUN=0
|
||||
|
||||
case $(uname -s) in
|
||||
|
@ -57,7 +58,7 @@ esac
|
|||
|
||||
function showusage {
|
||||
echo ""
|
||||
echo "USAGE: $progname [-l|m|c|g|n] [-d] [-e <extraflags>] [-x] [-j <ncpus>] [-a <appsdir>] [-t <topdir>] [-p] [-G] <testlist-file>"
|
||||
echo "USAGE: $progname [-l|m|c|g|n] [-d] [-e <extraflags>] [-x] [-j <ncpus>] [-a <appsdir>] [-t <topdir>] [-p] [-G] [--codechecker] <testlist-file>"
|
||||
echo " $progname -h"
|
||||
echo ""
|
||||
echo "Where:"
|
||||
|
@ -80,6 +81,7 @@ function showusage {
|
|||
echo " as well."
|
||||
echo " -R execute \"run\" script in the config directories if exists."
|
||||
echo " -h will show this help test and terminate"
|
||||
echo " --codechecker enables CodeChecker statically analyze the code."
|
||||
echo " <testlist-file> selects the list of configurations to test. No default"
|
||||
echo ""
|
||||
echo "Your PATH variable must include the path to both the build tools and the"
|
||||
|
@ -133,6 +135,9 @@ while [ ! -z "$1" ]; do
|
|||
-R )
|
||||
RUN=1
|
||||
;;
|
||||
--codechecker )
|
||||
CODECHECKER=1
|
||||
;;
|
||||
-h )
|
||||
showusage
|
||||
;;
|
||||
|
@ -208,6 +213,18 @@ function exportandimport {
|
|||
return $fail
|
||||
}
|
||||
|
||||
function compressartifacts {
|
||||
local target_path=$1
|
||||
local target_name=$2
|
||||
|
||||
pushd $target_path >/dev/null
|
||||
|
||||
tar zcf ${target_name}.tar.gz ${target_name}
|
||||
rm -rf ${target_name}
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function makefunc {
|
||||
if ! ${MAKE} ${MAKE_FLAGS} "${EXTRA_FLAGS}" ${JOPTION} $@ 1>/dev/null; then
|
||||
fail=1
|
||||
|
@ -218,6 +235,32 @@ function makefunc {
|
|||
return $fail
|
||||
}
|
||||
|
||||
function checkfunc {
|
||||
build_cmd="${MAKE} ${MAKE_FLAGS} \"${EXTRA_FLAGS}\" ${JOPTION} 1>/dev/null"
|
||||
|
||||
local config_sub_path=$(echo "$config" | sed "s/:/\//")
|
||||
local sub_target_name=${config_sub_path#$(dirname "${config_sub_path}")/}
|
||||
local codechecker_dir=${ARTIFACTDIR}/codechecker_logs/${config_sub_path}
|
||||
|
||||
mkdir -p "${codechecker_dir}"
|
||||
|
||||
echo " Checking NuttX by Codechecker..."
|
||||
CodeChecker check -b "${build_cmd}" -o "${codechecker_dir}/logs" -e sensitive --ctu
|
||||
codecheck_ret=$?
|
||||
echo " Storing analysis result to CodeChecker..."
|
||||
echo " Generating HTML report..."
|
||||
CodeChecker parse --export html --output "${codechecker_dir}/html" "${codechecker_dir}/logs" 1>/dev/null
|
||||
echo " Compressing logs..."
|
||||
compressartifacts "$(dirname "${codechecker_dir}")" "${sub_target_name}"
|
||||
|
||||
# If you need to stop CI, uncomment the following line.
|
||||
# if [ $codecheck_ret -ne 0 ]; then
|
||||
# fail=1
|
||||
# fi
|
||||
|
||||
return $fail
|
||||
}
|
||||
|
||||
# Clean up after the last build
|
||||
|
||||
function distclean {
|
||||
|
@ -283,7 +326,12 @@ function configure {
|
|||
|
||||
function build {
|
||||
echo " Building NuttX..."
|
||||
makefunc
|
||||
if [ "${CODECHECKER}" -eq 1 ]; then
|
||||
checkfunc
|
||||
else
|
||||
makefunc
|
||||
fi
|
||||
|
||||
if [ ${SAVEARTIFACTS} -eq 1 ]; then
|
||||
artifactconfigdir=$ARTIFACTDIR/$(echo $config | sed "s/:/\//")/
|
||||
mkdir -p $artifactconfigdir
|
||||
|
|
Loading…
Reference in a new issue