2017-06-13 03:55:12 +00:00
|
|
|
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-13 03:55:12 +00:00
|
|
|
},
|
2017-06-26 13:21:59 +00:00
|
|
|
|
2017-06-13 03:55:12 +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
|
|
|
|
2017-06-13 03:55:12 +00:00
|
|
|
tags: [
|
2017-06-26 13:21:59 +00:00
|
|
|
"kubernetes",
|
2017-06-13 03:55:12 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
QuayTest: {
|
|
|
|
// base job to test the container
|
|
|
|
image: vars.images.quayci.name,
|
|
|
|
variables: {
|
|
|
|
TEST: "true",
|
|
|
|
PYTHONPATH: ".",
|
2017-02-01 23:17:25 +00:00
|
|
|
QUAYDIR: "/quay-registry",
|
2017-06-13 03:55:12 +00:00
|
|
|
GIT_STRATEGY: "none",
|
|
|
|
},
|
|
|
|
before_script: [
|
2017-07-06 21:50:38 +00:00
|
|
|
"cd $QUAYDIR",
|
|
|
|
"source $QUAYDIR/venv/bin/activate",
|
2017-06-13 03:55:12 +00:00
|
|
|
],
|
|
|
|
tags: [
|
|
|
|
"kubernetes",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2017-07-16 23:24:31 +00:00
|
|
|
QuayDeploy: {
|
2017-07-19 22:34:08 +00:00
|
|
|
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},
|
2017-07-16 23:24:31 +00:00
|
|
|
image: "quay.io/appr/appr:kubectl",
|
|
|
|
environment: {
|
2017-07-19 22:34:08 +00:00
|
|
|
name: "review/%s" % _vars.image.tag,
|
|
|
|
url: "https://%s" % _vars.domain,
|
2017-07-16 23:24:31 +00:00
|
|
|
},
|
|
|
|
tags: [
|
|
|
|
"kubernetes",
|
|
|
|
],
|
2017-07-19 22:34:08 +00:00
|
|
|
|
2017-07-16 23:24:31 +00:00
|
|
|
before_script: [
|
2017-07-19 22:34:08 +00:00
|
|
|
"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,
|
2017-07-16 23:24:31 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
QuayDeployStop: self.QuayDeploy {
|
2017-07-19 22:34:08 +00:00
|
|
|
variables+: {GIT_STRATEGY: "none"},
|
2017-07-16 23:24:31 +00:00
|
|
|
environment+: {
|
|
|
|
action: "stop"
|
|
|
|
},
|
2017-07-19 22:34:08 +00:00
|
|
|
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'
|
|
|
|
},
|
2017-07-16 23:24:31 +00:00
|
|
|
},
|
|
|
|
|
2017-06-13 03:55:12 +00:00
|
|
|
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*$/",
|
2017-06-13 03:55:12 +00:00
|
|
|
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',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}
|