From 3e24b6f4f8f3c778e729e87dec1188315091ce13 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Fri, 30 Nov 2018 15:20:08 +0100 Subject: [PATCH] reDeploy the whole shebang on every merge, So we can have the latest installed on every merge. This closes openshiftio/openshift.io#4602 and closes #127 --- .cico/deploy.sh | 2 ++ .cico/setup.sh | 23 +++++++++++++++++++++++ openshift/deploy-openshift-dev.sh | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.cico/deploy.sh b/.cico/deploy.sh index 48b1691..2fa40cd 100755 --- a/.cico/deploy.sh +++ b/.cico/deploy.sh @@ -8,3 +8,5 @@ source .cico/setup.sh setup deploy + +deploy_devcluster build diff --git a/.cico/setup.sh b/.cico/setup.sh index bd77e65..aa543b7 100755 --- a/.cico/setup.sh +++ b/.cico/setup.sh @@ -17,6 +17,7 @@ function setup() { ghprbGhRepository \ ghprbPullId \ GIT_COMMIT \ + FABRIC8_DEVCLUSTER_TOKEN \ DEVSHIFT_TAG_LEN \ QUAY_USERNAME \ QUAY_PASSWORD \ @@ -116,6 +117,28 @@ function do_coverage() { bash <(curl -s https://codecov.io/bash) -K -X search -f tmp/coverage.out -t 533b56c6-9fec-4ff2-9756-6aea46d46f2b } +function download_latest_oc() { + pushd /bin >/dev/null && \ +curl -s -L $(curl -L -s "https://api.github.com/repos/openshift/origin/releases/latest"|python -c "import sys, json;x=json.load(sys.stdin);print([ r['browser_download_url'] for r in x['assets'] if 'openshift-origin-client-tools' in r['name'] and 'linux-64bit' in r['name']][0])") -o /tmp/oc.tgz && \ + tar xz -f/tmp/oc.tgz --wildcards "*/oc" --strip-components=1 && \ +popd >/dev/null +} + +function deploy_devcluster() { + project="${1}" + + download_latest_oc || { yum install centos-release-openshift-origin && yum install origin-clients ;} + + oc login --insecure-skip-tls-verify=true https://devtools-dev.ext.devshift.net:8443 --token=${FABRIC8_DEVCLUSTER_TOKEN} + + exist=$(oc get project -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'|grep "^${project}$" || true) + if [[ -z ${exist} ]];then + oc new-project ${project} + fi + oc project ${project} + bash ./openshift/deploy-openshift-dev.sh +} + function do_test() { make test-unit } diff --git a/openshift/deploy-openshift-dev.sh b/openshift/deploy-openshift-dev.sh index 061333a..5ecaea3 100755 --- a/openshift/deploy-openshift-dev.sh +++ b/openshift/deploy-openshift-dev.sh @@ -31,7 +31,7 @@ function waitForDC() { local max=60 # 2mn local cnt=0 - while [[ $(oc get dc/${DC} -o json | jq '.status.availableReplicas') < 1 ]];do + while [[ $(oc get dc/${DC} -o json|python -c "import sys, json;x=json.load(sys.stdin);print x['status']['availableReplicas']") < 1 ]];do [[ ${cnt} > ${max} ]] && { echo "Timing out while waiting for DC/${DC}"; exit 1