From 92f4ce411d418d5b4387f7bf83b535adcc249926 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Sun, 11 Oct 2020 02:17:03 +0300 Subject: [PATCH] Automated testing --- .github/workflows/continuous-integration.yml | 11 +++++++++++ .gitignore | 4 ++++ Dockerfile | 16 +++++++++------- docker-compose.yml | 6 ++++++ docker-entrypoint.sh | 5 +++++ requirements.txt | 4 ++-- scripts/citest | 20 ++++++++++++++++++++ web/manage.py | 3 +++ 8 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 docker-compose.yml create mode 100755 docker-entrypoint.sh create mode 100644 scripts/citest diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 00000000..98768637 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,11 @@ +--- +name: Automated tests + +on: pull_request + +jobs: + sqlite: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - run: bash -x scripts/citest diff --git a/.gitignore b/.gitignore index 0d20b648..1ee1d3a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ *.pyc +src +env* +*.orig +*.rej diff --git a/Dockerfile b/Dockerfile index 6ea04d2c..0d9b710f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ -FROM ubuntu:12.04 +FROM python:2 -MAINTAINER siimeon +WORKDIR /app/web -RUN apt-get update && apt-get install -y python python-django git +COPY . /app/ -RUN git clone https://github.com/siimeon/Kipa.git /root/kipa +RUN echo "PYTHONPATH=/usr/local/lib/python2.7/site-packages" | tee -a /etc/profile -EXPOSE 8000 +ENTRYPOINT ["/app/docker-entrypoint.sh"] -WORKDIR /root/kipa/web +EXPOSE 3000 -CMD git pull && python manage.py runserver 0.0.0.0:8000 +CMD ["./manage.py", "runserver", "0.0.0.0:3000"] + +RUN pip install -r /app/requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..afbbc6c4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: '3' +services: + web: + build: . + ports: + - 3000:3000 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..6244ad4b --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +export PYTHONPATH="/usr/local/lib/python2.7/site-packages" + +exec "$@" diff --git a/requirements.txt b/requirements.txt index ccdc5e6e..21048dea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ #django #django==1.2.7 #https://www.djangoproject.com/download/1.2.7/tarball/ --e git+https://github.com/django/django.git@1.2.7#egg=django +git+https://github.com/django/django.git@1.2.7#egg=django south #mysql-python --e git+https://github.com/PyMySQL/mysqlclient-python.git#egg=MySQLdb +git+https://github.com/PyMySQL/mysqlclient-python.git@v1.4.6#egg=MySQLdb diff --git a/scripts/citest b/scripts/citest new file mode 100644 index 00000000..9905b707 --- /dev/null +++ b/scripts/citest @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +docker_compose="docker-compose --file docker-compose.yml" + +function cleanup() { + $docker_compose down +} + +function die() { + echo $@ + exit 1 +} + +trap cleanup EXIT + +$docker_compose build +$docker_compose up -d +$docker_compose run web './manage.py' test diff --git a/web/manage.py b/web/manage.py index 5660e18f..b9ff11b6 100755 --- a/web/manage.py +++ b/web/manage.py @@ -1,7 +1,10 @@ #!/usr/bin/python2 + import sys +print sys.path from tupa.dia2django import luoMallienRungot from django.core.management import execute_manager + #try: import settings # import legacySettings # Legacy settings for exporting an legacy db