ci: move pos processing to the CI script
Move post processing to script and remove duplicatated code. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
6fd1691b94
commit
a0a1bffd1c
2 changed files with 201 additions and 149 deletions
|
@ -35,74 +35,25 @@ build:
|
|||
- export CCACHE_DIR=${SHIPPABLE_BUILD_DIR}/ccache/.ccache
|
||||
- >
|
||||
if [ "$IS_PULL_REQUEST" = "true" ]; then
|
||||
./scripts/ci/run_ci.sh -b master -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -B ${BSIM_BT_TEST_RESULTS_FILE} -p;
|
||||
./scripts/ci/run_ci.sh -c -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -B ${BSIM_BT_TEST_RESULTS_FILE} -p;
|
||||
else
|
||||
./scripts/ci/run_ci.sh -b master -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -B ${BSIM_BT_TEST_RESULTS_FILE};
|
||||
./scripts/ci/run_ci.sh -c -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -B ${BSIM_BT_TEST_RESULTS_FILE};
|
||||
fi;
|
||||
- ccache -s
|
||||
on_failure:
|
||||
- >
|
||||
if [ -f "$HOME/.cache/zephyr/ToolchainCapabilityDatabase.cmake" ]; then
|
||||
echo "Dumping the capability database in case we are affected by #9992"
|
||||
cat $HOME/.cache/zephyr/ToolchainCapabilityDatabase.cmake
|
||||
fi;
|
||||
- rm -rf ccache $HOME/.cache/zephyr
|
||||
- mkdir -p shippable/testresults
|
||||
- mkdir -p shippable/codecoverage
|
||||
- source zephyr-env.sh
|
||||
- >
|
||||
if [ "$MATRIX_BUILD" = "1" ]; then
|
||||
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
|
||||
lcov --capture --directory sanity-out/native_posix/ --directory sanity-out/nrf52_bsim/ --directory sanity-out/unit_testing/ --directory bsim_bt_out/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
|
||||
lcov -q --remove lcov.pre.info mylib.c --remove lcov.pre.info tests/\* --remove lcov.pre.info samples/\* --remove lcov.pre.info ext/\* --remove lcov.pre.info *generated* -o lcov.info --rc lcov_branch_coverage=1;
|
||||
rm lcov.pre.info;
|
||||
rm -rf sanity-out out-2nd-pass;
|
||||
bash <(curl -s https://codecov.io/bash) -f "lcov.info" -X coveragepy -X fixes;
|
||||
rm -f lcov.info;
|
||||
else
|
||||
rm -rf sanity-out out-2nd-pass;
|
||||
fi;
|
||||
- >
|
||||
if [ -e compliance.xml ]; then
|
||||
cp compliance.xml shippable/testresults/;
|
||||
fi;
|
||||
- >
|
||||
if [ -e ./scripts/sanity_chk/last_sanity.xml ]; then
|
||||
cp ./scripts/sanity_chk/last_sanity.xml shippable/testresults/;
|
||||
fi;
|
||||
- >
|
||||
if [ -e ${BSIM_BT_TEST_RESULTS_FILE} ]; then
|
||||
cp ${BSIM_BT_TEST_RESULTS_FILE} shippable/testresults/;
|
||||
fi;
|
||||
if [ "$IS_PULL_REQUEST" = "true" ]; then
|
||||
./scripts/ci/run_ci.sh -f -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -p;
|
||||
else
|
||||
./scripts/ci/run_ci.sh -f -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS};
|
||||
fi;
|
||||
on_success:
|
||||
- rm -rf ccache $HOME/.cache/zephyr
|
||||
- mkdir -p shippable/testresults
|
||||
- mkdir -p shippable/codecoverage
|
||||
- source zephyr-env.sh
|
||||
- >
|
||||
if [ "$MATRIX_BUILD" = "1" ]; then
|
||||
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
|
||||
lcov --capture --directory sanity-out/native_posix/ --directory sanity-out/nrf52_bsim/ --directory sanity-out/unit_testing/ --directory bsim_bt_out/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
|
||||
lcov -q --remove lcov.pre.info mylib.c --remove lcov.pre.info tests/\* --remove lcov.pre.info samples/\* --remove lcov.pre.info ext/\* --remove lcov.pre.info *generated* -o lcov.info --rc lcov_branch_coverage=1;
|
||||
rm lcov.pre.info;
|
||||
rm -rf sanity-out out-2nd-pass;
|
||||
bash <(curl -s https://codecov.io/bash) -f "lcov.info" -X coveragepy -X fixes;
|
||||
rm -f lcov.info;
|
||||
else
|
||||
rm -rf sanity-out out-2nd-pass;
|
||||
fi;
|
||||
- >
|
||||
if [ -e compliance.xml ]; then
|
||||
cp compliance.xml shippable/testresults/;
|
||||
fi;
|
||||
- >
|
||||
if [ -e ./scripts/sanity_chk/last_sanity.xml ]; then
|
||||
cp ./scripts/sanity_chk/last_sanity.xml shippable/testresults/;
|
||||
fi;
|
||||
- >
|
||||
if [ -e ${BSIM_BT_TEST_RESULTS_FILE} ]; then
|
||||
cp ${BSIM_BT_TEST_RESULTS_FILE} shippable/testresults/;
|
||||
fi;
|
||||
if [ "$IS_PULL_REQUEST" = "true" ]; then
|
||||
./scripts/ci/run_ci.sh -s -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -p;
|
||||
else
|
||||
./scripts/ci/run_ci.sh -s -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS};
|
||||
fi;
|
||||
|
||||
integrations:
|
||||
notifications:
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
#
|
||||
# The script can be run locally using for exmaple:
|
||||
# ./scripts/ci/run_ci.sh -b master -r upstream -p
|
||||
|
||||
set -v
|
||||
|
||||
source zephyr-env.sh
|
||||
|
||||
SANITYCHECK_OPTIONS=" --inline-logs --enable-coverage -N"
|
||||
|
@ -25,55 +28,141 @@ SANITYCHECK="${ZEPHYR_BASE}/scripts/sanitycheck"
|
|||
MATRIX_BUILDS=1
|
||||
MATRIX=1
|
||||
|
||||
while getopts ":pm:b:B:r:M:" opt; do
|
||||
case $opt in
|
||||
p)
|
||||
echo "Testing a Pull Request." >&2
|
||||
PULL_REQUEST=1
|
||||
;;
|
||||
m)
|
||||
echo "Running on Matrix $OPTARG" >&2
|
||||
MATRIX=$OPTARG
|
||||
;;
|
||||
M)
|
||||
echo "Running a matrix of $OPTARG slaves" >&2
|
||||
MATRIX_BUILDS=$OPTARG
|
||||
;;
|
||||
b)
|
||||
echo "Base Branch: $OPTARG" >&2
|
||||
BRANCH=$OPTARG
|
||||
;;
|
||||
B)
|
||||
echo "bsim BT tests xml results file: $OPTARG" >&2
|
||||
BSIM_BT_TEST_RESULTS_FILE=$OPTARG
|
||||
;;
|
||||
r)
|
||||
echo "Remote: $OPTARG" >&2
|
||||
REMOTE=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
;;
|
||||
esac
|
||||
while getopts ":pm:b:r:M:cfsB:" opt; do
|
||||
case $opt in
|
||||
c)
|
||||
echo "Execute CI" >&2
|
||||
MAIN_CI=1
|
||||
;;
|
||||
s)
|
||||
echo "Success" >&2
|
||||
SUCCESS=1
|
||||
;;
|
||||
f)
|
||||
echo "Failure" >&2
|
||||
FAILURE=1
|
||||
;;
|
||||
p)
|
||||
echo "Testing a Pull Request." >&2
|
||||
PULL_REQUEST=1
|
||||
;;
|
||||
m)
|
||||
echo "Running on Matrix $OPTARG" >&2
|
||||
MATRIX=$OPTARG
|
||||
;;
|
||||
M)
|
||||
echo "Running a matrix of $OPTARG slaves" >&2
|
||||
MATRIX_BUILDS=$OPTARG
|
||||
;;
|
||||
b)
|
||||
echo "Base Branch: $OPTARG" >&2
|
||||
BRANCH=$OPTARG
|
||||
;;
|
||||
B)
|
||||
echo "bsim BT tests xml results file: $OPTARG" >&2
|
||||
BSIM_BT_TEST_RESULTS_FILE=$OPTARG
|
||||
;;
|
||||
r)
|
||||
echo "Remote: $OPTARG" >&2
|
||||
REMOTE=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
DOC_MATRIX=${MATRIX_BUILDS}
|
||||
|
||||
if [ -z "$BRANCH" ]; then
|
||||
echo "No base branch given"
|
||||
exit
|
||||
if [ -n "$MAIN_CI" ]; then
|
||||
if [ -z "$BRANCH" ]; then
|
||||
echo "No base branch given"
|
||||
exit
|
||||
else
|
||||
COMMIT_RANGE=$REMOTE/${BRANCH}..HEAD
|
||||
echo "Commit range:" ${COMMIT_RANGE}
|
||||
fi
|
||||
if [ -n "$PULL_REQUEST" ]; then
|
||||
git rebase $REMOTE/${BRANCH};
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$PULL_REQUEST" ]; then
|
||||
git rebase $REMOTE/${BRANCH};
|
||||
fi
|
||||
function handle_coverage() {
|
||||
# this is for shippable coverage reports
|
||||
echo "Calling gcovr"
|
||||
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
|
||||
|
||||
# Capture data
|
||||
echo "Running lcov --capture ..."
|
||||
lcov --capture \
|
||||
--directory sanity-out/native_posix/ \
|
||||
--directory sanity-out/nrf52_bsim/ \
|
||||
--directory sanity-out/unit_testing/ \
|
||||
--directory bsim_bt_out/ \
|
||||
--output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
|
||||
|
||||
# Remove noise
|
||||
echo "Exclude data from coverage report..."
|
||||
lcov -q \
|
||||
--remove lcov.pre.info mylib.c \
|
||||
--remove lcov.pre.info tests/\* \
|
||||
--remove lcov.pre.info samples/\* \
|
||||
--remove lcov.pre.info ext/\* \
|
||||
--remove lcov.pre.info *generated* \
|
||||
-o lcov.info --rc lcov_branch_coverage=1;
|
||||
|
||||
# Cleanup
|
||||
rm lcov.pre.info;
|
||||
rm -rf sanity-out out-2nd-pass;
|
||||
|
||||
# Upload to codecov.io
|
||||
echo "Upload coverage reports to codecov.io"
|
||||
bash <(curl -s https://codecov.io/bash) -f "lcov.info" -X coveragepy -X fixes;
|
||||
rm -f lcov.info;
|
||||
|
||||
}
|
||||
|
||||
function handle_compiler_cache() {
|
||||
# Give more details in case we fail because of compiler cache
|
||||
if [ -f "$HOME/.cache/zephyr/ToolchainCapabilityDatabase.cmake" ]; then
|
||||
echo "Dumping the capability database in case we are affected by #9992"
|
||||
cat $HOME/.cache/zephyr/ToolchainCapabilityDatabase.cmake
|
||||
fi;
|
||||
}
|
||||
|
||||
function on_complete() {
|
||||
if [ "$1" == "failure" ]; then
|
||||
handle_compiler_cache
|
||||
fi
|
||||
|
||||
rm -rf ccache $HOME/.cache/zephyr
|
||||
mkdir -p shippable/testresults
|
||||
mkdir -p shippable/codecoverage
|
||||
source zephyr-env.sh
|
||||
|
||||
if [ "$MATRIX" = "1" ]; then
|
||||
echo "Handle coverage data..."
|
||||
handle_coverage
|
||||
else
|
||||
rm -rf sanity-out out-2nd-pass;
|
||||
fi;
|
||||
|
||||
if [ -e compliance.xml ]; then
|
||||
echo "Copy compliance.xml"
|
||||
cp compliance.xml shippable/testresults/;
|
||||
fi;
|
||||
|
||||
if [ -e ./scripts/sanity_chk/last_sanity.xml ]; then
|
||||
echo "Copy ./scripts/sanity_chk/last_sanity.xml"
|
||||
cp ./scripts/sanity_chk/last_sanity.xml shippable/testresults/;
|
||||
fi;
|
||||
|
||||
if [ -e ${BSIM_BT_TEST_RESULTS_FILE} ]; then
|
||||
echo "Copy ${BSIM_BT_TEST_RESULTS_FILE}"
|
||||
cp ${BSIM_BT_TEST_RESULTS_FILE} shippable/testresults/;
|
||||
fi;
|
||||
}
|
||||
|
||||
if [ -n "$BRANCH" ]; then
|
||||
COMMIT_RANGE=$REMOTE/${BRANCH}..HEAD
|
||||
echo "Commit range:" ${COMMIT_RANGE}
|
||||
else
|
||||
exit
|
||||
fi
|
||||
|
||||
function build_btsim() {
|
||||
NRF_HW_MODELS_VERSION=`cat boards/posix/nrf52_bsim/hw_models_version`
|
||||
|
@ -105,60 +194,72 @@ function run_bsim_bt_tests() {
|
|||
}
|
||||
|
||||
function build_docs() {
|
||||
echo "- Building Documentation";
|
||||
make htmldocs
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Documentation build failed";
|
||||
exit 1;
|
||||
fi
|
||||
if [ -s doc/_build/doc.warnings ]; then
|
||||
echo " => New documentation warnings/errors";
|
||||
cp doc/_build/doc.warnings doc.warnings
|
||||
fi
|
||||
echo "- Verify commit message, coding style, doc build";
|
||||
echo "- Building Documentation";
|
||||
make htmldocs
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Documentation build failed";
|
||||
exit 1;
|
||||
fi
|
||||
if [ -s doc/_build/doc.warnings ]; then
|
||||
echo " => New documentation warnings/errors";
|
||||
cp doc/_build/doc.warnings doc.warnings
|
||||
fi
|
||||
echo "- Verify commit message, coding style, doc build";
|
||||
}
|
||||
|
||||
function get_tests_to_run() {
|
||||
./scripts/ci/get_modified_tests.py --commits ${COMMIT_RANGE} > modified_tests.args;
|
||||
./scripts/ci/get_modified_boards.py --commits ${COMMIT_RANGE} > modified_boards.args;
|
||||
./scripts/ci/get_modified_tests.py --commits ${COMMIT_RANGE} > modified_tests.args;
|
||||
./scripts/ci/get_modified_boards.py --commits ${COMMIT_RANGE} > modified_boards.args;
|
||||
|
||||
if [ -s modified_boards.args ]; then
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_boards.args --save-tests test_file.txt || exit 1;
|
||||
fi
|
||||
if [ -s modified_tests.args ]; then
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_tests.args --save-tests test_file.txt || exit 1;
|
||||
fi
|
||||
rm -f modified_tests.args modified_boards.args;
|
||||
if [ -s modified_boards.args ]; then
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_boards.args --save-tests test_file.txt || exit 1;
|
||||
fi
|
||||
if [ -s modified_tests.args ]; then
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_tests.args --save-tests test_file.txt || exit 1;
|
||||
fi
|
||||
rm -f modified_tests.args modified_boards.args;
|
||||
}
|
||||
|
||||
if [ ! -z "${BSIM_OUT_PATH}" ]; then
|
||||
# Build BT Simulator
|
||||
build_btsim
|
||||
if [ -n "$MAIN_CI" ]; then
|
||||
|
||||
# Run BLE tests in simulator on the 1st CI instance:
|
||||
if [ "$MATRIX" = "1" ]; then
|
||||
run_bsim_bt_tests
|
||||
if [ ! -z "${BSIM_OUT_PATH}" ]; then
|
||||
echo "Build BT simulator tests"
|
||||
# Build BT Simulator
|
||||
build_btsim
|
||||
|
||||
# Run BLE tests in simulator on the 1st CI instance:
|
||||
if [ "$MATRIX" = "1" ]; then
|
||||
run_bsim_bt_tests
|
||||
fi
|
||||
else
|
||||
echo "Skipping BT simulator tests"
|
||||
fi
|
||||
|
||||
# In a pull-request see if we have changed any tests or board definitions
|
||||
if [ -n "${PULL_REQUEST}" ]; then
|
||||
get_tests_to_run
|
||||
fi
|
||||
|
||||
# Save list of tests to be run
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} --save-tests test_file.txt || exit 1
|
||||
|
||||
# Run a subset of tests based on matrix size
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} --load-tests test_file.txt --subset ${MATRIX}/${MATRIX_BUILDS}
|
||||
if [ "$?" != 0 ]; then
|
||||
# let the host settle down
|
||||
sleep 10
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS_RETRY} || \
|
||||
( sleep 10; ${SANITYCHECK} ${SANITYCHECK_OPTIONS_RETRY}; )
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
rm -f test_file.txt
|
||||
|
||||
elif [ -n "$FAILURE" ]; then
|
||||
on_complete failure
|
||||
elif [ -n "$SUCCESS" ]; then
|
||||
on_complete
|
||||
else
|
||||
echo "Skipping BT simulator tests"
|
||||
echo "Nothing to do"
|
||||
fi
|
||||
|
||||
# In a pull-request see if we have changed any tests or board definitions
|
||||
if [ -n "${PULL_REQUEST}" ]; then
|
||||
get_tests_to_run
|
||||
fi
|
||||
|
||||
# Save list of tests to be run
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} --save-tests test_file.txt || exit 1
|
||||
|
||||
# Run a subset of tests based on matrix size
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} --load-tests test_file.txt --subset ${MATRIX}/${MATRIX_BUILDS}
|
||||
if [ "$?" != 0 ]; then
|
||||
# let the host settle down
|
||||
sleep 10
|
||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS_RETRY} || \
|
||||
( sleep 10; ${SANITYCHECK} ${SANITYCHECK_OPTIONS_RETRY}; )
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
rm test_file.txt
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue