Merge pull request #2713 from coreos-inc/alegrand/QUAY-569/show-code-coverage
add coverage report
This commit is contained in:
commit
af9a6caa49
7 changed files with 70 additions and 21 deletions
4
.coverage.dockerfile
Normal file
4
.coverage.dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM nginx:alpine
|
||||||
|
MAINTAINER Antoine Legrand <2t.antoine@gmail.com>
|
||||||
|
COPY . /usr/share/nginx/html
|
||||||
|
EXPOSE 80
|
|
@ -34,7 +34,7 @@ local jobs = {
|
||||||
// Update the base container
|
// Update the base container
|
||||||
stage: stages.docker_base,
|
stage: stages.docker_base,
|
||||||
script: [
|
script: [
|
||||||
'docker build --cache-from quay.io/quay/quay-base:latest' +
|
'docker build --no-cache' +
|
||||||
' -t %s -f quay-base.dockerfile .' % images.base.name,
|
' -t %s -f quay-base.dockerfile .' % images.base.name,
|
||||||
'docker push %s' % images.base.name,
|
'docker push %s' % images.base.name,
|
||||||
],
|
],
|
||||||
|
@ -46,6 +46,10 @@ local jobs = {
|
||||||
stage: stages.docker_build,
|
stage: stages.docker_build,
|
||||||
script: [
|
script: [
|
||||||
'docker build -t %s -f Dockerfile .' % images.quayci.name,
|
'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],
|
'docker push %s' % images.quayci.name],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -64,13 +68,24 @@ local jobs = {
|
||||||
// Unit-tests
|
// Unit-tests
|
||||||
local unittest_stage = baseJob.QuayTest {
|
local unittest_stage = baseJob.QuayTest {
|
||||||
stage: stages.unit_tests },
|
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 {
|
'unit-tests': unittest_stage {
|
||||||
|
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
|
||||||
script: [
|
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 {
|
'registry-tests': unittest_stage {
|
||||||
script: [
|
script: [ pytest_cmd + ' ./test/registry_tests.py'],
|
||||||
'py.test --timeout=7200 --verbose --show-count ./test/registry_tests.py --color=no -x'] },
|
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
|
||||||
|
},
|
||||||
|
|
||||||
// UI tests
|
// UI tests
|
||||||
'karma-tests': unittest_stage {
|
'karma-tests': unittest_stage {
|
||||||
|
@ -85,6 +100,7 @@ local jobs = {
|
||||||
// Unit-tests with real databases
|
// Unit-tests with real databases
|
||||||
local db_stage = { stage: stages.unit_tests },
|
local db_stage = { stage: stages.unit_tests },
|
||||||
local dbname = 'quay',
|
local dbname = 'quay',
|
||||||
|
|
||||||
postgres: db_stage + baseJob.dbTest('postgresql',
|
postgres: db_stage + baseJob.dbTest('postgresql',
|
||||||
image='postgres:9.6',
|
image='postgres:9.6',
|
||||||
env={ POSTGRES_PASSWORD: dbname, POSTGRES_USER: dbname }),
|
env={ POSTGRES_PASSWORD: dbname, POSTGRES_USER: dbname }),
|
||||||
|
|
|
@ -9,7 +9,7 @@ container-base-build:
|
||||||
- master
|
- master
|
||||||
- tags
|
- tags
|
||||||
script:
|
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
|
- docker push quay.io/quay/quay-base:latest
|
||||||
stage: docker_base
|
stage: docker_base
|
||||||
tags:
|
tags:
|
||||||
|
@ -23,6 +23,10 @@ container-build:
|
||||||
image: docker:git
|
image: docker:git
|
||||||
script:
|
script:
|
||||||
- docker build -t quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} -f Dockerfile .
|
- 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}
|
- docker push quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
||||||
stage: docker_build
|
stage: docker_build
|
||||||
tags:
|
tags:
|
||||||
|
@ -39,8 +43,8 @@ container-release:
|
||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- docker pull quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
- 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 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}-${CI_COMMIT_SHA}
|
- docker push quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${SHA8}
|
||||||
stage: docker_release
|
stage: docker_release
|
||||||
tags:
|
tags:
|
||||||
- kubernetes
|
- kubernetes
|
||||||
|
@ -78,8 +82,8 @@ deploy-staging:
|
||||||
before_script:
|
before_script:
|
||||||
- appr login -u $DOCKER_USER -p $DOCKER_PASS quay.io
|
- appr login -u $DOCKER_USER -p $DOCKER_PASS quay.io
|
||||||
- cd deploy/quay-ci-app
|
- cd deploy/quay-ci-app
|
||||||
- echo -n 1.0.0-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA} > VERSION
|
- echo -n 1.0.0-${CI_COMMIT_REF_SLUG}-${SHA8} > 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 "{\"domain\": \"$QUAY_DOMAIN\", \"image\": \"quay.io/quay/quay:${CI_COMMIT_REF_SLUG}-${SHA8}\", \"tag\": \"${CI_COMMIT_REF_SLUG}-${SHA8}\"}" > params.json'
|
||||||
- cat params.json
|
- cat params.json
|
||||||
environment:
|
environment:
|
||||||
name: staging
|
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 master
|
||||||
- appr push quay.io/quay/quay-ci-app -c beta
|
- appr push quay.io/quay/quay-ci-app -c beta
|
||||||
- appr push quay.io/quay/quay-ci-app -c latest
|
- 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
|
- kubectl get ingresses -n ci-staging -o wide
|
||||||
stage: deploy_staging
|
stage: deploy_staging
|
||||||
tags:
|
tags:
|
||||||
|
@ -123,6 +127,7 @@ mysql:
|
||||||
before_script:
|
before_script:
|
||||||
- cd $QUAYDIR
|
- cd $QUAYDIR
|
||||||
- source $QUAYDIR/venv/bin/activate
|
- source $QUAYDIR/venv/bin/activate
|
||||||
|
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
|
||||||
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
||||||
script:
|
script:
|
||||||
- sleep 30
|
- sleep 30
|
||||||
|
@ -148,6 +153,7 @@ postgres:
|
||||||
before_script:
|
before_script:
|
||||||
- cd $QUAYDIR
|
- cd $QUAYDIR
|
||||||
- source $QUAYDIR/venv/bin/activate
|
- source $QUAYDIR/venv/bin/activate
|
||||||
|
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
|
||||||
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
||||||
script:
|
script:
|
||||||
- sleep 30
|
- sleep 30
|
||||||
|
@ -171,9 +177,10 @@ registry-tests:
|
||||||
before_script:
|
before_script:
|
||||||
- cd $QUAYDIR
|
- cd $QUAYDIR
|
||||||
- source $QUAYDIR/venv/bin/activate
|
- source $QUAYDIR/venv/bin/activate
|
||||||
|
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
|
||||||
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
||||||
script:
|
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
|
stage: unit_tests
|
||||||
tags:
|
tags:
|
||||||
- kubernetes
|
- kubernetes
|
||||||
|
@ -214,12 +221,18 @@ stop-preview:
|
||||||
QUAY_DOMAIN: quay-${CI_COMMIT_REF_SLUG}.k8s.devtable.com
|
QUAY_DOMAIN: quay-${CI_COMMIT_REF_SLUG}.k8s.devtable.com
|
||||||
when: manual
|
when: manual
|
||||||
unit-tests:
|
unit-tests:
|
||||||
|
after_script:
|
||||||
|
- cp -r $QUAYDIR/htmlcov/ $CI_PROJECT_DIR/coverage
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- coverage
|
||||||
before_script:
|
before_script:
|
||||||
- cd $QUAYDIR
|
- cd $QUAYDIR
|
||||||
- source $QUAYDIR/venv/bin/activate
|
- source $QUAYDIR/venv/bin/activate
|
||||||
|
coverage: /^TOTAL.*\s+(\d+\%)\s*$/
|
||||||
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG}
|
||||||
script:
|
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
|
stage: unit_tests
|
||||||
tags:
|
tags:
|
||||||
- kubernetes
|
- kubernetes
|
||||||
|
|
|
@ -106,6 +106,7 @@ function(vars={})
|
||||||
SKIP_DB_SCHEMA: 'true',
|
SKIP_DB_SCHEMA: 'true',
|
||||||
TEST_DATABASE_URI: '%s://quay:quay@localhost/quay' % scheme,
|
TEST_DATABASE_URI: '%s://quay:quay@localhost/quay' % scheme,
|
||||||
} + env,
|
} + env,
|
||||||
|
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
|
||||||
services: [image],
|
services: [image],
|
||||||
script: [
|
script: [
|
||||||
"sleep 30",
|
"sleep 30",
|
||||||
|
|
|
@ -15,11 +15,16 @@ local utils = import "utils.libsonnet";
|
||||||
|
|
||||||
// release is a copy of the quayci image to the 'prod' repository
|
// release is a copy of the quayci image to the 'prod' repository
|
||||||
release: { repo: "quay.io/quay/quay",
|
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),
|
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),
|
name: utils.containerName(self.repo, self.tag),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
18
Makefile
18
Makefile
|
@ -40,12 +40,20 @@ conf/stack/license: $(QUAY_CONFIG)/local/license
|
||||||
mkdir -p conf/stack
|
mkdir -p conf/stack
|
||||||
ln -s $(QUAY_CONFIG)/local/license conf/stack/license
|
ln -s $(QUAY_CONFIG)/local/license conf/stack/license
|
||||||
|
|
||||||
unit:
|
unit-test:
|
||||||
TEST=true PYTHONPATH="." py.test --timeout=3600 --verbose -x ./
|
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_PASSWORD := quay
|
||||||
PG_USER := quay
|
PG_USER := quay
|
||||||
|
|
|
@ -9,7 +9,9 @@ branch = True
|
||||||
|
|
||||||
[coverage:report]
|
[coverage:report]
|
||||||
omit =
|
omit =
|
||||||
test/*
|
test/**
|
||||||
|
venv/**
|
||||||
|
**/test/**
|
||||||
|
|
||||||
[pep8]
|
[pep8]
|
||||||
ignore = E111,E114
|
ignore = E111,E114
|
||||||
|
|
Reference in a new issue