I have a gitlab ci pipeline which basically do some stuff on the enviornment ( install python and other packages) then it simply run tox
in order to run some tests.
stages:
- check
before_script:
# here you can run any commands before the pipelines start
- apt-get -qq update && apt-get -qq install -y python3.9
- apt-get install -y libpq-dev && apt-get install -y python3.9-dev
- apt-get install -y build-essential && apt-get install -y gcc && apt-get install -y postgresql
- apt-get install -y postgresql-contrib && apt-get install -y ffmpeg libsm6 libxext6
- apt-get install -y git
- pip install tox
check:
stage: check
image: gitlab.*****.com:****/*****
environment: prod
services:
- name: docker:19.03.8-dind #20.10.7
alias: docker
only:
- master
script:
- |
echo "
machine gitlab.*****.com
login gitlab-ci-token
password $CI_JOB_TOKEN
" > ~/.netrc
- tox
This is my tox.ini
:
[tox]
envlist =
{python3.9}
[testenv]
passenv = *
setenv =
AIRFLOW_HOME = /airflow_home
deps=
pytest
-r{toxinidir}/requirements.txt
commands=
pytest
The problem is that when tox
is building the env and installing the packages specified in the requirements.txt
it returns a ReadTimeOutError
.
I've tried to delete tox
and simply run a pip install -r requiremenets --default-timeout=200
and it worked.
So the problem seems to be a timeout.
I'd like to define a timeout
but i don't want to discard tox.
How can i do it?
tox is using pip under the hood, so you can use the same options, preferable as environment variables.
So, following https://pip.pypa.io/en/stable/topics/configuration/#environment-variables you need to convert --default-timeout
into the PIP_DEFAULT_TIMEOUT
variable.
You can use this variable either by setting it in CI and then use the passenv
directive in your tox.ini
, or you can set it directly in tox.ini
via the setenv
directive.
Relevant documentation for tox: