From 689de82139b8fcc3b1b4ad1a9150a3168a9ccae2 Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Tue, 3 Sep 2024 13:06:24 +0300 Subject: [PATCH] build: make cerberus dependency optional --- .github/workflows/setup.sh | 8 ++-- .readthedocs.yml | 1 + Dockerfile | 45 +++++++++++++++++--- package/archlinux/PKGBUILD | 3 +- pyproject.toml | 4 +- src/ahriman/application/handlers/validate.py | 3 +- tox.ini | 2 +- 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/.github/workflows/setup.sh b/.github/workflows/setup.sh index 4a42f2e7..5ed7afcb 100755 --- a/.github/workflows/setup.sh +++ b/.github/workflows/setup.sh @@ -10,7 +10,7 @@ echo -e '[arcanisrepo]\nServer = https://repo.arcanis.me/$arch\nSigLevel = Never # refresh the image pacman -Syu --noconfirm # main dependencies -pacman -Sy --noconfirm devtools git pyalpm python-cerberus python-inflection python-passlib python-pyelftools python-requests python-srcinfo python-systemd sudo +pacman -Sy --noconfirm devtools git pyalpm python-inflection python-passlib python-pyelftools python-requests python-srcinfo python-systemd sudo # make dependencies pacman -Sy --noconfirm --asdeps base-devel python-build python-flit python-installer python-tox python-wheel # optional dependencies @@ -20,7 +20,7 @@ if [[ -z $MINIMAL_INSTALL ]]; then # web server pacman -Sy --noconfirm python-aioauth-client python-aiohttp python-aiohttp-apispec-git python-aiohttp-cors python-aiohttp-jinja2 python-aiohttp-security python-aiohttp-session python-cryptography python-jinja # additional features - pacman -Sy --noconfirm gnupg python-boto3 python-matplotlib rsync + pacman -Sy --noconfirm gnupg python-boto3 python-cerberus python-matplotlib rsync fi # FIXME since 1.0.4 devtools requires dbus to be run, which doesn't work now in container cp "docker/systemd-nspawn.sh" "/usr/local/bin/systemd-nspawn" @@ -42,12 +42,12 @@ pacman -Qdtq | pacman -Rscn --noconfirm - # initial setup command as root [[ -z $MINIMAL_INSTALL ]] && WEB_ARGS=("--web-port" "8080") ahriman -a x86_64 -r "github" service-setup --packager "ahriman bot " "${WEB_ARGS[@]}" -# validate configuration -ahriman service-config-validate --exit-code # enable services systemctl enable ahriman-web systemctl enable ahriman@x86_64-github.timer if [[ -z $MINIMAL_INSTALL ]]; then + # validate configuration + ahriman service-config-validate --exit-code # run web service (detached) sudo -u ahriman -- ahriman web & WEB_PID=$! diff --git a/.readthedocs.yml b/.readthedocs.yml index b9f560bd..c5db0ed2 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -12,6 +12,7 @@ python: extra_requirements: - docs - s3 + - validator - web formats: diff --git a/Dockerfile b/Dockerfile index 416d98de..5a887293 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,11 +32,46 @@ RUN useradd -m -d "/home/build" -s "/usr/bin/nologin" build && \ COPY "docker/install-aur-package.sh" "/usr/local/bin/install-aur-package" ## install package dependencies ## darcs is not installed by reasons, because it requires a lot haskell packages which dramatically increase image size -RUN pacman -Sy --noconfirm --asdeps devtools git pyalpm python-cerberus python-inflection python-passlib python-pyelftools python-requests python-srcinfo && \ - pacman -Sy --noconfirm --asdeps base-devel python-build python-flit python-installer python-wheel && \ - pacman -Sy --noconfirm --asdeps breezy git mercurial python-aiohttp python-boto3 python-cryptography python-jinja python-matplotlib python-systemd rsync subversion && \ - runuser -u build -- install-aur-package python-aioauth-client python-webargs python-aiohttp-apispec-git python-aiohttp-cors \ - python-aiohttp-jinja2 python-aiohttp-session python-aiohttp-security python-requests-unixsocket2 +RUN pacman -Sy --noconfirm --asdeps \ + devtools \ + git \ + pyalpm \ + python-inflection \ + python-passlib \ + python-pyelftools \ + python-requests \ + python-srcinfo \ + && \ + pacman -Sy --noconfirm --asdeps \ + base-devel \ + python-build \ + python-flit \ + python-installer \ + python-wheel \ + && \ + pacman -Sy --noconfirm --asdeps \ + breezy \ + git \ + mercurial \ + python-aiohttp \ + python-boto3 \ + python-cerberus \ + python-cryptography \ + python-jinja \ + python-matplotlib \ + python-systemd \ + rsync \ + subversion \ + && \ + runuser -u build -- install-aur-package \ + python-aioauth-client \ + python-webargs \ + python-aiohttp-apispec-git \ + python-aiohttp-cors \ + python-aiohttp-jinja2 \ + python-aiohttp-session \ + python-aiohttp-security \ + python-requests-unixsocket2 ## FIXME since 1.0.4 devtools requires dbus to be run, which doesn't work now in container COPY "docker/systemd-nspawn.sh" "/usr/local/bin/systemd-nspawn" diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index 2fa9b686..59b4b36f 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -7,7 +7,7 @@ pkgdesc="ArcH linux ReposItory MANager" arch=('any') url="https://github.com/arcan1s/ahriman" license=('GPL3') -depends=('devtools>=1:1.0.0' 'git' 'pyalpm' 'python-cerberus' 'python-inflection' 'python-passlib' 'python-pyelftools' 'python-requests' 'python-srcinfo') +depends=('devtools>=1:1.0.0' 'git' 'pyalpm' 'python-inflection' 'python-passlib' 'python-pyelftools' 'python-requests' 'python-srcinfo') makedepends=('python-build' 'python-flit' 'python-installer' 'python-wheel') optdepends=('breezy: -bzr packages support' 'darcs: -darcs packages support' @@ -20,6 +20,7 @@ optdepends=('breezy: -bzr packages support' 'python-aiohttp-security: web server with authorization' 'python-aiohttp-session: web server with authorization' 'python-boto3: sync to s3' + 'python-cerberus: configuration validator' 'python-cryptography: web server with authorization' 'python-matplotlib: usage statistics chart' 'python-requests-unixsocket2: client report to web server by unix socket' diff --git a/pyproject.toml b/pyproject.toml index d45d4ada..e85e1865 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,6 @@ authors = [ ] dependencies = [ - "cerberus", "inflection", "passlib", "pyelftools", @@ -74,6 +73,9 @@ tests = [ "pytest-resource-path", "pytest-spec", ] +validator = [ + "cerberus", +] web = [ "Jinja2", "aioauth-client", diff --git a/src/ahriman/application/handlers/validate.py b/src/ahriman/application/handlers/validate.py index 63d9e51d..62ea4fd4 100644 --- a/src/ahriman/application/handlers/validate.py +++ b/src/ahriman/application/handlers/validate.py @@ -25,7 +25,6 @@ from typing import Any from ahriman.application.handlers.handler import Handler from ahriman.core.configuration import Configuration from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA, ConfigurationSchema -from ahriman.core.configuration.validator import Validator from ahriman.core.exceptions import ExtensionError from ahriman.core.formatters import ValidationPrinter from ahriman.core.triggers import TriggerLoader @@ -51,6 +50,8 @@ class Validate(Handler): configuration(Configuration): configuration instance report(bool): force enable or disable reporting """ + from ahriman.core.configuration.validator import Validator + schema = Validate.schema(repository_id, configuration) validator = Validator(configuration=configuration, schema=schema) diff --git a/tox.ini b/tox.ini index a7c8c7f4..17a7c3ab 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = check, tests isolated_build = True labels = release = version, docs, publish -dependencies = -e .[journald,pacman,s3,stats,web] +dependencies = -e .[journald,pacman,s3,stats,validator,web] project_name = ahriman [mypy]