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/base_jobs.libsonnet

146 lines
4.4 KiB
Text
Raw Normal View History

function(vars={})
{
dockerBuild: {
// base job to manage containers (build / push)
variables: {
2017-07-18 07:08:33 +00:00
DOCKER_DRIVER: "overlay2",
2017-06-26 13:21:59 +00:00
DOCKER_HOST: "tcp://docker-host.gitlab-runner.svc.cluster.local:2375"
},
2017-06-26 13:21:59 +00:00
image: "docker:git",
before_script: [
"docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io",
],
2017-06-26 13:21:59 +00:00
tags: [
2017-06-26 13:21:59 +00:00
"kubernetes",
],
},
QuayTest: {
// base job to test the container
image: vars.images.quayci.name,
variables: {
TEST: "true",
PYTHONPATH: ".",
QUAYDIR: "/quay-registry",
GIT_STRATEGY: "none",
},
before_script: [
2017-07-06 21:50:38 +00:00
"cd $QUAYDIR",
"source $QUAYDIR/venv/bin/activate",
],
tags: [
"kubernetes",
],
},
QuayDeploy: {
local this = self,
local _vars = self.localvars,
localvars:: {
appversion: "1.0.0-%s" % self.image.tag,
apprepo: "quay.io/quay/%s" % self.appname,
appname: "quay-ci-app",
domain: "quay-%s.k8s.devtable.com" % self.image.tag,
namespace: "ci-quay-%s" % self.image.tag,
image: vars.images.quayci,
channels: [],
pushargs: ["-f"],
buildParams(extra_params={}):: (
local params = {image: _vars.image.name,
tag: _vars.image.tag,
domain: "$QUAY_DOMAIN"} + extra_params;
[
"echo -n %s > VERSION" % _vars.appversion,
'echo %s > params.json' % std.escapeStringJson(params),
"cat params.json"
]),
pushApp(repo="quay.io/quay", extra_args=['-f'], channels=[]):: (
["appr push %s %s" % [repo, std.join(" ", extra_args)]] +
["appr push %s -c %s" % [repo, channel] for channel in channels]
),
},
variables: {K8S_NAMESPACE: _vars.namespace,
QUAY_DOMAIN: _vars.domain},
image: "quay.io/appr/appr:kubectl",
environment: {
name: "review/%s" % _vars.image.tag,
url: "https://%s" % _vars.domain,
},
tags: [
"kubernetes",
],
before_script: [
"appr login -u $DOCKER_USER -p $DOCKER_PASS quay.io",
"cd deploy/%s" % _vars.appname,
] + _vars.buildParams(),
script:
_vars.pushApp(_vars.apprepo, _vars.pushargs, _vars.channels) +
[
"appr deploy %s@%s --namespace %s -x docker_user=$DOCKER_USER -x docker_pass=$DOCKER_PASS" % [
_vars.apprepo,
_vars.appversion,
_vars.namespace],
"kubectl get ingresses -n %s -o wide" % _vars.namespace,
],
},
QuayDeployStop: self.QuayDeploy {
variables+: {GIT_STRATEGY: "none"},
environment+: {
action: "stop"
},
before_script: [],
script: [],
2017-07-14 08:28:19 +00:00
},
EndToEndTest: self.QuayTest {
2017-07-28 11:23:31 +00:00
initDb:: true,
2017-07-14 08:28:19 +00:00
services: [
2017-07-28 11:23:31 +00:00
{name: "postgres:9.6"},
{name: vars.images.quayci.name, alias: 'quay'}
] + if self.initDb == true then [
{name: vars.images.quayci.name,
alias: 'db-init',
command: ["/bin/sh",
"-c",
"sleep 30" +
"&& /quay-registry/venv/bin/python initdb.py" +
"&& sleep 3600",]},
] else [],
before_script: if self.image == vars.images.quayci.name
then super.before_script
else [],
script: ['sleep 150'],
2017-07-14 08:28:19 +00:00
variables+: {
2017-07-28 11:23:31 +00:00
APP_HOST: "localhost:80",
2017-07-14 08:28:19 +00:00
POSTGRES_PASSWORD: "quay",
POSTGRES_USER: "quay",
SKIP_DB_SCHEMA: 'true',
TEST_DATABASE_URI: self['DB_URI'],
2017-07-28 15:13:52 +00:00
QUAY_OVERRIDE_CONFIG: '' + {"SERVER_HOSTNAME": "localhost:80"},
2017-07-14 08:28:19 +00:00
DB_URI: 'postgresql://quay:quay@localhost/quay'
},
},
dbTest(scheme, image, env):: self.QuayTest {
variables+: {
SKIP_DB_SCHEMA: 'true',
TEST_DATABASE_URI: '%s://quay:quay@localhost/quay' % scheme,
} + env,
2017-06-20 09:30:27 +00:00
coverage: @"/^TOTAL.*\s+(\d+\%)\s*$/",
services: [image],
script: [
"sleep 30",
"alembic upgrade head",
'PYTHONPATH="." TEST="true" py.test --timeout=7200 --verbose --show-count ./ --color=no --ignore=endpoints/appr/test/ -x',
],
},
}