Merge pull request #2713 from coreos-inc/alegrand/QUAY-569/show-code-coverage

add coverage report
This commit is contained in:
Antoine Legrand 2017-07-27 12:41:19 +02:00 committed by GitHub
commit af9a6caa49
7 changed files with 70 additions and 21 deletions

4
.coverage.dockerfile Normal file
View file

@ -0,0 +1,4 @@
FROM nginx:alpine
MAINTAINER Antoine Legrand <2t.antoine@gmail.com>
COPY . /usr/share/nginx/html
EXPOSE 80

View file

@ -34,7 +34,7 @@ local jobs = {
// Update the base container
stage: stages.docker_base,
script: [
'docker build --cache-from quay.io/quay/quay-base:latest' +
'docker build --no-cache' +
' -t %s -f quay-base.dockerfile .' % images.base.name,
'docker push %s' % images.base.name,
],
@ -46,6 +46,10 @@ local jobs = {
stage: stages.docker_build,
script: [
'docker build -t %s -f Dockerfile .' % images.quayci.name,
'docker run --rm %s cat ALEMBIC_HEAD > /tmp/ALEMBIC_HEAD' % images.quayci.name,
'export MIGRATION_HEAD=`cat /tmp/ALEMBIC_HEAD | cut -d" " -f1`',
'echo $MIGRATION_HEAD',
'docker build --label db-schema-head=$MIGRATION_HEAD -t %s -f Dockerfile .' % images.quayci.name,
'docker push %s' % images.quayci.name],
},
@ -64,13 +68,24 @@ local jobs = {
// Unit-tests
local unittest_stage = baseJob.QuayTest {
stage: stages.unit_tests },
local pytest_cmd = 'py.test --cov="." --cov-report=html --cov-report=term-missing' +
' --timeout=3600 --verbose -x --color=no --show-count ',
'unit-tests': unittest_stage {
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
script: [
'py.test --timeout=7200 --verbose --show-count ./ --color=no -x'] },
pytest_cmd + ' ./',],
after_script: [
'cp -r $QUAYDIR/htmlcov/ $CI_PROJECT_DIR/coverage'
],
artifacts: {
paths: ['coverage',]
}
},
'registry-tests': unittest_stage {
script: [
'py.test --timeout=7200 --verbose --show-count ./test/registry_tests.py --color=no -x'] },
script: [ pytest_cmd + ' ./test/registry_tests.py'],
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
},
// UI tests
'karma-tests': unittest_stage {
@ -85,6 +100,7 @@ local jobs = {
// Unit-tests with real databases
local db_stage = { stage: stages.unit_tests },
local dbname = 'quay',
postgres: db_stage + baseJob.dbTest('postgresql',
image='postgres:9.6',
env={ POSTGRES_PASSWORD: dbname, POSTGRES_USER: dbname }),

View file

@ -9,7 +9,7 @@ container-base-build:
- master
- tags
script:
- docker build --cache-from quay.io/quay/quay-base:latest -t quay.io/quay/quay-base:latest -f quay-base.dockerfile .
- docker build --no-cache -t quay.io/quay/quay-base:latest -f quay-base.dockerfile .
- docker push quay.io/quay/quay-base:latest
stage: docker_base
tags:
@ -23,6 +23,10 @@ container-build:
image: docker:git
script:
- docker build -t quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} -f Dockerfile .
- docker run --rm quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} cat ALEMBIC_HEAD > /tmp/ALEMBIC_HEAD
- export MIGRATION_HEAD=`cat /tmp/ALEMBIC_HEAD | cut -d" " -f1`
- echo $MIGRATION_HEAD
- docker build --label db-schema-head=$MIGRATION_HEAD -t quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} -f Dockerfile .
- docker push quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
stage: docker_build
tags:
@ -39,8 +43,8 @@ container-release:
- tags
script:
- docker pull quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
- docker tag quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}
- docker push quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}
- docker tag quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${SHA8}
- docker push quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${SHA8}
stage: docker_release
tags:
- kubernetes
@ -78,8 +82,8 @@ deploy-staging:
before_script:
- appr login -u $DOCKER_USER -p $DOCKER_PASS quay.io
- cd deploy/quay-ci-app
- echo -n 1.0.0-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA} > VERSION
- 'echo "{\"domain\": \"$QUAY_DOMAIN\", \"image\": \"quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}\", \"tag\": \"${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}\"}" > params.json'
- echo -n 1.0.0-${CI_COMMIT_REF_SLUG}-${SHA8} > VERSION
- 'echo "{\"domain\": \"$QUAY_DOMAIN\", \"image\": \"quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${SHA8}\", \"tag\": \"${CI_COMMIT_REF_SLUG}-${SHA8}\"}" > params.json'
- cat params.json
environment:
name: staging
@ -92,7 +96,7 @@ deploy-staging:
- appr push quay.io/quay/quay-ci-app -c master
- appr push quay.io/quay/quay-ci-app -c beta
- appr push quay.io/quay/quay-ci-app -c latest
- appr deploy quay.io/quay/quay-ci-app@1.0.0-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA} --namespace ci-staging -x docker_user=$DOCKER_USER -x docker_pass=$DOCKER_PASS
- appr deploy quay.io/quay/quay-ci-app@1.0.0-${CI_COMMIT_REF_SLUG}-${SHA8} --namespace ci-staging -x docker_user=$DOCKER_USER -x docker_pass=$DOCKER_PASS
- kubectl get ingresses -n ci-staging -o wide
stage: deploy_staging
tags:
@ -123,6 +127,7 @@ mysql:
before_script:
- cd $QUAYDIR
- source $QUAYDIR/venv/bin/activate
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
script:
- sleep 30
@ -148,6 +153,7 @@ postgres:
before_script:
- cd $QUAYDIR
- source $QUAYDIR/venv/bin/activate
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
script:
- sleep 30
@ -171,9 +177,10 @@ registry-tests:
before_script:
- cd $QUAYDIR
- source $QUAYDIR/venv/bin/activate
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
script:
- py.test --timeout=7200 --verbose --show-count ./test/registry_tests.py --color=no -x
- py.test --cov="." --cov-report=html --cov-report=term-missing --timeout=3600 --verbose -x --color=no --show-count ./test/registry_tests.py
stage: unit_tests
tags:
- kubernetes
@ -214,12 +221,18 @@ stop-preview:
QUAY_DOMAIN: quay-${CI_COMMIT_REF_SLUG}.k8s.devtable.com
when: manual
unit-tests:
after_script:
- cp -r $QUAYDIR/htmlcov/ $CI_PROJECT_DIR/coverage
artifacts:
paths:
- coverage
before_script:
- cd $QUAYDIR
- source $QUAYDIR/venv/bin/activate
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
script:
- py.test --timeout=7200 --verbose --show-count ./ --color=no -x
- py.test --cov="." --cov-report=html --cov-report=term-missing --timeout=3600 --verbose -x --color=no --show-count ./
stage: unit_tests
tags:
- kubernetes

