|
14 | 14 | type: string |
15 | 15 | - description: Namespace where the the Operator bundle will be deployed. |
16 | 16 | name: NAMESPACE |
17 | | - default: openshift-builds |
| 17 | + default: default |
18 | 18 | type: string |
19 | 19 | tasks: |
20 | 20 | - name: parse-metadata |
@@ -146,6 +146,8 @@ spec: |
146 | 146 | - bundle |
147 | 147 | - --namespace |
148 | 148 | - "$(params.namespace)" |
| 149 | + - --timeout |
| 150 | + - "10m0s" |
149 | 151 | - "$(params.bundleImage)" |
150 | 152 | - name: e2e-test |
151 | 153 | description: Placeholder task that prints the Snapshot and outputs standard TEST_OUTPUT |
@@ -195,4 +197,83 @@ spec: |
195 | 197 | #!/usr/bin/env bash |
196 | 198 | set -ex -u -o pipefail |
197 | 199 | |
198 | | - oc get all -n openshift-builds |
| 200 | + NAMESPACE="default" # using default since openshift-builds NS is not available |
| 201 | + DEPLOYMENTS=("openshift-builds-operator" "openshift-pipelines-operator" "shipwright-build-controller" "shipwright-build-webhook" "tekton-operator-webhook") |
| 202 | + BUILDS=("buildah-golang-buildrun") |
| 203 | +
|
| 204 | + oc get all -n $NAMESPACE |
| 205 | + # sleep for 5 minutes, give deployments time to get ready |
| 206 | + sleep 300 |
| 207 | + oc get all -n $NAMESPACE |
| 208 | + for DEPLOYMENT in "${DEPLOYMENTS[@]}"; do |
| 209 | + oc wait deployment "$DEPLOYMENT" --namespace="$NAMESPACE" --for="condition=available" --timeout="180s" |
| 210 | + done |
| 211 | +
|
| 212 | + echo "All specified deployments are running and ready." |
| 213 | +
|
| 214 | + # Check running builds |
| 215 | + oc apply -f - <<EOF |
| 216 | + apiVersion: shipwright.io/v1beta1 |
| 217 | + kind: Build |
| 218 | + metadata: |
| 219 | + name: buildah-golang-build |
| 220 | + spec: |
| 221 | + source: |
| 222 | + type: Git |
| 223 | + git: |
| 224 | + url: https://github.com/redhat-openshift-builds/samples |
| 225 | + contextDir: buildah-build |
| 226 | + strategy: |
| 227 | + name: buildah |
| 228 | + kind: ClusterBuildStrategy |
| 229 | + paramValues: |
| 230 | + - name: dockerfile |
| 231 | + value: Dockerfile |
| 232 | + output: |
| 233 | + image: ttl.sh/build-examples-golang:30m |
| 234 | + EOF |
| 235 | +
|
| 236 | + oc apply -f - <<EOF |
| 237 | + apiVersion: shipwright.io/v1beta1 |
| 238 | + kind: BuildRun |
| 239 | + metadata: |
| 240 | + name: buildah-golang-buildrun |
| 241 | + spec: |
| 242 | + build: |
| 243 | + name: buildah-golang-build |
| 244 | + EOF |
| 245 | +
|
| 246 | + # Wait for builds to succeed (with a 10-minute timeout) |
| 247 | + TIMEOUT=600 # 10 minutes |
| 248 | + INTERVAL=30 # Check every 30 seconds |
| 249 | +
|
| 250 | + for BUILD in "${BUILDS[@]}"; do |
| 251 | + START_TIME=$(date +%s) |
| 252 | +
|
| 253 | + while true; do |
| 254 | + CURRENT_TIME=$(date +%s) |
| 255 | + ELAPSED=$((CURRENT_TIME - START_TIME)) |
| 256 | +
|
| 257 | + if [[ $ELAPSED -ge $TIMEOUT ]]; then |
| 258 | + echo "Timeout waiting for build $BUILD. Exiting..." |
| 259 | + exit 1 |
| 260 | + fi |
| 261 | +
|
| 262 | + STATUS=$(kubectl get buildrun "$BUILD" -n "$NAMESPACE" -o jsonpath="{.status.conditions[?(@.type=='Succeeded')].status}" 2>/dev/null || echo "Unknown") |
| 263 | +
|
| 264 | + if [[ "$STATUS" == "True" ]]; then |
| 265 | + echo "Build $BUILD succeeded!" |
| 266 | + break |
| 267 | + elif [[ "$STATUS" == "False" ]]; then |
| 268 | + echo "Build $BUILD failed!" |
| 269 | + exit 1 |
| 270 | + else |
| 271 | + echo "Waiting for build $BUILD to complete... ($ELAPSED/$TIMEOUT seconds)" |
| 272 | + sleep $INTERVAL |
| 273 | + fi |
| 274 | + done |
| 275 | + done |
| 276 | +
|
| 277 | + echo "All builds completed successfully." |
| 278 | +
|
| 279 | +
|
0 commit comments