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
|
- export CCACHE_DIR=${SHIPPABLE_BUILD_DIR}/ccache/.ccache
|
||||||
- >
|
- >
|
||||||
if [ "$IS_PULL_REQUEST" = "true" ]; then
|
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
|
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;
|
fi;
|
||||||
- ccache -s
|
- ccache -s
|
||||||
on_failure:
|
on_failure:
|
||||||
- >
|
- >
|
||||||
if [ -f "$HOME/.cache/zephyr/ToolchainCapabilityDatabase.cmake" ]; then
|
if [ "$IS_PULL_REQUEST" = "true" ]; then
|
||||||
echo "Dumping the capability database in case we are affected by #9992"
|
./scripts/ci/run_ci.sh -f -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -p;
|
||||||
cat $HOME/.cache/zephyr/ToolchainCapabilityDatabase.cmake
|
else
|
||||||
fi;
|
./scripts/ci/run_ci.sh -f -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS};
|
||||||
- rm -rf ccache $HOME/.cache/zephyr
|
fi;
|
||||||
- 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;
|
|
||||||
on_success:
|
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
|
if [ "$IS_PULL_REQUEST" = "true" ]; then
|
||||||
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
|
./scripts/ci/run_ci.sh -s -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS} -p;
|
||||||
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;
|
else
|
||||||
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;
|
./scripts/ci/run_ci.sh -s -b ${PULL_REQUEST_BASE_BRANCH} -r origin -m ${MATRIX_BUILD} -M ${MATRIX_BUILDS};
|
||||||
rm lcov.pre.info;
|
fi;
|
||||||
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;
|
|
||||||
|
|
||||||
integrations:
|
integrations:
|
||||||
notifications:
|
notifications:
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
#
|
#
|
||||||
# The script can be run locally using for exmaple:
|
# The script can be run locally using for exmaple:
|
||||||
# ./scripts/ci/run_ci.sh -b master -r upstream -p
|
# ./scripts/ci/run_ci.sh -b master -r upstream -p
|
||||||
|
|
||||||
|
set -v
|
||||||
|
|
||||||
source zephyr-env.sh
|
source zephyr-env.sh
|
||||||
|
|
||||||
SANITYCHECK_OPTIONS=" --inline-logs --enable-coverage -N"
|
SANITYCHECK_OPTIONS=" --inline-logs --enable-coverage -N"
|
||||||
|
@ -25,55 +28,141 @@ SANITYCHECK="${ZEPHYR_BASE}/scripts/sanitycheck"
|
||||||
MATRIX_BUILDS=1
|
MATRIX_BUILDS=1
|
||||||
MATRIX=1
|
MATRIX=1
|
||||||
|
|
||||||
while getopts ":pm:b:B:r:M:" opt; do
|
while getopts ":pm:b:r:M:cfsB:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
p)
|
c)
|
||||||
echo "Testing a Pull Request." >&2
|
echo "Execute CI" >&2
|
||||||
PULL_REQUEST=1
|
MAIN_CI=1
|
||||||
;;
|
;;
|
||||||
m)
|
s)
|
||||||
echo "Running on Matrix $OPTARG" >&2
|
echo "Success" >&2
|
||||||
MATRIX=$OPTARG
|
SUCCESS=1
|
||||||
;;
|
;;
|
||||||
M)
|
f)
|
||||||
echo "Running a matrix of $OPTARG slaves" >&2
|
echo "Failure" >&2
|
||||||
MATRIX_BUILDS=$OPTARG
|
FAILURE=1
|
||||||
;;
|
;;
|
||||||
b)
|
p)
|
||||||
echo "Base Branch: $OPTARG" >&2
|
echo "Testing a Pull Request." >&2
|
||||||
BRANCH=$OPTARG
|
PULL_REQUEST=1
|
||||||
;;
|
;;
|
||||||
B)
|
m)
|
||||||
echo "bsim BT tests xml results file: $OPTARG" >&2
|
echo "Running on Matrix $OPTARG" >&2
|
||||||
BSIM_BT_TEST_RESULTS_FILE=$OPTARG
|
MATRIX=$OPTARG
|
||||||
;;
|
;;
|
||||||
r)
|
M)
|
||||||
echo "Remote: $OPTARG" >&2
|
echo "Running a matrix of $OPTARG slaves" >&2
|
||||||
REMOTE=$OPTARG
|
MATRIX_BUILDS=$OPTARG
|
||||||
;;
|
;;
|
||||||
\?)
|
b)
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
echo "Base Branch: $OPTARG" >&2
|
||||||
;;
|
BRANCH=$OPTARG
|
||||||
esac
|
;;
|
||||||
|
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
|
done
|
||||||
|
|
||||||
DOC_MATRIX=${MATRIX_BUILDS}
|
DOC_MATRIX=${MATRIX_BUILDS}
|
||||||
|
|
||||||
if [ -z "$BRANCH" ]; then
|
if [ -n "$MAIN_CI" ]; then
|
||||||
echo "No base branch given"
|
if [ -z "$BRANCH" ]; then
|
||||||
exit
|
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
|
fi
|
||||||
|
|
||||||
if [ -n "$PULL_REQUEST" ]; then
|
function handle_coverage() {
|
||||||
git rebase $REMOTE/${BRANCH};
|
# this is for shippable coverage reports
|
||||||
fi
|
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() {
|
function build_btsim() {
|
||||||
NRF_HW_MODELS_VERSION=`cat boards/posix/nrf52_bsim/hw_models_version`
|
NRF_HW_MODELS_VERSION=`cat boards/posix/nrf52_bsim/hw_models_version`
|
||||||
|
@ -105,60 +194,72 @@ function run_bsim_bt_tests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_docs() {
|
function build_docs() {
|
||||||
echo "- Building Documentation";
|
echo "- Building Documentation";
|
||||||
make htmldocs
|
make htmldocs
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
echo "Documentation build failed";
|
echo "Documentation build failed";
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
if [ -s doc/_build/doc.warnings ]; then
|
if [ -s doc/_build/doc.warnings ]; then
|
||||||
echo " => New documentation warnings/errors";
|
echo " => New documentation warnings/errors";
|
||||||
cp doc/_build/doc.warnings doc.warnings
|
cp doc/_build/doc.warnings doc.warnings
|
||||||
fi
|
fi
|
||||||
echo "- Verify commit message, coding style, doc build";
|
echo "- Verify commit message, coding style, doc build";
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_tests_to_run() {
|
function get_tests_to_run() {
|
||||||
./scripts/ci/get_modified_tests.py --commits ${COMMIT_RANGE} > modified_tests.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;
|
./scripts/ci/get_modified_boards.py --commits ${COMMIT_RANGE} > modified_boards.args;
|
||||||
|
|
||||||
if [ -s modified_boards.args ]; then
|
if [ -s modified_boards.args ]; then
|
||||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_boards.args --save-tests test_file.txt || exit 1;
|
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_boards.args --save-tests test_file.txt || exit 1;
|
||||||
fi
|
fi
|
||||||
if [ -s modified_tests.args ]; then
|
if [ -s modified_tests.args ]; then
|
||||||
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_tests.args --save-tests test_file.txt || exit 1;
|
${SANITYCHECK} ${SANITYCHECK_OPTIONS} +modified_tests.args --save-tests test_file.txt || exit 1;
|
||||||
fi
|
fi
|
||||||
rm -f modified_tests.args modified_boards.args;
|
rm -f modified_tests.args modified_boards.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -z "${BSIM_OUT_PATH}" ]; then
|
if [ -n "$MAIN_CI" ]; then
|
||||||
# Build BT Simulator
|
|
||||||
build_btsim
|
|
||||||
|
|
||||||
# Run BLE tests in simulator on the 1st CI instance:
|
if [ ! -z "${BSIM_OUT_PATH}" ]; then
|
||||||
if [ "$MATRIX" = "1" ]; then
|
echo "Build BT simulator tests"
|
||||||
run_bsim_bt_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
|
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
|
else
|
||||||
echo "Skipping BT simulator tests"
|
echo "Nothing to do"
|
||||||
fi
|
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