View file

@ -106,6 +106,7 @@ function(vars={})
SKIP_DB_SCHEMA: 'true',
TEST_DATABASE_URI: '%s://quay:quay@localhost/quay' % scheme,
} + env,
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
services: [image],
script: [
"sleep 30",

View file

@ -15,11 +15,16 @@ local utils = import "utils.libsonnet";
// release is a copy of the quayci image to the 'prod' repository
release: { repo: "quay.io/quay/quay",
tag: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}",
tag: "${CI_COMMIT_REF_SLUG}-${SHA8}",
name: utils.containerName(self.repo, self.tag),
},
quayci: { repo: "quay.io/quay/quay-ci", tag: "${CI_COMMIT_REF_SLUG}",
quayci: { repo: "quay.io/quay/quay-ci",
tag: "${CI_COMMIT_REF_SLUG}",
name: utils.containerName(self.repo, self.tag),
},
coverage: { repo: "quay.io/quay/quay-coverage", tag: "${CI_COMMIT_REF_SLUG}",
name: utils.containerName(self.repo, self.tag),
},
},

View file

@ -40,12 +40,20 @@ conf/stack/license: $(QUAY_CONFIG)/local/license
mkdir -p conf/stack
ln -s $(QUAY_CONFIG)/local/license conf/stack/license
unit:
TEST=true PYTHONPATH="." py.test --timeout=3600 --verbose -x ./
unit-test:
TEST=true PYTHONPATH="." py.test \
--cov="." --cov-report=html --cov-report=term-missing \
--timeout=3600 --verbose -x \
./
registry-test:
TEST=true PYTHONPATH="." py.test \
--cov="." --cov-report=html --cov-report=term-missing \
--timeout=3600 --verbose --show-count -x \
test/registry_tests.py
test: unit-test registry-test
test: unit test/registry_tests.py
TEST=true PYTHONPATH="." py.test --timeout=3600 --verbose --show-count -x \
test/registry_tests.py
PG_PASSWORD := quay
PG_USER := quay

View file

@ -9,7 +9,9 @@ branch = True
[coverage:report]
omit =
test/*
test/**
venv/**
**/test/**
[pep8]
ignore = E111,E114
@ -17,4 +19,4 @@ max-line-length = 100
[flake8]
ignore = E111,E114
max-line-length = 100
max-line-length = 100