Skip to content
Snippets Groups Projects

CI fix issue with gitlab timeout

Merged Mateusz Żebrak requested to merge mzebrak/run-pytest-anchor into develop
+ 1
53
@@ -38,7 +38,7 @@ include:
ref: 60f81ebd60dfb950361525d4e06b4a3f1d0b525f
file: '/scripts/ci-helpers/prepare_data_image_job.yml'
- project: 'hive/common-ci-configuration'
ref: 32073829224f333726bb99e01e4d9787f299b4dd
ref: 1f5ef20de47ac89dc4c61f5745c728f19cde022b
file: '/templates/python_projects.gitlab-ci.yml'
image: ${CI_BASE_IMAGE}
@@ -96,58 +96,6 @@ build_wheel:
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| TESTS |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.run-pytest: &run-pytest
# Usage:
# 1. Add - *run-pytest to your script section.
# 2. Set the appropriate values for:
# - PYTEST_TIMEOUT_MINUTES (required, should be set on the job level)
# - PYTEST_NUMBER_OF_PROCESSES (default: defined via global CI variable, could be overridden on the job level)
# - PYTEST_LOG_DURATIONS (default: defined via global CI variable, could be overridden on the job level)
# - PYTEST_ARGS (default: "" - empty, should be set on the job level)
# - PYTEST_JUNIT_REPORT (default: "report.xml")
# Best to export PYTEST_ARGS as array (e.g. `export PYTEST_ARGS=(-m testnet)`). In some cases setting PYTEST_ARGS as string will fail.
- |
PYTEST_FULL_CMD=("pytest")
if [ -z "${PYTEST_TIMEOUT_MINUTES}" ]; then
echo "Required variable PYTEST_TIMEOUT_MINUTES was not set!"
exit 22
fi
# add pytest timeout to prevent gitlab CI killing job on timeout without any artifacts and no info about tests
PYTEST_FULL_CMD+=("--timeout=$((${PYTEST_TIMEOUT_MINUTES} * 60))")
if [[ ${PYTEST_NUMBER_OF_PROCESSES} == "auto" || ${PYTEST_NUMBER_OF_PROCESSES} -gt 1 ]]; then
PYTEST_FULL_CMD+=("-n=${PYTEST_NUMBER_OF_PROCESSES}")
fi
# durations=0 makes pytest print all tests durations
if [ ${PYTEST_LOG_DURATIONS:=0} -ge 1 ]; then
PYTEST_FULL_CMD+=("--durations=0")
fi
if [ -z "${PYTEST_JUNIT_REPORT}" ]; then
JUNIT_REPORT="report.xml"
else
JUNIT_REPORT="${PYTEST_JUNIT_REPORT}"
fi
PYTEST_FULL_CMD+=("--junitxml=${JUNIT_REPORT}")
PYTEST_FULL_CMD+=("${PYTEST_ARGS[@]}")
echo "Launching pytest with:
- timeout (minutes): ${PYTEST_TIMEOUT_MINUTES}
- processes: ${PYTEST_NUMBER_OF_PROCESSES}
- log durations: ${PYTEST_LOG_DURATIONS}
- additional arguments: ${PYTEST_ARGS[@]}"
echo
echo "Full pytest command:"
echo "${PYTEST_FULL_CMD[@]}"
# add extra bash timeout
timeout $(((${PYTEST_TIMEOUT_MINUTES} + 2) * 60)) "${PYTEST_FULL_CMD[@]}"
.testing:
stage: tests
extends: .project_develop_configuration_template
Loading