Add gitlab-ci docker-build

This commit is contained in:
Antoine Legrand 2017-05-30 23:06:09 +02:00
parent c568542d77
commit 7e85ac6f89
5 changed files with 116 additions and 182 deletions

View file

@ -1,5 +1,6 @@
---
stages:
- docker-build
- unit-tests
- integration
- release
@ -8,55 +9,75 @@ stages:
variables:
FAILFASTCI_NAMESPACE: 'quay'
IMAGE: quay.io/quay/quay
PIP_CACHE_DIR: /pip-cache
PIP_CACHE_DIR: pip-cache
PIP: /venv/bin/pip
PYTEST: /venv/bin/py.test
TEST: "true"
PYTHONPATH: "."
cache:
paths:
- cache
- /pip-cache
- /apt-cache
key: "$CI_PROJECT_ID"
# STAGE 1: container build
.job: &job
.docker: &docker
variables:
DOCKER_DRIVER: aufs
image: docker:git
before_script:
- mkdir -p /apt-cache
- apt-get update
- apt-get install -o dir::cache::archives="/apt-cache" -y python-dev g++ libjpeg62-dev libevent-dev libldap2-dev libsasl2-dev libpq-dev libffi-dev libgpgme11-dev nodejs jpegoptim optipng w3m
- pip install -r requirements.txt
- pip install -r requirements-tests.txt
- docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io
services:
- docker:dind
tags:
- docker
container-base-build:
<<: *docker
stage: docker-build
script:
- echo test
- docker build --cache-from quay.io/quay/quay-base:latest -t quay.io/quay/quay-base:latest -f quay-base.dockerfile .
- docker push quay.io/quay/quay-base:latest
when: manual
container-build:
<<: *docker
stage: docker-build
script:
- docker build -t quay.io/quay/quay-ci:$CI_COMMIT_REF_SLUG -f quay.dockerfile .
- docker push quay.io/quay/quay-ci:$CI_COMMIT_REF_SLUG
# STAGE 2: Unit tests & code-style
.job: &job
variables:
GIT_STRATEGY: none
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
before_script:
- cd /
- source venv/bin/activate
tags:
- kubernetes
image: quay.io/quay/quay:build
unit-tests:
<<: *job
stage: unit-tests
script:
- py.test --timeout=7200 --verbose --show-count ./ --color=no
- py.test --timeout=7200 --verbose --show-count ./ --color=no -x
registry-tests:
<<: *job
stage: unit-tests
script:
- py.test --timeout=7200 --verbose --show-count ./test/registry_tests.py --color=no
- py.test --timeout=7200 --verbose --show-count ./test/registry_tests.py --color=no -x
karma-tests:
<<: *job
stage: unit-tests
script:
- yarn install --ignore-engines
- yarn test
code-styles:
<<: *job
stage: unit-tests
@ -66,6 +87,7 @@ code-styles:
- echo "pylint"
# Stage 3: Integration/e2e tests
postgres:
<<: *job
variables:
@ -73,60 +95,51 @@ postgres:
SKIP_DB_SCHEMA: 'true'
POSTGRES_PASSWORD: quay
POSTGRES_USER: quay
GIT_STRATEGY: none
stage: integration
services:
- postgres:9.6
script:
- sleep 30
- alembic upgrade head
- py.test --timeout=7200 --verbose --show-count ./ --color=no --ignore=endpoints/appr/test/
- PYTHONPATH="." TEST="true" py.test --timeout=7200 --verbose --show-count ./ --color=no --ignore=endpoints/appr/test/ -x
mysql:
<<: *job
variables:
TEST_DATABASE_URI: mysql+pymysql://quay:quay@localhost/quay
TEST_DATABASE_URI: 'mysql+pymysql://quay:quay@localhost/quay'
SKIP_DB_SCHEMA: 'true'
MYSQL_ROOT_PASSWORD: quay
MYSQL_DATABASE: quay
MYSQL_USER: quay
MYSQL_PASSWORD: quay
GIT_STRATEGY: none
stage: integration
services:
- mysql
script:
- sleep 30
- alembic upgrade head
- py.test --timeout=7200 --verbose --show-count ./ --color=no --ignore=endpoints/appr/test/
- PYTHONPATH="." TEST="true" py.test --timeout=7200 --verbose --show-count ./ --color=no --ignore=endpoints/appr/test/ -x
# # TODO (@ant31)
# .docker: &docker
# e2e-demo:
# <<: *job
# image: python:2.7
# variables:
# DOCKER_HOST: tcp://localhost:2375
# image: docker:git
# TEST_DATABASE_URI: 'postgresql://quay:quay@localhost/quay'
# SKIP_DB_SCHEMA: 'true'
# POSTGRES_PASSWORD: quay
# POSTGRES_USER: quay
# GIT_STRATEGY: none
# stage: integration
# before_script:
# - docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io
# - cd /
# services:
# - docker:dind
# tags:
# - kubernetes
# docker-push:
# <<: *docker
# stage: release
# - postgres:9.6
# - quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
# script:
# - echo "push container to the quay prod repo"
# - docker build --no-cache -t quay.io/quay/quay-branches:$CI_BUILD_REF_NAME .
# - docker push quay.io/quay/quay-branches:$CI_BUILD_REF_NAME
# helm-push:
# <<: *docker
# stage: release
# script:
# - echo "build chart"
# deploy-staging:
# when: manual
# stage: deploy
# script:
# - echo "deploy-staging"
# - sleep 240
# - curl localhost:80/cnr/version
# allow_failure: true