Skip to content

Commit

Permalink
be more like ansible's shippable.sh
Browse files Browse the repository at this point in the history
ci_coverage
  • Loading branch information
jillr committed May 16, 2020
1 parent 9e1e143 commit e9d6bca
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions tests/utils/shippable/shippable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ else
export UNSTABLE=""
fi

virtualenv --python /usr/bin/python3.7 ~/ansible-venv
set +ux
. ~/ansible-venv/bin/activate
set -ux

pip install setuptools==44.1.0
pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check

Expand Down Expand Up @@ -100,20 +95,42 @@ cd "${TEST_DIR}"

function cleanup
{
# if [ -d tests/output/coverage/ ]; then
# if find tests/output/coverage/ -mindepth 1 -name '.*' -prune -o -print -quit | grep -q .; then
# # for complete on-demand coverage generate a report for all files with no coverage on the "other" job so we only have one copy
# if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ] && [ "${test}" == "sanity/1" ]; then
# stub="--stub"
# else
# stub=""
# fi
# for complete on-demand coverage generate a report for all files with no coverage on the "sanity/5" job so we only have one copy
if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ] && [ "${test}" == "sanity/5" ]; then
stub="--stub"
# trigger coverage reporting for stubs even if no other coverage data exists
mkdir -p tests/output/coverage/
else
stub=""
fi

if [ -d tests/output/coverage/ ]; then
if find tests/output/coverage/ -mindepth 1 -name '.*' -prune -o -print -quit | grep -q .; then
# for complete on-demand coverage generate a report for all files with no coverage on the "other" job so we only have one copy
if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ] && [ "${test}" == "sanity/1" ]; then
stub="--stub"
else
stub=""
fi
process_coverage='yes' # process existing coverage files
elif [ "${stub}" ]; then
process_coverage='yes' # process coverage when stubs are enabled
else
process_coverage=''
fi

if [ "${process_coverage}" ]; then
# use python 3.7 for coverage to avoid running out of memory during coverage xml processing
# only use it for coverage to avoid the additional overhead of setting up a virtual environment for a potential no-op job
virtualenv --python /usr/bin/python3.7 ~/ansible-venv
set +ux
. ~/ansible-venv/bin/activate
set -ux

# shellcheck disable=SC2086
mkdir -p tests/output/reports/
ansible-test coverage xml --color --requirements --group-by command --group-by version ${stub:+"$stub"}
ls tests/output/
ls tests/output/reports/
cp -a tests/output/reports/coverage=*.xml "$SHIPPABLE_RESULT_DIR/codecoverage/"

# analyze and capture code coverage aggregated by integration test target
Expand Down

0 comments on commit e9d6bca

Please sign in to comment.