Add support for running tests from a Docker container.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
|
|
||||||
job_docker_master:
|
job_docker_master:
|
||||||
stage: build
|
stage: build
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
@@ -11,10 +11,11 @@ job_docker_master:
|
|||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- docker build --pull -t "$CI_REGISTRY_IMAGE" -f docker/Dockerfile .
|
- docker build --pull -t "$CI_REGISTRY_IMAGE" -f docker/Dockerfile .
|
||||||
|
- docker run --rm "$CI_REGISTRY_IMAGE" run-tests
|
||||||
- docker push "$CI_REGISTRY_IMAGE"
|
- docker push "$CI_REGISTRY_IMAGE"
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
job_docker_other:
|
job_docker_other:
|
||||||
stage: build
|
stage: build
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
@@ -24,6 +25,7 @@ job_docker_other:
|
|||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f docker/Dockerfile .
|
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f docker/Dockerfile .
|
||||||
|
- docker run --rm "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" run-tests
|
||||||
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
||||||
except:
|
except:
|
||||||
- master
|
- master
|
||||||
@@ -44,7 +46,7 @@ job_docker_other:
|
|||||||
- export LC_ALL=en_US.UTF-8
|
- export LC_ALL=en_US.UTF-8
|
||||||
- apt-get install -qq curl gcc ghostscript gpgv gnupg graphviz libjpeg-dev libmagic1 libpng-dev libtiff-dev poppler-utils libreoffice poppler-utils python-dev python-pip tesseract-ocr tesseract-ocr-deu
|
- apt-get install -qq curl gcc ghostscript gpgv gnupg graphviz libjpeg-dev libmagic1 libpng-dev libtiff-dev poppler-utils libreoffice poppler-utils python-dev python-pip tesseract-ocr tesseract-ocr-deu
|
||||||
- pip install -r requirements/testing.txt
|
- pip install -r requirements/testing.txt
|
||||||
|
|
||||||
test-mysql:
|
test-mysql:
|
||||||
<<: *test_base
|
<<: *test_base
|
||||||
variables:
|
variables:
|
||||||
@@ -59,7 +61,7 @@ test-mysql:
|
|||||||
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
|
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
test-postgres:
|
test-postgres:
|
||||||
<<: *test_base
|
<<: *test_base
|
||||||
variables:
|
variables:
|
||||||
@@ -73,7 +75,7 @@ test-postgres:
|
|||||||
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
|
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
|
||||||
tags:
|
tags:
|
||||||
- postgres
|
- postgres
|
||||||
|
|
||||||
test-sqlite:
|
test-sqlite:
|
||||||
<<: *test_base
|
<<: *test_base
|
||||||
script:
|
script:
|
||||||
|
|||||||
8
contrib/scripts/docker/run-tests.sh
Executable file
8
contrib/scripts/docker/run-tests.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends tesseract-ocr-deu
|
||||||
|
|
||||||
|
pip install -r $DOCKER_ROOT/requirements-testing.txt
|
||||||
|
|
||||||
|
mayan-edms.py test --mayan-apps
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
echo "mayan: starting entrypoint.sh"
|
echo "mayan: starting entrypoint.sh"
|
||||||
INSTALL_FLAG=/var/lib/mayan/media/system/SECRET_KEY
|
INSTALL_FLAG=/var/lib/mayan/media/system/SECRET_KEY
|
||||||
|
export DOCKER_ROOT=/root
|
||||||
|
|
||||||
export MAYAN_DEFAULT_BROKER_URL=redis://127.0.0.1:6379/0
|
export MAYAN_DEFAULT_BROKER_URL=redis://127.0.0.1:6379/0
|
||||||
export MAYAN_DEFAULT_CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0
|
export MAYAN_DEFAULT_CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0
|
||||||
@@ -57,15 +58,29 @@ pip_installs() {
|
|||||||
os_package_installs || true
|
os_package_installs || true
|
||||||
pip_installs || true
|
pip_installs || true
|
||||||
|
|
||||||
if [ "$1" = 'mayan' ]; then
|
case "$1" in
|
||||||
# Check if this is a new install, otherwise try to upgrade the existing
|
|
||||||
# installation on subsequent starts
|
mayan) # Check if this is a new install, otherwise try to upgrade the existing
|
||||||
if [ ! -f $INSTALL_FLAG ]; then
|
# installation on subsequent starts
|
||||||
initialize
|
if [ ! -f $INSTALL_FLAG ]; then
|
||||||
else
|
initialize
|
||||||
upgrade
|
else
|
||||||
fi
|
upgrade
|
||||||
start
|
fi
|
||||||
else
|
start
|
||||||
su mayan -c "mayan-edms.py $@";
|
;;
|
||||||
fi
|
|
||||||
|
run-tests) # Check if this is a new install, otherwise try to upgrade the existing
|
||||||
|
# installation on subsequent starts
|
||||||
|
if [ ! -f $INSTALL_FLAG ]; then
|
||||||
|
initialize
|
||||||
|
else
|
||||||
|
upgrade
|
||||||
|
fi
|
||||||
|
$DOCKER_ROOT/run-tests.sh
|
||||||
|
;;
|
||||||
|
|
||||||
|
*) su mayan -c "$@";
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user