Commit 49a15b3c authored by totte's avatar totte

Initial commit

parent 8ef3c9c4

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

[run]
source = .
omit =
venv/*
manage.py
*/wsgi.py
*/migrations/*
*/__init__.py
.idea/
.coverage
.dockerignore
.env
.git
.gitignore
.gitlab-ci.yml
venv/
Dockerfile
docker-compose.override.yml
docker-compose.test.yml
docker-compose.yml
melange.service
nginx.conf
nginx.production.conf
nginx.staging.conf
README.md
TODO.md
.coverage
.env
venv/
.idea/
stages:
- test source
- build images
- test images
- release
- deploy
# Job 1
flake8:
except:
- tags
stage: test source
image: python:3.7.2
before_script:
- pip install flake8
script:
- flake8 .
# Job 2
pylint:
except:
- tags
stage: test source
image: python:3.7.2
before_script:
- pip install pylint
script:
- find -name '*.py' -not -path "./venv/*" -not -path "./*/migrations/*" | xargs pylint -j 0 --rcfile=.pylintrc | tee pylint.log || exit 0
# Job 3
unit test:
except:
- tags
stage: test source
image: python:3.7.2
services:
- postgres:11.2
variables:
DATABASE_URL: postgres://postgres@postgres:5432/postgres
SECRET_KEY: $TEST_SECRET_KEY
before_script:
- pip install pipenv
- pipenv install --system
script:
- python manage.py test
# Job 4
amd64 image:
only:
- master
tags:
- x86_64
stage: build images
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build -t ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:$CI_COMMIT_REF_NAME .
- docker push ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:$CI_COMMIT_REF_NAME
# Job 5
arm image:
only:
- master
tags:
- armv71
stage: build images
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build -t ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:$CI_COMMIT_REF_NAME .
- docker push ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:$CI_COMMIT_REF_NAME
# Job 6
amd64 unit test:
only:
- master
tags:
- x86_64
stage: test images
image: docker:stable
services:
- docker:dind
- postgres:11.2
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
TEST_IMAGE: ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:$CI_COMMIT_REF_NAME
SECRET_KEY: $TEST_SECRET_KEY
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- apk add --no-cache py-pip
- pip install docker-compose~=1.23.0
script:
- docker pull $TEST_IMAGE
- env | grep -i postgres
- env | grep POSTGRES_PORT_5432_TCP_ADDR
- docker run postgres:11.2 psql -d postgres -U postgres -h $POSTGRES_PORT_5432_TCP_ADDR -c 'SELECT version();'
- export POSTGRES_HOST=${POSTGRES_PORT_5432_TCP_ADDR}
- docker-compose -f docker-compose.test.yml -p test up --abort-on-container-exit
# Job 7
arm unit test:
only:
- master
tags:
- armv71
stage: test images
image: docker:stable
services:
- docker:dind
- postgres:11.2
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
TEST_IMAGE: ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:$CI_COMMIT_REF_NAME
SECRET_KEY: $TEST_SECRET_KEY
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- apk add --no-cache py-pip
- pip install docker-compose~=1.23.0
script:
- docker pull $TEST_IMAGE
- env | grep -i postgres
- env | grep POSTGRES_PORT_5432_TCP_ADDR
- docker run postgres:11.2 psql -d postgres -U postgres -h $POSTGRES_PORT_5432_TCP_ADDR -c 'SELECT version();'
- export POSTGRES_HOST=${POSTGRES_PORT_5432_TCP_ADDR}
- docker-compose -f docker-compose.test.yml -p test up --abort-on-container-exit
# Job 8
staging images:
only:
- master
stage: release
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
before_script:
- export DOCKER_CLI_EXPERIMENTAL=enabled
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker pull ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:$CI_COMMIT_REF_NAME
- docker tag ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:$CI_COMMIT_REF_NAME ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:latest
- docker push ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:latest
- docker pull ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:$CI_COMMIT_REF_NAME
- docker tag ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:$CI_COMMIT_REF_NAME ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:latest
- docker push ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:latest
- docker manifest create ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm:latest ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64:latest
- docker manifest annotate --arch arm --variant v7 --os linux ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-arm
- docker manifest annotate --arch amd64 --os linux ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}-amd64
- docker manifest push ${CI_REGISTRY_IMAGE}:latest