|
| 1 | +# this file includes an extra end-to-end test which is required to pass |
| 2 | +# for PRs made to any release branch (i.e. a branch whose name follows semantic versioning) |
| 3 | + |
| 4 | +name: Validate IPFS Operator For Release |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: ["release*"] |
| 8 | + tags: ["*"] |
| 9 | + pull_request: |
| 10 | + branches: ["release*"] |
| 11 | + |
| 12 | +env: |
| 13 | + GO_VERSION: "1.18" |
| 14 | + GO111MODULE: "on" |
| 15 | + OPERATOR_IMAGE: "quay.io/redhat-et-ipfs/ipfs-operator" |
| 16 | + BUNDLE_IMAGE: "quay.io/redhat-et-ipfs/ipfs-operator-bundle" |
| 17 | + TAG: "v0.0.1" |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-operator: |
| 21 | + name: Build-operator |
| 22 | + runs-on: ubuntu-20.04 |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout source |
| 26 | + uses: actions/checkout@v2 |
| 27 | + |
| 28 | + - name: Install Go |
| 29 | + uses: actions/setup-go@v1 |
| 30 | + with: |
| 31 | + go-version: ${{ env.GO_VERSION }} |
| 32 | + |
| 33 | + - name: Test |
| 34 | + run: make test |
| 35 | + |
| 36 | + - name: Build operator container |
| 37 | + run: make docker-build IMG="${OPERATOR_IMAGE}" |
| 38 | + |
| 39 | + - name: Export container image |
| 40 | + run: docker save -o /tmp/operator.tar ${OPERATOR_IMAGE} |
| 41 | + |
| 42 | + - name: Save container as artifact |
| 43 | + uses: actions/upload-artifact@v1 |
| 44 | + with: |
| 45 | + name: ipfs-cluster-operator |
| 46 | + path: /tmp/operator.tar |
| 47 | + |
| 48 | + build-bundle: |
| 49 | + name: Build-Bundle |
| 50 | + runs-on: ubuntu-20.04 |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Checkout source |
| 54 | + uses: actions/checkout@v2 |
| 55 | + |
| 56 | + - name: Install Go |
| 57 | + uses: actions/setup-go@v1 |
| 58 | + with: |
| 59 | + go-version: ${{ env.GO_VERSION }} |
| 60 | + |
| 61 | + - name: Install operator-sdk |
| 62 | + run: | |
| 63 | + curl -L -o operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/v1.11.0/operator-sdk_linux_amd64 |
| 64 | + sudo install ./operator-sdk /usr/local/bin && rm operator-sdk |
| 65 | +
|
| 66 | + - name: Make bundle |
| 67 | + run: make bundle |
| 68 | + |
| 69 | + - name: Build bundle |
| 70 | + run: make bundle-build |
| 71 | + |
| 72 | + - name: Export container image |
| 73 | + run: docker save -o /tmp/bundle.tar ${BUNDLE_IMAGE} |
| 74 | + |
| 75 | + - name: Save container as artifact |
| 76 | + uses: actions/upload-artifact@v1 |
| 77 | + with: |
| 78 | + name: operator-bundle |
| 79 | + path: /tmp/bundle.tar |
| 80 | + |
| 81 | + e2e-release: |
| 82 | + name: End-to-end tests |
| 83 | + needs: [ build-bundle, build-operator ] |
| 84 | + runs-on: ubuntu-20.04 |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v2 |
| 87 | + |
| 88 | + - name: Install the Kubectl binary |
| 89 | + run: | |
| 90 | + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" |
| 91 | + sudo install ./kubectl /usr/local/bin/ |
| 92 | + kubectl version --short --client |
| 93 | +
|
| 94 | +
|
| 95 | + - name: Install the Kind binary |
| 96 | + run: | |
| 97 | + curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.12.0/kind-linux-amd64 |
| 98 | + chmod +x ./kind |
| 99 | + sudo mv ./kind /usr/local/bin/kind |
| 100 | + kind version |
| 101 | + |
| 102 | + - name: Create a Kind Cluster |
| 103 | + run: ./hack/setup-kind-cluster.sh |
| 104 | + |
| 105 | + - name: Pull the Container Image from Artifacts |
| 106 | + uses: actions/download-artifact@v1 |
| 107 | + with: |
| 108 | + name: ipfs-cluster-operator |
| 109 | + path: /tmp |
| 110 | + |
| 111 | + - name: Load the Container Image |
| 112 | + run: | |
| 113 | + docker load -i /tmp/operator.tar |
| 114 | + docker inspect ${OPERATOR_IMAGE} |
| 115 | + docker tag ${OPERATOR_IMAGE} ${OPERATOR_IMAGE}:ci-build |
| 116 | + kind load docker-image ${OPERATOR_IMAGE}:ci-build |
| 117 | +
|
| 118 | + - name: Load the Operator into Kind |
| 119 | + run: | |
| 120 | + helm upgrade --install \ |
| 121 | + --debug \ |
| 122 | + --set image.tag="ci-build" \ |
| 123 | + --wait --timeout=300s \ |
| 124 | + ipfs-cluster ./helm/ipfs-operator |
| 125 | +
|
| 126 | + - name: run e2e tests |
| 127 | + shell: bash |
| 128 | + run: | |
| 129 | + mkdir bin |
| 130 | + make test-e2e-release |
| 131 | +
|
| 132 | + push-operator: |
| 133 | + name: Push operator container to registry |
| 134 | + needs: e2e-release |
| 135 | + if: > |
| 136 | + (github.event_name == 'push' || github.event_name == 'schedule') && |
| 137 | + (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) |
| 138 | + runs-on: ubuntu-20.04 |
| 139 | + steps: |
| 140 | + - name: Pull the Container Image from Artifacts |
| 141 | + uses: actions/download-artifact@v1 |
| 142 | + with: |
| 143 | + name: ipfs-cluster-operator |
| 144 | + path: /tmp |
| 145 | + |
| 146 | + - name: Load the Container Image |
| 147 | + run: | |
| 148 | + docker load -i /tmp/operator.tar |
| 149 | + docker inspect ${OPERATOR_IMAGE} |
| 150 | +
|
| 151 | + - name: Login to registry |
| 152 | + # If the registry server is specified in the image name, we use that. |
| 153 | + # If the server isn't in the image name, default to docker.io |
| 154 | + run: | |
| 155 | + [[ "${OPERATOR_IMAGE}" =~ ^([^/]+)/[^/]+/[^/]+ ]] && REGISTRY="${BASH_REMATCH[1]}" || REGISTRY="docker.io" |
| 156 | + echo "Attempting docker login to: ${REGISTRY}" |
| 157 | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin ${REGISTRY} |
| 158 | + - name: Push to registry (version tag) |
| 159 | + if: > |
| 160 | + (github.event_name == 'push' || github.event_name == 'schedule') && |
| 161 | + github.ref == 'refs/heads/main' |
| 162 | + run: | |
| 163 | + docker tag ${OPERATOR_IMAGE} ${OPERATOR_IMAGE}:${TAG} |
| 164 | + docker push "${OPERATOR_IMAGE}:${TAG}" |
| 165 | +
|
| 166 | + push-bundle: |
| 167 | + name: Push bundle container to registry |
| 168 | + needs: e2e-release |
| 169 | + if: > |
| 170 | + (github.event_name == 'push' || github.event_name == 'schedule') && |
| 171 | + (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) |
| 172 | + runs-on: ubuntu-20.04 |
| 173 | + |
| 174 | + steps: |
| 175 | + - name: Load container artifact |
| 176 | + uses: actions/download-artifact@v1 |
| 177 | + with: |
| 178 | + name: operator-bundle |
| 179 | + path: /tmp |
| 180 | + |
| 181 | + - name: Import container image |
| 182 | + run: | |
| 183 | + docker load -i /tmp/bundle.tar |
| 184 | + docker inspect "${BUNDLE_IMAGE}:${{ env.TAG }}" |
| 185 | +
|
| 186 | + - name: Login to registry |
| 187 | + # If the registry server is specified in the image name, we use that. |
| 188 | + # If the server isn't in the image name, default to docker.io |
| 189 | + run: | |
| 190 | + [[ "${BUNDLE_IMAGE}" =~ ^([^/]+)/[^/]+/[^/]+ ]] && REGISTRY="${BASH_REMATCH[1]}" || REGISTRY="docker.io" |
| 191 | + echo "Attempting docker login to: ${REGISTRY}" |
| 192 | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin ${REGISTRY} |
| 193 | + |
| 194 | + - name: Push to registry (version tag) |
| 195 | + if: > |
| 196 | + (github.event_name == 'push' || github.event_name == 'schedule') && |
| 197 | + github.ref == 'refs/heads/main' |
| 198 | + run: | |
| 199 | + echo "Pushing to ${{ env.TAG }}" |
| 200 | + docker push "${BUNDLE_IMAGE}:${{ env.TAG }}" |
0 commit comments