stages: - lint - test - publish - deploy image: python:3.7-alpine .test-template: &test-template stage: test services: - postgres:10-alpine script: - python manage.py test tags: - docker variables: DATABASE_URL: postgres://django:supersecret@postgres/pysite POSTGRES_DB: pysite POSTGRES_PASSWORD: supersecret POSTGRES_USER: django lint: stage: lint before_script: - apk add python3-dev git libpq postgresql-dev gcc cmake autoconf automake musl-dev - python3 -m pip install --no-cache-dir .[lint] script: - flake8 tags: - docker test-3.7-alpine: <<: *test-template image: python:3.7-alpine before_script: - apk add python3-dev git libpq postgresql-dev gcc cmake autoconf automake musl-dev - python3 -m pip install --no-cache-dir .[test] - python manage.py migrate script: - coverage run --source=api,home,pysite,wiki --branch manage.py test after_script: - coverage report artifacts: paths: - .coverage test-3.6-alpine: <<: *test-template image: python:3.6-alpine before_script: - apk add git libpq postgresql-dev gcc cmake autoconf automake musl-dev - python3 -m pip install --no-cache-dir .[test] - python manage.py migrate test-3.7-stretch: <<: *test-template image: python:3.7-stretch services: - postgres:11 before_script: - apt-get update -y - apt-get install -y git libpq-dev gcc cmake autoconf automake libc-dev - python3 -m pip install --no-cache-dir .[test] - python manage.py migrate test-3.6-stretch: <<: *test-template image: python:3.6-stretch services: - postgres:11 before_script: - apt-get update -y - apt-get install -y git libpq-dev gcc cmake autoconf automake libc-dev - python3 -m pip install --no-cache-dir .[test] - python manage.py migrate pages: stage: publish dependencies: - test-3.7-alpine before_script: - pip install coverage script: - coverage html --directory=public artifacts: paths: - public expire_in: 30 days push-django: image: docker:stable-git stage: publish script: - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin - docker build -t pythondiscord/django:latest . - docker push pythondiscord/django:latest only: - master - django tags: - docker deploy: stage: deploy image: alpine:latest before_script: - apk add --no-cache openssh-client - echo "$DJANGO_DEPLOY_SSH_PRIVATE_KEY" > privkey script: - ssh -i privkey -p 583 pysite-deploy@jchri.st environment: name: Django staging url: https://pysite.jchri.st tags: - docker