This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/.gitlab-ci.jsonnet

149 lines
4.2 KiB
Text
Raw Normal View History

local utils = import '.gitlab-ci/utils.libsonnet';
local vars = import '.gitlab-ci/vars.libsonnet';
local mergeJob = utils.ci.mergeJob;
local images = vars.images;
local baseJob = (import '.gitlab-ci/base_jobs.libsonnet')(vars);
local stages_list = [
// gitlab-ci stages
'docker_base',
'docker_build',
'deploy_preview',
'unit_tests',
'integration',
'docker_release',
'deploy_staging',
'teardown',
];
2017-06-26 13:21:59 +00:00
local stages = utils.set(stages_list);
// List CI jobs
local jobs = {
// Helpers
local onlyMaster = {
only: ['master', 'tags'],
},
local onlyBranch = {
only: ['branches'],
2017-07-20 13:15:20 +00:00
except: ['master']
},
'container-base-build': baseJob.dockerBuild + onlyMaster {
// ! Only master/tags
// Update the base container
stage: stages.docker_base,
script: [
'docker build --cache-from quay.io/quay/quay-base:latest' +
' -t %s -f quay-base.dockerfile .' % images.base.name,
'docker push %s' % images.base.name,
],
},
'container-build': baseJob.dockerBuild {
// Build and push the quay container.
// Docker Tag is the branch/tag name
stage: stages.docker_build,
script: [
2017-07-06 21:50:38 +00:00
'docker build -t %s -f Dockerfile .' % images.quayci.name,
'docker push %s' % images.quayci.name],
},
'container-release': baseJob.dockerBuild + onlyMaster {
// ! Only master/tags
// push the container to the 'prod' repository
local repo_with_sha = images.release.name,
stage: stages.docker_release,
script: [
'docker pull %s' % images.quayci.name,
'docker tag %s %s' % [images.quayci.name, repo_with_sha],
'docker push %s' % [repo_with_sha], # @TODO(ant31) add signing
],
},
// Unit-tests
local unittest_stage = baseJob.QuayTest {
stage: stages.unit_tests },
2017-06-20 09:30:27 +00:00
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 {
2017-06-20 09:30:27 +00:00
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
script: [
2017-06-20 09:30:27 +00:00
pytest_cmd + ' ./',],
after_script: [
'cp -r $QUAYDIR/htmlcov/ $CI_PROJECT_DIR/coverage'
],
artifacts: {
paths: ['coverage',]
}
},
'registry-tests': unittest_stage {
2017-06-20 09:30:27 +00:00
script: [ pytest_cmd + ' ./test/registry_tests.py'],
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
},
// UI tests
'karma-tests': unittest_stage {
script: [
'curl -Ss https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -',
'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list',
'apt-get update -yqqq',
'apt-get install -y google-chrome-stable',
'yarn test'
] },
// Unit-tests with real databases
local db_stage = { stage: stages.unit_tests },
local dbname = 'quay',
2017-06-20 09:30:27 +00:00
postgres: db_stage + baseJob.dbTest('postgresql',
image='postgres:9.6',
env={ POSTGRES_PASSWORD: dbname, POSTGRES_USER: dbname }),
mysql: db_stage + baseJob.dbTest('mysql+pymysql',
image='mysql:latest',
env={ [key]: dbname for key in ['MYSQL_ROOT_PASSWORD', 'MYSQL_DATABASE',
'MYSQL_USER', 'MYSQL_PASSWORD'] }),
"deploy-preview": baseJob.QuayDeploy {
local _vars = self.localvars,
stage: stages.deploy_preview,
when: "manual",
environment+: {
on_stop: "stop-preview",
},
} + onlyBranch,
"stop-preview": baseJob.QuayDeployStop {
when: "manual",
stage: stages.deploy_preview,
script: [
"kubectl delete ns $K8S_NAMESPACE",
"kubectl get pods -o wide -n $K8S_NAMESPACE"
]
} + onlyBranch,
"deploy-staging": baseJob.QuayDeploy {
local _vars = self.localvars,
localvars+:: {
image: images.release,
domain: "quay-staging.k8s.devtable.com",
namespace: "ci-staging",
channels: ['master' , 'beta', 'latest'],
},
stage: stages.deploy_staging,
script+: [],
environment+: {
name: "staging",
},
only: ['master']
},
};
{
stages: stages_list,
variables: vars.global,
} + jobs