Add CI support (#7)

* Switch to 'slim' image, add Travis CI integration

* Remove trailing quote, simplify CI flow

* Add missing phony targets, suppress F401/F403 'pyflakes' errors on missing file

* Replace 'psycopg2' with 'psycopg2-binary', bump version to '2.8.4'

* Install 'make' in docker, add build and termination option in readme

* Revert 'psycopg2-binary' to 'psycopg2'

* Remove extra empty line

* Install missing 'gcc', 'libc-dev' and 'libpq-dev'
This commit is contained in:
Volodymyr 'vovin' Shcherbinin 2020-02-01 00:20:56 +02:00 committed by GitHub
parent 4f0ef28ea2
commit 0ba301315a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 8 deletions

11
.travis.yml Normal file
View File

@ -0,0 +1,11 @@
os: linux
dist: bionic
language: python
python:
- "3.7"
addons:
apt:
packages:
- "shellcheck"
script:
- "make test-ci"

View File

@ -1,9 +1,21 @@
FROM python:3.7
FROM python:3.7-slim-buster
ARG requirements=requirements.txt
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get install --no-install-recommends -yq \
gcc \
libc-dev \
libpq-dev \
make \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
ARG requirements=requirements.txt
ADD . /app
RUN pip install --no-cache-dir -e .
RUN pip install --no-cache-dir -r $requirements
RUN pip install --no-cache-dir -e . \
&& pip install --no-cache-dir -r $requirements

View File

@ -39,6 +39,11 @@ mypy: ## Check types with mypy
run: ## Runs dev server
@python3 manage.py runserver
test-ci: test-requirements lint mypy ## Run tests (intended for CI usage)
test-requirements: ## Install requirements to run tests
@pip3 install -r ./requirements-test.txt
.PHONY: \
dev-requirements \
docker_run \
@ -49,4 +54,6 @@ run: ## Runs dev server
lint \
migrate \
mypy \
run
run \
test-ci \
test-requirements

View File

@ -2,8 +2,20 @@
Experimental project
### Build and run
```shell script
docker-compose up --build
```
### Run
```shell script
docker-compose up
```
$ docker-compose up
### Terminate
```shell script
docker-compose down --remove-orphans
```

View File

@ -118,7 +118,10 @@ MEDIA_UPLOAD_CODE = None # should be set in private_settings.py
try:
# poor mans' private settings
from infomate.private_settings import *
# As due to obvious reasons this file is missing in the repository, suppress the following 'pyflakes' error codes:
# - F401 'infomate.private_settings.*' imported but unused
# - F403 'from infomate.private_settings import *' used; unable to detect undefined names
from infomate.private_settings import * # noqa: F401 F403
except ImportError:
pass

5
requirements-test.txt Normal file
View File

@ -0,0 +1,5 @@
flake8
mypy
pylint
requests
yamllint

View File

@ -1,5 +1,5 @@
Django==2.2.8
psycopg2==2.8.3
psycopg2==2.8.4
click==7.0
pillow==7.0
awesome-slugify>=1.6.5