Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Add new build stage in CI
Browse files Browse the repository at this point in the history
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
  • Loading branch information
darkowlzz committed Sep 6, 2019
1 parent 395e552 commit 197cbe4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
38 changes: 30 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- |
Expand All @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions test/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 197cbe4

Please sign in to comment.