stages: - build - lint - test - deploy - cleanup services: - registry cache: paths: - .cache/ variables: PIPENV_CACHE_DIR: "$CI_PROJECT_DIR/.cache" build docker image: image: docker:stable-git stage: build script: - docker build -t registry:5000/django-ci . tags: - docker only: - master - django lint: image: registry:5000/django-ci stage: lint script: - pipenv install --dev --system - flake8 test: image: registry:5000/django-ci stage: test services: - postgres:10-alpine before_script: - pipenv install --dev --system - python manage.py migrate script: - coverage run --source=api,home,pysite,wiki --branch manage.py test after_script: - coverage report artifacts: paths: - .coverage variables: DATABASE_URL: postgres://django:supersecret@postgres/pysite POSTGRES_DB: pysite POSTGRES_PASSWORD: supersecret POSTGRES_USER: django pages: stage: deploy dependencies: - test before_script: - pip install coverage script: - coverage html --directory=public artifacts: paths: - public expire_in: 30 days upload newest docker image: image: docker:stable-git stage: deploy script: - echo "$GITLAB_DOCKER_PASSWORD" | docker login --username "$GITLAB_DOCKER_USERNAME" --password-stdin registry.gitlab.com - docker pull registry:5000/django-ci - docker image tag registry.gitlab.com/python-discord/projects/site/django:latest registry:5000/django-ci - docker push registry.gitlab.com/python-discord/projects/site/django:latest only: - master - django