From a97bfdffefcb215cc94272c249a1a8d76a5f7441 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 21 Aug 2020 14:14:40 +0200 Subject: [PATCH] Run tests from inside docker image to ensure python version --- .build.yml | 11 ++--------- Dockerfile | 6 +++--- docker-compose.yml | 5 +++++ docker/runtests.sh | 3 +++ 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100755 docker/runtests.sh diff --git a/.build.yml b/.build.yml index df4b9df..cb5ca6a 100644 --- a/.build.yml +++ b/.build.yml @@ -1,8 +1,6 @@ image: archlinux packages: - docker - - python-pip - - python-virtualenv sources: - https://git.sr.ht/~crocmagnon/blog secrets: @@ -12,19 +10,14 @@ secrets: environment: TESTING: true tasks: - - test: | - python --version - cd blog - virtualenv venv - venv/bin/python -m pip install -r requirements.txt -r requirements-dev.txt --progress-bar off - venv/bin/python -m pytest - setup_docker: | ./blog/docker/setup-docker - - build: | + - build_and_test: | docker info docker login -u crocmagnon --password-stdin < .docker-secret docker pull crocmagnon/blog || true docker build --cache-from crocmagnon/blog:latest -t crocmagnon/blog blog/ + docker run -t --rm crocmagnon/blog /app/docker/runtests.sh docker push crocmagnon/blog - deploy: | ssh blog -o StrictHostKeyChecking=no "/srv/blog/redeploy" diff --git a/Dockerfile b/Dockerfile index 69f2b07..29ac5c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,10 @@ RUN apt-get update \ WORKDIR /app COPY requirements.txt ./ RUN pip install -r requirements.txt -COPY manage.py ./ -COPY articles ./articles/ -COPY blog ./blog/ +COPY manage.py LICENSE .pre-commit-config.yaml .isort.cfg pyproject.toml requirements-dev.txt ./ COPY docker ./docker/ +COPY blog ./blog/ +COPY articles ./articles/ ENV SECRET_KEY "changeme" ENV DEBUG "false" diff --git a/docker-compose.yml b/docker-compose.yml index dc4d75f..42ea2c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,3 +11,8 @@ services: - ./db:/db - ./static:/app/staticfiles restart: on-failure + tests: + image: crocmagnon/blog + build: . + command: ["/app/docker/runtests.sh"] + healthcheck: {} diff --git a/docker/runtests.sh b/docker/runtests.sh new file mode 100755 index 0000000..9b43ca5 --- /dev/null +++ b/docker/runtests.sh @@ -0,0 +1,3 @@ +#!/bin/sh +pip install -r /app/requirements-dev.txt --progress-bar off +TESTING=true python -m pytest