Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout coverage/pytest with sigint to help debug CI timeout issues #2827

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export PYRIGHT_PYTHON_IGNORE_WARNINGS=1
echo "::group::Environment"
uname -a
env | sort
date
echo "::endgroup::"

# Curl's built-in retry system is not very robust; it gives up on lots of
Expand Down Expand Up @@ -126,9 +127,34 @@ else
# support subprocess spawning with coverage.py
echo "import coverage; coverage.process_startup()" | tee -a "$INSTALLDIR/../sitecustomize.py"

# set the location of .coveragerc for multi-process coverage to work
COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml

PYTEST_CMD="pytest -r a -p trio._tests.pytest_plugin --junitxml=../test-results.xml --run-slow --verbose --durations=10 $flags ${INSTALLDIR}"

RUN_TESTS="coverage run --rcfile=../pyproject.toml -m $PYTEST_CMD"

# timeout can be changed with an environment variable, but if empty or unset
# default to 9m to not hit 10m limit
if [ -z "$TESTS_TIMEOUT" ]; then
TESTS_TIMEOUT=7m
fi

# if available, timeout coverage/pytest with SIGINT before the CI runner kills it, to
# get in-progress data and print out the slowest tests
if type timeout > /dev/null; then
RUN_TESTS="timeout --signal=INT $TESTS_TIMEOUT $RUN_TESTS"
elif type gtimeout > /dev/null; then
RUN_TESTS="gtimeout --signal=INT $TESTS_TIMEOUT $RUN_TESTS"
fi

# print datetime
date

echo "::endgroup::"
echo "::group:: Run Tests"
if COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml coverage run --rcfile=../pyproject.toml -m pytest -r a -p trio._tests.pytest_plugin --junitxml=../test-results.xml --run-slow ${INSTALLDIR} --verbose --durations=10 $flags; then

if $RUN_TESTS; then
PASSED=true
else
PASSED=false
Expand Down