From fc42849b008230e6fc316c47d782b70cb1106ca4 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 7 May 2018 01:08:47 -0400 Subject: [PATCH] Update gitlab-ci to build a docker image if the tests are successful. Signed-off-by: Roberto Rosario --- .gitlab-ci.yml | 114 ++++++++++++++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 44 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88fd056b33..6a956ad572 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,46 +1,72 @@ -image: ubuntu:16.04 -cache: - paths: - - ~/.cache/pip/ -before_script: - - apt-get -qq update - - apt-get install -qq locales - - echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale - - locale-gen en_US.UTF-8 - - update-locale LANG=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 -variables: - POSTGRES_DB: "mayan_edms" - POSTGRES_PASSWORD: "postgres" - MYSQL_ALLOW_EMPTY_PASSWORD: "yes" - MYSQL_DATABASE: "mayan_edms" -test:mysql: +stages: + - test + - build +job_docker: + stage: build + image: docker:latest services: - - mysql:8.0.3 - script: - - apt-get install -qq libmysqlclient-dev - - pip install -r requirements/testing.txt - - pip install mysql-python - - apt-get install -qq mysql-client - - mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -e "set global character_set_server=utf8mb4;" - - coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations - - codecov - tags: - - mysql -test:postgres: - services: - - postgres - script: - - apt-get install -qq libpq-dev - - pip install -r requirements/testing.txt - - pip install psycopg2 - - coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations - - codecov - tags: + - docker:dind + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + build-master: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE" -f docker/Dockerfile . + - docker push "$CI_REGISTRY_IMAGE" + only: + - master + build: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f docker/Dockerfile . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + except: + - master +job_python: + stage: test + image: ubuntu:16.04 + cache: + paths: + - ~/.cache/pip/ + before_script: + - apt-get -qq update + - apt-get install -qq locales + - echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale + - locale-gen en_US.UTF-8 + - update-locale LANG=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 + variables: + POSTGRES_DB: "mayan_edms" + POSTGRES_PASSWORD: "postgres" + MYSQL_ALLOW_EMPTY_PASSWORD: "yes" + MYSQL_DATABASE: "mayan_edms" + test:mysql: + services: + - mysql:8.0.3 + script: + - apt-get install -qq libmysqlclient-dev + - pip install -r requirements/testing.txt + - pip install mysql-python + - apt-get install -qq mysql-client + - mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -e "set global character_set_server=utf8mb4;" + - coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations + - codecov + tags: + - mysql + test:postgres: + services: - postgres -test:sqlite: - script: - - pip install -r requirements/testing.txt - - coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci --nomigrations - - codecov + script: + - apt-get install -qq libpq-dev + - pip install -r requirements/testing.txt + - pip install psycopg2 + - coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations + - codecov + tags: + - postgres + test:sqlite: + script: + - pip install -r requirements/testing.txt + - coverage run manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci --nomigrations + - codecov