source: trunk/.circleci/run-tests.sh

Last change on this file was 2787554a, checked in by Itamar Turner-Trauring <itamar@…>, at 2020-09-04T16:05:42Z

Make sure CircleCI see progress output from subunitv2 reporter.

  • Property mode set to 100755
File size: 3.0 KB
Line 
1#!/bin/bash
2
3# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
4set -euxo pipefail
5
6# The filesystem location of the root of a virtualenv we can use to get/build
7# wheels.
8BOOTSTRAP_VENV="$1"
9shift
10
11# The filesystem location of the root of the project source.  We need this to
12# know what wheels to get/build, of course.
13PROJECT_ROOT="$1"
14shift
15
16ALLOWED_FAILURE="$1"
17shift
18
19ARTIFACTS=$1
20shift
21
22TAHOE_LAFS_TOX_ENVIRONMENT=$1
23shift
24
25TAHOE_LAFS_TOX_ARGS=$1
26shift || :
27
28if [ -n "${ARTIFACTS}" ]; then
29    # If given an artifacts path, prepare to have some artifacts created
30    # there.  The integration tests don't produce any artifacts; that is the
31    # case where we expect not to end up here.
32
33    # Make sure we can actually write things to this directory.
34    mkdir -p "${ARTIFACTS}"
35
36    SUBUNIT2="${ARTIFACTS}"/results.subunit2
37
38    # Use an intermediate directory here because CircleCI extracts some label
39    # information from its name.
40    JUNITXML="${ARTIFACTS}"/junit/unittests/results.xml
41else
42    SUBUNIT2=""
43    JUNITXML=""
44fi
45
46# A prefix for the test command that ensure it will exit after no more than a
47# certain amount of time.  Ideally, we would only enforce a "silent" period
48# timeout but there isn't obviously a ready-made tool for that.  The test
49# suite only takes about 5 - 6 minutes on CircleCI right now.  15 minutes
50# seems like a moderately safe window.
51#
52# This is primarily aimed at catching hangs on the PyPy job which runs for
53# about 21 minutes and then gets killed by CircleCI in a way that fails the
54# job and bypasses our "allowed failure" logic.
55TIMEOUT="timeout --kill-after 1m 15m"
56
57# Run the test suite as a non-root user.  This is the expected usage some
58# small areas of the test suite assume non-root privileges (such as unreadable
59# files being unreadable).
60#
61# Also run with /tmp as a workdir because the non-root user won't be able to
62# create the tox working filesystem state in the source checkout because it is
63# owned by root.
64#
65# Send the output directly to a file because transporting the binary subunit2
66# via tox and then scraping it out is hideous and failure prone.
67export SUBUNITREPORTER_OUTPUT_PATH="${SUBUNIT2}"
68export TAHOE_LAFS_TRIAL_ARGS="${TAHOE_LAFS_TRIAL_ARGS:---reporter=subunitv2-file --rterrors}"
69export PIP_NO_INDEX="1"
70
71# Make output unbuffered, so progress reports from subunitv2-file get streamed
72# and notify CircleCI we're still alive.
73export PYTHONUNBUFFERED=1
74
75if [ "${ALLOWED_FAILURE}" = "yes" ]; then
76    alternative="true"
77else
78    alternative="false"
79fi
80
81${TIMEOUT} ${BOOTSTRAP_VENV}/bin/tox \
82    -c ${PROJECT_ROOT}/tox.ini \
83    --workdir /tmp/tahoe-lafs.tox \
84    -e "${TAHOE_LAFS_TOX_ENVIRONMENT}" \
85    ${TAHOE_LAFS_TOX_ARGS} || "${alternative}"
86
87if [ -n "${ARTIFACTS}" ]; then
88    if [ ! -e "${SUBUNIT2}" ]; then
89        echo "subunitv2 output file does not exist: ${SUBUNIT2}"
90        exit 1
91    fi
92
93    # Create a junitxml results area.
94    mkdir -p "$(dirname "${JUNITXML}")"
95    "${BOOTSTRAP_VENV}"/bin/subunit2junitxml < "${SUBUNIT2}" > "${JUNITXML}" || "${alternative}"
96fi
Note: See TracBrowser for help on using the repository browser.