Run tests from inside docker image to ensure python version

This commit is contained in:
Gabriel Augendre 2020-08-21 14:14:40 +02:00
parent 3afdd108b5
commit a97bfdffef
4 changed files with 13 additions and 12 deletions

View file

@ -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"

View file

@ -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"

View file

@ -11,3 +11,8 @@ services:
- ./db:/db
- ./static:/app/staticfiles
restart: on-failure
tests:
image: crocmagnon/blog
build: .
command: ["/app/docker/runtests.sh"]
healthcheck: {}

3
docker/runtests.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
pip install -r /app/requirements-dev.txt --progress-bar off
TESTING=true python -m pytest