2019-04-04 16:07:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
# The filesystem location of the root of a virtualenv we can use to get/build
|
|
|
|
# wheels.
|
|
|
|
BOOTSTRAP_VENV="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
# The filesystem location of the root of the project source. We need this to
|
|
|
|
# know what wheels to get/build, of course.
|
|
|
|
PROJECT_ROOT="$1"
|
|
|
|
shift
|
2018-06-15 18:21:33 +00:00
|
|
|
|
2019-06-25 18:50:42 +00:00
|
|
|
ALLOWED_FAILURE="$1"
|
|
|
|
shift
|
|
|
|
|
2018-07-06 15:28:52 +00:00
|
|
|
ARTIFACTS=$1
|
|
|
|
shift
|
|
|
|
|
2018-06-15 19:40:50 +00:00
|
|
|
TAHOE_LAFS_TOX_ENVIRONMENT=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
TAHOE_LAFS_TOX_ARGS=$1
|
2018-06-15 20:02:49 +00:00
|
|
|
shift || :
|
2018-06-15 19:40:50 +00:00
|
|
|
|
2019-01-24 21:04:26 +00:00
|
|
|
if [ -n "${ARTIFACTS}" ]; then
|
|
|
|
# If given an artifacts path, prepare to have some artifacts created
|
|
|
|
# there. The integration tests don't produce any artifacts; that is the
|
|
|
|
# case where we expect not to end up here.
|
2018-07-06 15:32:19 +00:00
|
|
|
|
2019-01-24 21:04:26 +00:00
|
|
|
# Make sure we can actually write things to this directory.
|
2019-04-04 17:23:26 +00:00
|
|
|
mkdir -p "${ARTIFACTS}"
|
2018-07-06 16:06:38 +00:00
|
|
|
|
2019-01-24 21:04:26 +00:00
|
|
|
SUBUNIT2="${ARTIFACTS}"/results.subunit2
|
|
|
|
|
|
|
|
# Use an intermediate directory here because CircleCI extracts some label
|
|
|
|
# information from its name.
|
|
|
|
JUNITXML="${ARTIFACTS}"/junit/unittests/results.xml
|
2019-04-04 19:36:08 +00:00
|
|
|
else
|
|
|
|
SUBUNIT2=""
|
|
|
|
JUNITXML=""
|
2019-01-24 21:04:26 +00:00
|
|
|
fi
|
2018-07-06 16:06:38 +00:00
|
|
|
|
2019-08-13 19:57:29 +00:00
|
|
|
# A prefix for the test command that ensure it will exit after no more than a
|
|
|
|
# certain amount of time. Ideally, we would only enforce a "silent" period
|
|
|
|
# timeout but there isn't obviously a ready-made tool for that. The test
|
|
|
|
# suite only takes about 5 - 6 minutes on CircleCI right now. 15 minutes
|
|
|
|
# seems like a moderately safe window.
|
|
|
|
#
|
|
|
|
# This is primarily aimed at catching hangs on the PyPy job which runs for
|
|
|
|
# about 21 minutes and then gets killed by CircleCI in a way that fails the
|
|
|
|
# job and bypasses our "allowed failure" logic.
|
|
|
|
TIMEOUT="timeout --kill-after 1m 15m"
|
|
|
|
|
2018-06-15 18:21:33 +00:00
|
|
|
# Run the test suite as a non-root user. This is the expected usage some
|
|
|
|
# small areas of the test suite assume non-root privileges (such as unreadable
|
|
|
|
# files being unreadable).
|
|
|
|
#
|
|
|
|
# Also run with /tmp as a workdir because the non-root user won't be able to
|
|
|
|
# create the tox working filesystem state in the source checkout because it is
|
|
|
|
# owned by root.
|
2018-07-08 22:49:45 +00:00
|
|
|
#
|
|
|
|
# Send the output directly to a file because transporting the binary subunit2
|
|
|
|
# via tox and then scraping it out is hideous and failure prone.
|
2019-04-04 16:52:35 +00:00
|
|
|
export SUBUNITREPORTER_OUTPUT_PATH="${SUBUNIT2}"
|
|
|
|
export TAHOE_LAFS_TRIAL_ARGS="--reporter=subunitv2-file --rterrors"
|
|
|
|
export PIP_NO_INDEX="1"
|
|
|
|
|
2019-06-25 18:50:42 +00:00
|
|
|
if [ "${ALLOWED_FAILURE}" = "yes" ]; then
|
2019-06-25 19:11:20 +00:00
|
|
|
alternative="true"
|
2019-06-25 18:50:42 +00:00
|
|
|
else
|
2019-06-25 19:11:20 +00:00
|
|
|
alternative="false"
|
2019-06-25 19:02:34 +00:00
|
|
|
fi
|
2019-06-25 18:50:42 +00:00
|
|
|
|
2019-08-13 19:57:29 +00:00
|
|
|
${TIMEOUT} ${BOOTSTRAP_VENV}/bin/tox \
|
2019-04-04 16:07:32 +00:00
|
|
|
-c ${PROJECT_ROOT}/tox.ini \
|
2018-07-10 19:43:30 +00:00
|
|
|
--workdir /tmp/tahoe-lafs.tox \
|
|
|
|
-e "${TAHOE_LAFS_TOX_ENVIRONMENT}" \
|
2019-06-25 18:50:42 +00:00
|
|
|
${TAHOE_LAFS_TOX_ARGS} || "${alternative}"
|
2018-07-05 18:19:23 +00:00
|
|
|
|
2019-01-24 21:04:26 +00:00
|
|
|
if [ -n "${ARTIFACTS}" ]; then
|
|
|
|
# Create a junitxml results area.
|
|
|
|
mkdir -p "$(dirname "${JUNITXML}")"
|
2019-06-25 19:20:55 +00:00
|
|
|
${BOOTSTRAP_VENV}/bin/subunit2junitxml < "${SUBUNIT2}" > "${JUNITXML}" || "${alternative}"
|
2019-01-24 21:04:26 +00:00
|
|
|
fi
|