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 - pre-commit run --all --show-diff-on-failure --verbose --color always
pytest: pytest:
image:
name: python:$PYTHON_VERSION
stage: test stage: test
tags: tags:
- shell - cie-oow-dind-runner
only: only:
- merge_requests - merge_requests
- "main" - "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+)\%/' coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)\%/'
script: before_script:
- python3 -m venv ./.gitlab-ci-venv
- source ./.gitlab-ci-venv/bin/activate
# - pip install --upgrade pip
- pip install poetry - pip install poetry
- poetry --version - export PATH="$HOME/.local/bin:$PATH"
- poetry install -v - poetry install --all-extras
- echo $PATH script:
- echo $PYTHONPATH - poetry run pytest -vv -x --cov=odoo_openupgrade_wizard
- poetry run pytest --version parallel:
- poetry run pytest --verbosity=2 --exitfirst --cov odoo_openupgrade_wizard matrix:
- PYTHON_VERSION:
- "3.7"
- "3.8"
- "3.9"
build: build:
stage: 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