From d0a7f3c842dec7c66b2cce0e8a172c7f1f488bf0 Mon Sep 17 00:00:00 2001 From: GergelyKalmar Date: Thu, 23 May 2024 19:41:30 +0200 Subject: [PATCH] Add Docker support --- pytest_logikal/browser/chromium.py | 2 ++ pytest_logikal/core.py | 2 +- pytest_logikal/django.py | 3 ++- requirements/dev.txt.lock | 10 +++++----- requirements/docs.txt.lock | 10 +++++----- requirements/extras/browser.txt | 4 ++-- requirements/extras/django.txt | 4 ++-- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/pytest_logikal/browser/chromium.py b/pytest_logikal/browser/chromium.py index 537e454..7596ad7 100644 --- a/pytest_logikal/browser/chromium.py +++ b/pytest_logikal/browser/chromium.py @@ -1,3 +1,4 @@ +import os from abc import abstractmethod from typing import Any, Dict, Type @@ -33,6 +34,7 @@ def init_args(self) -> Dict[str, Any]: '--disable-search-engine-choice-screen', # Web platform behavior f'--js-flags=--random-seed={DEFAULT_JS_RANDOM_SEED}', + *(['--no-sandbox'] if os.getenv('DOCKER_RUN') == '1' else []) ] options = self.options_class() diff --git a/pytest_logikal/core.py b/pytest_logikal/core.py index a62a54d..eb5757d 100644 --- a/pytest_logikal/core.py +++ b/pytest_logikal/core.py @@ -47,6 +47,7 @@ def pytest_addoption(parser: pytest.Parser) -> None: group.addoption('--no-pylint', action='store_true', help='do not use pylint') group.addoption('--no-requirements', action='store_true', help='do not check requirements') group.addoption('--no-style', action='store_true', help='do not use pycodestyle & pydocstyle') + group.addoption('--no-install', action='store_true', help='do not install packages') if EXTRAS['django']: group.addoption('--no-migration', action='store_true', help='do not check migrations') @@ -55,7 +56,6 @@ def pytest_addoption(parser: pytest.Parser) -> None: group.addoption('--no-css', action='store_true', help='do not run css checks') group.addoption('--no-svg', action='store_true', help='do not run svg checks') group.addoption('--no-js', action='store_true', help='do not run js checks') - group.addoption('--no-install', action='store_true', help='do not install packages') for option, entry in DEFAULT_INI_OPTIONS.items(): parser.addini(option, default=str(entry['value']), help=entry['help']) diff --git a/pytest_logikal/django.py b/pytest_logikal/django.py index a52cc38..e9860ce 100644 --- a/pytest_logikal/django.py +++ b/pytest_logikal/django.py @@ -24,7 +24,8 @@ def pytest_sessionstart(session: pytest.Session) -> None: if not session.config.getoption('no_install'): install_node_packages() - if not session.config.getoption('no_css') and not session.config.getoption('no_svg'): + css_or_svg = not session.config.getoption('no_css') or not session.config.getoption('no_svg') + if not session.config.getoption('fast') and css_or_svg: # We start the validator service here to avoid pytest's output capturing Validator.service_url() diff --git a/requirements/dev.txt.lock b/requirements/dev.txt.lock index 27d4106..9b19863 100644 --- a/requirements/dev.txt.lock +++ b/requirements/dev.txt.lock @@ -3,7 +3,7 @@ ## DO NOT EDIT THIS FILE. ## This is a locked requirements file generated by pyorbs. ## -## Requirements hash: f41544170eeafc53ce555705b2513ad9b8019d8fc81a71c2a9d656e0ccbc615c +## Requirements hash: e189ad6b93754b6df783fa8060dce845e5d8090ead3f4b22f46bfc947929765a ## ################################################################################################### -e . @@ -32,7 +32,7 @@ django-migration-linter==5.1.0 django-stubs==4.2.7 django-stubs-ext==5.0.0 djlint==1.34.1 -docker==7.0.0 +docker==7.1.0 docutils==0.20.1 EditorConfig==0.12.4 exceptiongroup==1.2.1 @@ -59,7 +59,7 @@ jsbeautifier==1.15.1 json5==0.9.25 keyring==25.2.1 logikal-docs==1.1.4 -logikal-utils==1.1.0 +logikal-utils==1.1.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mccabe==0.7.0 @@ -102,7 +102,7 @@ pytz==2024.1 PyYAML==6.0.1 readme_renderer==43.0 regex==2023.12.25 -requests==2.31.0 +requests==2.32.2 requests-toolbelt==1.0.0 rfc3986==2.0.0 rich==13.7.1 @@ -135,7 +135,7 @@ trio-websocket==0.11.1 twine==5.1.0 types-pytz==2024.1.0.20240417 types-PyYAML==6.0.12.20240311 -types-requests==2.31.0.20240406 +types-requests==2.32.0.20240523 types-tqdm==4.66.0.20240417 typing_extensions==4.11.0 urllib3==2.2.1 diff --git a/requirements/docs.txt.lock b/requirements/docs.txt.lock index 2be0037..a07c6c1 100644 --- a/requirements/docs.txt.lock +++ b/requirements/docs.txt.lock @@ -3,7 +3,7 @@ ## DO NOT EDIT THIS FILE. ## This is a locked requirements file generated by pyorbs. ## -## Requirements hash: 49046982207a816fa7a4a207626836f702b212515e8a94283769de8473b710b3 +## Requirements hash: 569e4a42677a7862a3c16175b3497fe03a500929bcf719b0839e3f3cfe62d036 ## ################################################################################################### -e . @@ -28,7 +28,7 @@ django-migration-linter==5.1.0 django-stubs==4.2.7 django-stubs-ext==5.0.0 djlint==1.34.1 -docker==7.0.0 +docker==7.1.0 docutils==0.20.1 EditorConfig==0.12.4 exceptiongroup==1.2.1 @@ -49,7 +49,7 @@ Jinja2==3.1.4 jsbeautifier==1.15.1 json5==0.9.25 logikal-docs==1.1.4 -logikal-utils==1.1.0 +logikal-utils==1.1.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mccabe==0.7.0 @@ -86,7 +86,7 @@ python-dateutil==2.9.0.post0 pytz==2024.1 PyYAML==6.0.1 regex==2023.12.25 -requests==2.31.0 +requests==2.32.2 rich==13.7.1 selenium==4.21.0 setuptools==70.0.0 @@ -114,7 +114,7 @@ trio==0.25.1 trio-websocket==0.11.1 types-pytz==2024.1.0.20240417 types-PyYAML==6.0.12.20240311 -types-requests==2.31.0.20240406 +types-requests==2.32.0.20240523 types-tqdm==4.66.0.20240417 typing_extensions==4.11.0 urllib3==2.2.1 diff --git a/requirements/extras/browser.txt b/requirements/extras/browser.txt index 34e3f5d..dc689b7 100644 --- a/requirements/extras/browser.txt +++ b/requirements/extras/browser.txt @@ -1,5 +1,5 @@ -requests<2.32 # see https://github.com/docker/docker-py/issues/3256 -types-requests<2.32 # see https://github.com/docker/docker-py/issues/3256 +requests~=2.32 +types-requests~=2.32 tqdm~=4.66 types-tqdm~=4.66 selenium==4.21.0 diff --git a/requirements/extras/django.txt b/requirements/extras/django.txt index cbad1a9..4ca83b7 100644 --- a/requirements/extras/django.txt +++ b/requirements/extras/django.txt @@ -8,6 +8,6 @@ pytest-django==4.8.0 pytest-factoryboy==2.7.0 # Validator -requests<2.32 # see https://github.com/docker/docker-py/issues/3256 -types-requests<2.32 # see https://github.com/docker/docker-py/issues/3256 +requests~=2.32 +types-requests~=2.32 logikal-utils[docker]~=1.1