Use docker-in-docker to run tests

Cortesy @maisim.

This commit allow to use docker-in-docker to run tests.

Also it will run the tests on python version defined in the
PYTHON_VERSION array. The tox.ini file is not needed anymore.
Test locally can be run on the user python version, and check against
several python version will be done by the CI.

Notice the ODOO_RPC_URL environment variable which allow to mock the RPC
request to the right url.

This tests needs to be run on custom privileged runner.
! Using gitlab runner does not work !
This commit is contained in:
Rémy Taymans 2023-11-09 16:41:01 +01:00
parent 6a36c97ee4
commit 0dc011684d
2 changed files with 22 additions and 21 deletions

View File

@ -15,24 +15,35 @@ pre-commit:
- pre-commit run --all --show-diff-on-failure --verbose --color always
pytest:
image:
name: python:$PYTHON_VERSION
stage: test
tags:
- shell
- cie-oow-dind-runner
only:
- merge_requests
- "main"
services:
- name: docker:dind
alias: dind
variables:
ODOO_RPC_URL: dind
DOCKER_HOST: tcp://dind:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)\%/'
script:
- python3 -m venv ./.gitlab-ci-venv
- source ./.gitlab-ci-venv/bin/activate
# - pip install --upgrade pip
before_script:
- pip install poetry
- poetry --version
- poetry install -v
- echo $PATH
- echo $PYTHONPATH
- poetry run pytest --version
- poetry run pytest --verbosity=2 --exitfirst --cov odoo_openupgrade_wizard
- export PATH="$HOME/.local/bin:$PATH"
- poetry install --all-extras
script:
- poetry run pytest -vv -x --cov=odoo_openupgrade_wizard
parallel:
matrix:
- PYTHON_VERSION:
- "3.7"
- "3.8"
- "3.9"
build:
stage: build

10
tox.ini
View File

@ -1,10 +0,0 @@
[tox]
isolated_build = true
skipsdist = True
envlist = py36, py37, py38, py39
[testenv]
whitelist_externals = poetry
commands =
poetry install -v
poetry run pytest -vv