From fbb3e052fed5a82e334bb795c58f6e0a16f55890 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Tue, 23 Aug 2022 00:07:40 -0700 Subject: [PATCH] ci: use cache/virtualenv for test dependencies Signed-off-by: Kevin Morris --- .gitlab-ci.yml | 3 +++ Dockerfile | 3 ++- docker/scripts/install-deps.sh | 3 ++- docker/scripts/install-python-deps.sh | 7 +++---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7134673c..4d082582 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ cache: paths: # For some reason Gitlab CI only supports storing cache/artifacts in a path relative to the build directory - .pkg-cache + - .venv variables: AUR_CONFIG: conf/config # Default MySQL config setup in before_script. @@ -31,6 +32,8 @@ test: before_script: - export PATH="$HOME/.poetry/bin:${PATH}" - ./docker/scripts/install-deps.sh + - virtualenv -p python3 .venv + - source .venv/bin/activate # Enable our virtualenv cache - ./docker/scripts/install-python-deps.sh - useradd -U -d /aurweb -c 'AUR User' aur - ./docker/mariadb-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 16e6514e..28bca0e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ VOLUME /root/.cache/pypoetry/artifacts ENV PATH="/root/.poetry/bin:${PATH}" ENV PYTHONPATH=/aurweb ENV AUR_CONFIG=conf/config +ENV COMPOSE=1 # Install system-wide dependencies. COPY ./docker/scripts/install-deps.sh /install-deps.sh @@ -27,7 +28,7 @@ RUN cp -vf conf/config.dev conf/config RUN sed -i "s;YOUR_AUR_ROOT;/aurweb;g" conf/config # Install Python dependencies. -RUN /docker/scripts/install-python-deps.sh +RUN /docker/scripts/install-python-deps.sh compose # Compile asciidocs. RUN make -C doc diff --git a/docker/scripts/install-deps.sh b/docker/scripts/install-deps.sh index ced18c81..82496a2b 100755 --- a/docker/scripts/install-deps.sh +++ b/docker/scripts/install-deps.sh @@ -17,6 +17,7 @@ pacman -Syu --noconfirm --noprogressbar \ mariadb mariadb-libs cgit-aurweb uwsgi uwsgi-plugin-cgi \ php php-fpm memcached php-memcached python-pip pyalpm \ python-srcinfo curl libeatmydata cronie python-poetry \ - python-poetry-core step-cli step-ca asciidoc + python-poetry-core step-cli step-ca asciidoc \ + python-virtualenv exec "$@" diff --git a/docker/scripts/install-python-deps.sh b/docker/scripts/install-python-deps.sh index 3d5f28f0..01a6eaa7 100755 --- a/docker/scripts/install-python-deps.sh +++ b/docker/scripts/install-python-deps.sh @@ -4,8 +4,7 @@ set -eou pipefail # Upgrade PIP; Arch Linux's version of pip is outdated for Poetry. pip install --upgrade pip -# Install the aurweb package and deps system-wide via poetry. -poetry config virtualenvs.create false +if [ ! -z "${COMPOSE+x}" ]; then + poetry config virtualenvs.create false +fi poetry install --no-interaction --no-ansi - -exec "$@"