Merge branch 'update_ci' into 'main'
New CI with docker-in-docker See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!48
This commit is contained in:
commit
1f720c667e
|
|
@ -5,9 +5,8 @@ stages:
|
||||||
- release
|
- release
|
||||||
|
|
||||||
pre-commit:
|
pre-commit:
|
||||||
|
image: python
|
||||||
stage: lint
|
stage: lint
|
||||||
tags:
|
|
||||||
- shell
|
|
||||||
only:
|
only:
|
||||||
- merge_requests
|
- merge_requests
|
||||||
before_script:
|
before_script:
|
||||||
|
|
@ -16,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
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
exclude: '^tests/data/output_expected/'
|
exclude: '^tests/data/output_expected/'
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.4.0
|
rev: v4.5.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
|
|
@ -19,15 +19,15 @@ repos:
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- id: check-symlinks
|
- id: check-symlinks
|
||||||
- repo: https://github.com/pre-commit/mirrors-isort
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
rev: v5.7.0
|
rev: v5.10.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 22.3.0
|
rev: 23.11.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: "3.9.2"
|
rev: "6.1.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
# - repo: https://gitlab.com/smop/pre-commit-hooks
|
# - repo: https://gitlab.com/smop/pre-commit-hooks
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ def docker_build(ctx, versions):
|
||||||
|
|
||||||
# Build images for each odoo version
|
# Build images for each odoo version
|
||||||
for odoo_version in get_odoo_versions_from_options(ctx, versions):
|
for odoo_version in get_odoo_versions_from_options(ctx, versions):
|
||||||
|
|
||||||
odoo_requirement_file_path = (
|
odoo_requirement_file_path = (
|
||||||
get_odoo_env_path(ctx, odoo_version) / "src/odoo/requirements.txt"
|
get_odoo_env_path(ctx, odoo_version) / "src/odoo/requirements.txt"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_writable
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def generate_module_analysis(ctx, step, database, modules):
|
def generate_module_analysis(ctx, step, database, modules):
|
||||||
|
|
||||||
migration_steps = get_migration_steps_from_options(ctx, step - 1, step)
|
migration_steps = get_migration_steps_from_options(ctx, step - 1, step)
|
||||||
|
|
||||||
initial_step = migration_steps[0].copy()
|
initial_step = migration_steps[0].copy()
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ def database_option_required(function):
|
||||||
|
|
||||||
|
|
||||||
def get_odoo_versions_from_options(ctx, versions_arg):
|
def get_odoo_versions_from_options(ctx, versions_arg):
|
||||||
|
|
||||||
if not versions_arg:
|
if not versions_arg:
|
||||||
return ctx.obj["config"]["odoo_versions"]
|
return ctx.obj["config"]["odoo_versions"]
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ from odoo_openupgrade_wizard.tools.tools_postgres import (
|
||||||
@database_option_required
|
@database_option_required
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def upgrade(ctx, first_step, last_step, database):
|
def upgrade(ctx, first_step, last_step, database):
|
||||||
|
|
||||||
migration_steps = get_migration_steps_from_options(
|
migration_steps = get_migration_steps_from_options(
|
||||||
ctx, first_step, last_step
|
ctx, first_step, last_step
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,6 @@ RUN pip3 install --upgrade pip \
|
||||||
# <OOW> Get local user id and set it to the odoo user
|
# <OOW> Get local user id and set it to the odoo user
|
||||||
ARG LOCAL_USER_ID
|
ARG LOCAL_USER_ID
|
||||||
|
|
||||||
RUN useradd --uid $LOCAL_USER_ID odoo
|
RUN useradd --uid $LOCAL_USER_ID --non-unique odoo
|
||||||
|
|
||||||
USER odoo
|
USER odoo
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,6 @@ RUN pip3 install --upgrade pip \
|
||||||
# <OOW> Get local user id and set it to the odoo user
|
# <OOW> Get local user id and set it to the odoo user
|
||||||
ARG LOCAL_USER_ID
|
ARG LOCAL_USER_ID
|
||||||
|
|
||||||
RUN useradd --uid $LOCAL_USER_ID odoo
|
RUN useradd --uid $LOCAL_USER_ID --non-unique odoo
|
||||||
|
|
||||||
USER odoo
|
USER odoo
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,6 @@ RUN pip3 install --upgrade pip \
|
||||||
# <OOW> Get local user id and set it to the odoo user
|
# <OOW> Get local user id and set it to the odoo user
|
||||||
ARG LOCAL_USER_ID
|
ARG LOCAL_USER_ID
|
||||||
|
|
||||||
RUN useradd --uid $LOCAL_USER_ID odoo
|
RUN useradd --uid $LOCAL_USER_ID --non-unique odoo
|
||||||
|
|
||||||
USER odoo
|
USER odoo
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,6 @@ RUN pip3 install --upgrade pip \
|
||||||
# <OOW> Get local user id and set it to the odoo user
|
# <OOW> Get local user id and set it to the odoo user
|
||||||
ARG LOCAL_USER_ID
|
ARG LOCAL_USER_ID
|
||||||
|
|
||||||
RUN useradd --uid $LOCAL_USER_ID odoo
|
RUN useradd --uid $LOCAL_USER_ID --non-unique odoo
|
||||||
|
|
||||||
USER odoo
|
USER odoo
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,6 @@ RUN pip3 install --upgrade pip \
|
||||||
# <OOW> Get local user id and set it to the odoo user
|
# <OOW> Get local user id and set it to the odoo user
|
||||||
ARG LOCAL_USER_ID
|
ARG LOCAL_USER_ID
|
||||||
|
|
||||||
RUN useradd --uid $LOCAL_USER_ID odoo
|
RUN useradd --uid $LOCAL_USER_ID --non-unique odoo
|
||||||
|
|
||||||
USER odoo
|
USER odoo
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,6 @@ RUN pip3 install --upgrade pip \
|
||||||
# <OOW> Get local user id and set it to the odoo user
|
# <OOW> Get local user id and set it to the odoo user
|
||||||
ARG LOCAL_USER_ID
|
ARG LOCAL_USER_ID
|
||||||
|
|
||||||
RUN useradd --uid $LOCAL_USER_ID odoo
|
RUN useradd --uid $LOCAL_USER_ID --non-unique odoo
|
||||||
|
|
||||||
USER odoo
|
USER odoo
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import time
|
|
||||||
|
|
||||||
import docker
|
import docker
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
|
@ -88,15 +86,6 @@ def run_container(
|
||||||
if detach:
|
if detach:
|
||||||
logger.debug("Container %s launched." % image_name)
|
logger.debug("Container %s launched." % image_name)
|
||||||
elif auto_remove:
|
elif auto_remove:
|
||||||
# Workaround to avoid
|
|
||||||
# "Conflict. The container name xxx is already in use"
|
|
||||||
# Because it seems that the container name is not freed when the
|
|
||||||
# run command completes
|
|
||||||
while client.containers.list(
|
|
||||||
all=True, filters={"name": container_name}
|
|
||||||
):
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
logger.debug("Container closed.")
|
logger.debug("Container closed.")
|
||||||
|
|
||||||
return container
|
return container
|
||||||
|
|
@ -130,6 +119,7 @@ def kill_container(container_name):
|
||||||
containers = client.containers.list(
|
containers = client.containers.list(
|
||||||
all=True,
|
all=True,
|
||||||
filters={"name": container_name},
|
filters={"name": container_name},
|
||||||
|
ignore_removed=True,
|
||||||
)
|
)
|
||||||
except docker.errors.NotFound as err:
|
except docker.errors.NotFound as err:
|
||||||
logger.debug(f"Cannot kill container {container_name}: " + str(err))
|
logger.debug(f"Cannot kill container {container_name}: " + str(err))
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,6 @@ def generate_odoo_command(
|
||||||
stop_after_init: bool = False,
|
stop_after_init: bool = False,
|
||||||
shell: bool = False,
|
shell: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
|
|
||||||
odoo_env_path = get_odoo_env_path(ctx, migration_step["version"])
|
odoo_env_path = get_odoo_env_path(ctx, migration_step["version"])
|
||||||
|
|
||||||
# Compute 'server_wide_modules'
|
# Compute 'server_wide_modules'
|
||||||
|
|
@ -295,7 +294,6 @@ def execute_click_odoo_python_files(
|
||||||
python_files: list = [],
|
python_files: list = [],
|
||||||
execution_context: str = False,
|
execution_context: str = False,
|
||||||
):
|
):
|
||||||
|
|
||||||
if not python_files:
|
if not python_files:
|
||||||
# Get post-migration python scripts to execute
|
# Get post-migration python scripts to execute
|
||||||
script_folder = get_script_folder(ctx, migration_step)
|
script_folder = get_script_folder(ctx, migration_step)
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ from loguru import logger
|
||||||
|
|
||||||
# Wait for the launch of odoo instance 60 seconds
|
# Wait for the launch of odoo instance 60 seconds
|
||||||
_ODOO_RPC_MAX_TRY = 60
|
_ODOO_RPC_MAX_TRY = 60
|
||||||
|
_ODOO_RPC_URL = "0.0.0.0"
|
||||||
|
|
||||||
|
|
||||||
class OdooInstance:
|
class OdooInstance:
|
||||||
|
|
||||||
env = False
|
env = False
|
||||||
version = False
|
version = False
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ class OdooInstance:
|
||||||
# Connection
|
# Connection
|
||||||
try:
|
try:
|
||||||
rpc_connexion = odoorpc.ODOO(
|
rpc_connexion = odoorpc.ODOO(
|
||||||
"0.0.0.0",
|
_ODOO_RPC_URL,
|
||||||
"jsonrpc",
|
"jsonrpc",
|
||||||
port=port,
|
port=port,
|
||||||
timeout=ctx.obj["config"]["odoo_rpc_timeout"],
|
timeout=ctx.obj["config"]["odoo_rpc_timeout"],
|
||||||
|
|
@ -83,7 +83,7 @@ class OdooInstance:
|
||||||
return model.browse(model.create(vals))
|
return model.browse(model.create(vals))
|
||||||
|
|
||||||
def install_modules(self, module_names):
|
def install_modules(self, module_names):
|
||||||
if type(module_names) == str:
|
if type(module_names) is str:
|
||||||
module_names = [module_names]
|
module_names = [module_names]
|
||||||
installed_modules = []
|
installed_modules = []
|
||||||
i = 0
|
i = 0
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,6 @@ class Analysis(object):
|
||||||
|
|
||||||
# Instanciate a new odoo_module
|
# Instanciate a new odoo_module
|
||||||
for module_name in module_list:
|
for module_name in module_list:
|
||||||
|
|
||||||
addon_path = OdooModule.get_addon_path(
|
addon_path = OdooModule.get_addon_path(
|
||||||
ctx, module_name, self.initial_version
|
ctx, module_name, self.initial_version
|
||||||
)
|
)
|
||||||
|
|
@ -476,7 +475,6 @@ class OdooModule(object):
|
||||||
|
|
||||||
|
|
||||||
class OdooModuleVersion(object):
|
class OdooModuleVersion(object):
|
||||||
|
|
||||||
_exclude_directories = [
|
_exclude_directories = [
|
||||||
"lib",
|
"lib",
|
||||||
"demo",
|
"demo",
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,9 @@ def get_postgres_container(ctx):
|
||||||
|
|
||||||
# Check if container exists
|
# Check if container exists
|
||||||
containers = client.containers.list(
|
containers = client.containers.list(
|
||||||
all=True, filters={"name": container_name}
|
all=True,
|
||||||
|
filters={"name": container_name},
|
||||||
|
ignore_removed=True,
|
||||||
)
|
)
|
||||||
if containers:
|
if containers:
|
||||||
container = containers[0]
|
container = containers[0]
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,6 @@ def ensure_file_exists_from_template(
|
||||||
|
|
||||||
|
|
||||||
def git_aggregate(folder_path: Path, config_path: Path, jobs: int):
|
def git_aggregate(folder_path: Path, config_path: Path, jobs: int):
|
||||||
|
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
command="aggregate",
|
command="aggregate",
|
||||||
config=str(config_path),
|
config=str(config_path),
|
||||||
|
|
|
||||||
1660
poetry.lock
generated
1660
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
|
|
@ -43,11 +43,12 @@ pygount = "^1.4"
|
||||||
pyyaml = "5.4.1"
|
pyyaml = "5.4.1"
|
||||||
single-source = "^0.3"
|
single-source = "^0.3"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
pytest = [
|
pytest = [
|
||||||
{version = "<=6.1.2", python = "<3.10"},
|
{version = "<=6.1.2", python = "<3.10"},
|
||||||
{version = ">=6.2.5", python = ">=3.10"}
|
{version = ">=6.2.5", python = ">=3.10"}
|
||||||
]
|
]
|
||||||
|
pytest-mock = "3.6.1"
|
||||||
pytest-cov = "*"
|
pytest-cov = "*"
|
||||||
safety = "*"
|
safety = "*"
|
||||||
pylint = "*"
|
pylint = "*"
|
||||||
|
|
|
||||||
|
|
@ -81,3 +81,13 @@ def build_ctx_from_config_file() -> dict:
|
||||||
ctx.obj["env_folder_path"] = env_folder_path
|
ctx.obj["env_folder_path"] = env_folder_path
|
||||||
ctx.obj["src_folder_path"] = env_folder_path / Path("src")
|
ctx.obj["src_folder_path"] = env_folder_path / Path("src")
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
|
def mock_odoo_rpc_url(mocker):
|
||||||
|
"""Mock the _ODOO_RPC_URL for testing purpose"""
|
||||||
|
odoo_rpc_url = os.environ.get("ODOO_RPC_URL")
|
||||||
|
if odoo_rpc_url:
|
||||||
|
mocker.patch(
|
||||||
|
"odoo_openupgrade_wizard.tools.tools_odoo_instance._ODOO_RPC_URL",
|
||||||
|
odoo_rpc_url,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,19 @@ from odoo_openupgrade_wizard.tools.tools_postgres import (
|
||||||
from . import (
|
from . import (
|
||||||
build_ctx_from_config_file,
|
build_ctx_from_config_file,
|
||||||
cli_runner_invoke,
|
cli_runner_invoke,
|
||||||
|
mock_odoo_rpc_url,
|
||||||
move_to_test_folder,
|
move_to_test_folder,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cli_install_from_csv():
|
def test_cli_install_from_csv(mocker):
|
||||||
move_to_test_folder()
|
move_to_test_folder()
|
||||||
|
mock_odoo_rpc_url(mocker)
|
||||||
|
|
||||||
# Initialize database
|
# Initialize database
|
||||||
db_name = "database_test_cli___install_from_csv"
|
db_name = "database_test_cli___install_from_csv"
|
||||||
ctx = build_ctx_from_config_file()
|
ctx = build_ctx_from_config_file()
|
||||||
|
|
||||||
ensure_database(ctx, db_name, state="absent")
|
ensure_database(ctx, db_name, state="absent")
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,14 @@ from odoo_openupgrade_wizard.tools.tools_odoo import get_odoo_env_path
|
||||||
from . import (
|
from . import (
|
||||||
build_ctx_from_config_file,
|
build_ctx_from_config_file,
|
||||||
cli_runner_invoke,
|
cli_runner_invoke,
|
||||||
|
mock_odoo_rpc_url,
|
||||||
move_to_test_folder,
|
move_to_test_folder,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cli_generate_module_analysis():
|
def test_cli_generate_module_analysis(mocker):
|
||||||
move_to_test_folder()
|
move_to_test_folder()
|
||||||
|
mock_odoo_rpc_url(mocker)
|
||||||
ctx = build_ctx_from_config_file()
|
ctx = build_ctx_from_config_file()
|
||||||
|
|
||||||
db_name = "database_test_cli___generate_module_analysis"
|
db_name = "database_test_cli___generate_module_analysis"
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
|
||||||
from . import (
|
from . import (
|
||||||
build_ctx_from_config_file,
|
build_ctx_from_config_file,
|
||||||
cli_runner_invoke,
|
cli_runner_invoke,
|
||||||
|
mock_odoo_rpc_url,
|
||||||
move_to_test_folder,
|
move_to_test_folder,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cli_dumpdb():
|
def test_cli_dumpdb(mocker):
|
||||||
move_to_test_folder()
|
move_to_test_folder()
|
||||||
|
mock_odoo_rpc_url(mocker)
|
||||||
|
|
||||||
# Initialize database
|
# Initialize database
|
||||||
db_name = "database_test_cli___dumpdb"
|
db_name = "database_test_cli___dumpdb"
|
||||||
|
|
@ -62,8 +64,9 @@ def test_cli_dumpdb():
|
||||||
filestore_path.unlink()
|
filestore_path.unlink()
|
||||||
|
|
||||||
|
|
||||||
def test_cli_dumpdb_failure():
|
def test_cli_dumpdb_failure(mocker):
|
||||||
move_to_test_folder()
|
move_to_test_folder()
|
||||||
|
mock_odoo_rpc_url(mocker)
|
||||||
|
|
||||||
# Initialize database
|
# Initialize database
|
||||||
db_name = "database_test_cli___dumpdb"
|
db_name = "database_test_cli___dumpdb"
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
|
||||||
from . import (
|
from . import (
|
||||||
build_ctx_from_config_file,
|
build_ctx_from_config_file,
|
||||||
cli_runner_invoke,
|
cli_runner_invoke,
|
||||||
|
mock_odoo_rpc_url,
|
||||||
move_to_test_folder,
|
move_to_test_folder,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cli_copydb():
|
def test_cli_copydb(mocker):
|
||||||
move_to_test_folder()
|
move_to_test_folder()
|
||||||
|
mock_odoo_rpc_url(mocker)
|
||||||
|
|
||||||
db_name = "database_test_cli___copydb"
|
db_name = "database_test_cli___copydb"
|
||||||
db_dest_name = "database_test_cli___copydb__copy"
|
db_dest_name = "database_test_cli___copydb__copy"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user