From 197cbe44c758ce1633bea68c1c4fcfd047bbcbb3 Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 6 Sep 2019 12:27:12 +0530 Subject: [PATCH] Add new build stage in CI This adds a new build stage in the CI where the container image is built once and pushed to docker hub. The test and deploy stages pull the same image and use it. New docker hub repo: https://hub.docker.com/r/stosci/cluster-operator --- .travis.yml | 38 ++++++++++++++++++++++++++++++-------- test/e2e.sh | 6 +----- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index f82c08526..9623905c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,8 @@ env: - MINIKUBE_VERSION="v0.28.2" - IMAGE_NAME=storageos/cluster-operator - IMAGE_TAG=test + - CI_CONTAINER_REGISTRY=stosci + - CONTAINER_REPO_NAME=cluster-operator before_install: - | @@ -32,43 +34,63 @@ install: true jobs: include: - - go: "1.11" + - stage: build + go: "1.12.9" + name: Build container image + script: + - make image/cluster-operator OPERATOR_IMAGE=$CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID + - docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS" + - docker push $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID + - go: "1.12.9" sudo: required env: - "TEST_CLUSTER=kind" - "INSTALL_METHOD=olm" name: OLM on KinD (k8s-1.13) - script: ./test/e2e.sh $TEST_CLUSTER $INSTALL_METHOD - - go: "1.11" + script: + - docker pull $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID + - docker tag $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID $IMAGE_NAME:$IMAGE_TAG + - ./test/e2e.sh $TEST_CLUSTER $INSTALL_METHOD + - go: "1.12.9" sudo: required env: - "TEST_CLUSTER=openshift" - "INSTALL_METHOD=olm" name: OLM on OpenShift (k8s-1.11) - script: ./test/e2e.sh $TEST_CLUSTER $INSTALL_METHOD + script: + - docker pull $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID + - docker tag $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID $IMAGE_NAME:$IMAGE_TAG + - ./test/e2e.sh $TEST_CLUSTER $INSTALL_METHOD - &base-test - go: "1.11" + go: "1.12.9" sudo: required env: - "TEST_CLUSTER=openshift" - "INSTALL_METHOD=none" name: OpenShift-3.11 (k8s-1.11) - script: ./test/e2e.sh $TEST_CLUSTER $INSTALL_METHOD + script: + - docker pull $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID + - docker tag $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID $IMAGE_NAME:$IMAGE_TAG + - ./test/e2e.sh $TEST_CLUSTER $INSTALL_METHOD - <<: *base-test env: - "TEST_CLUSTER=kind" - "INSTALL_METHOD=none" name: KinD (k8s-1.14) - stage: deploy - go: "1.11" + go: "1.12.9" sudo: required env: - "TEST_CLUSTER=kind" - "INSTALL_METHOD=none" name: Publish Container Image script: - - make image/cluster-operator + # Pull the container from CI container registry and retag it. + - docker pull $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID + - docker tag $CI_CONTAINER_REGISTRY/$CONTAINER_REPO_NAME:$TRAVIS_BUILD_ID $IMAGE_NAME:$IMAGE_TAG + # Generate OLM metadata zip for rhel operator marketplace. - make metadata-zip + # Generate uber manifest file. - OPERATOR_IMAGE=storageos/cluster-operator:$TRAVIS_TAG make generate-install-manifest before_deploy: - docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS" diff --git a/test/e2e.sh b/test/e2e.sh index 21ea12da2..b559cc5a0 100755 --- a/test/e2e.sh +++ b/test/e2e.sh @@ -243,15 +243,11 @@ main() { NODE_NAME=$(kubectl get nodes --no-headers=true -o=name) - # Build the operator container image. - # This would build a container with tag storageos/cluster-operator:test, - # which is used in the e2e test setup below. - make image/cluster-operator - # Move the operator container inside Kind container so that the image is # available to the docker in docker environment. if [ "$1" = "kind" ]; then x=$(docker ps -f name=kind-1-control-plane -q) + # This container image is built separately before running the e2e tests. docker save storageos/cluster-operator:test > cluster-operator.tar docker cp cluster-operator.tar $x:/cluster-operator.tar