@@ -114,45 +114,64 @@ jobs:
114114 local server_url="$1"
115115 local cluster_name="$2"
116116
117- [[ -z "$server_url" ]] && return 1
117+ [[ -z "$server_url" ]] && echo " ❌ Server URL is empty" && return 1
118+
119+ echo " 🔗 Attempting login to: $server_url"
118120
119121 # Try to login
120- if ! oc login -u "$OC_USERNAME" -p "$OC_PASSWORD" --server="$server_url" --insecure-skip-tls-verify > /dev/null 2>&1; then
122+ LOGIN_OUTPUT=$(oc login -u "$OC_USERNAME" -p "$OC_PASSWORD" --server="$server_url" --insecure-skip-tls-verify 2>&1) || true
123+ if ! oc whoami > /dev/null 2>&1; then
121124 echo " ❌ Failed to login to $cluster_name"
125+ echo " 📝 Login output: $LOGIN_OUTPUT" | head -5
126+ return 1
127+ fi
128+ echo " ✅ Login successful"
129+
130+ # Get DSC status with full output for debugging
131+ echo " 🔍 Fetching DataScienceCluster status..."
132+ DSC_JSON=$(oc get datasciencecluster -o json 2>&1)
133+ DSC_EXIT_CODE=$?
134+
135+ if [[ $DSC_EXIT_CODE -ne 0 ]]; then
136+ echo " ❌ Failed to get DSC (exit code: $DSC_EXIT_CODE)"
137+ echo " 📝 Output: $DSC_JSON" | head -5
122138 return 1
123139 fi
124140
125- # Get DSC status
126- DSC_JSON=$(oc get datasciencecluster -o json 2>/dev/null)
127- if [[ -z "$DSC_JSON" || "$DSC_JSON" == "null" ]]; then
141+ if [[ -z "$DSC_JSON" || "$DSC_JSON" == "null" || "$DSC_JSON" == '{"apiVersion":"datasciencecluster.opendatahub.io/v1","items":[],"kind":"List","metadata":{"resourceVersion":""}}' ]]; then
128142 echo " ❌ No DataScienceCluster found on $cluster_name"
129143 return 1
130144 fi
131145
146+ # Print DSC name and status for debugging
147+ DSC_NAME=$(echo "$DSC_JSON" | jq -r '.items[0].metadata.name // "unknown"')
148+ echo " 📦 DSC Name: $DSC_NAME"
149+
132150 # Check phase - this is the most reliable indicator
133151 PHASE=$(echo "$DSC_JSON" | jq -r '.items[0].status.phase // "Unknown"')
152+ echo " 📊 DSC Phase: $PHASE"
153+
154+ # Print all conditions for debugging
155+ echo " 📋 DSC Conditions:"
156+ echo "$DSC_JSON" | jq -r '.items[0].status.conditions[]? | " - \(.type): \(.status) (\(.reason // "no reason"))"' 2>/dev/null || echo " (no conditions found)"
134157
135- # If phase is Ready, cluster is healthy - no need to check individual conditions
158+ # If phase is Ready, cluster is healthy
136159 if [[ "$PHASE" == "Ready" ]]; then
137- echo " ✅ DSC phase: Ready"
160+ echo " ✅ DSC is Ready! "
138161 return 0
139162 fi
140163
141164 # Phase not Ready - check conditions for more detail
142- echo " ⚠️ DSC phase: $PHASE (expected Ready)"
143-
144165 AVAILABLE=$(echo "$DSC_JSON" | jq -r '.items[0].status.conditions[] | select(.type=="Available") | .status' 2>/dev/null || echo "")
145166 DEGRADED=$(echo "$DSC_JSON" | jq -r '.items[0].status.conditions[] | select(.type=="Degraded") | .status' 2>/dev/null || echo "")
146167
147- echo " 📊 Conditions: Available=$AVAILABLE, Degraded=$DEGRADED"
148-
149168 # Fallback: if conditions show healthy even though phase isn't Ready
150169 if [[ "$AVAILABLE" == "True" && "$DEGRADED" != "True" ]]; then
151- echo " ✅ Conditions look healthy despite phase"
170+ echo " ✅ Conditions look healthy despite phase=$PHASE "
152171 return 0
153172 fi
154173
155- echo " ❌ DSC not healthy"
174+ echo " ❌ DSC not healthy (Phase: $PHASE, Available: $AVAILABLE, Degraded: $DEGRADED) "
156175 return 1
157176 }
158177
@@ -181,10 +200,13 @@ jobs:
181200 rm -f /tmp/test-variables.yml
182201
183202 # ---------------------------------------------------------------------------
184- # Status - Set pending status on PR
203+ # Status - Set pending status on PR (independent - runs before cluster selection)
185204 # ---------------------------------------------------------------------------
186205 set-pending-status :
187- needs : [select-cluster]
206+ if : >-
207+ github.event_name == 'workflow_dispatch' ||
208+ (github.event.workflow_run.event == 'pull_request' &&
209+ github.event.workflow_run.conclusion == 'success')
188210 runs-on : ubuntu-latest
189211 steps :
190212 - name : Set pending status
@@ -194,7 +216,7 @@ jobs:
194216 gh api repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha || github.sha }} \
195217 -f state=pending \
196218 -f context="Cypress E2E Tests" \
197- -f description="Running on ${{ needs.select-cluster.outputs.cluster_name }} " \
219+ -f description="E2E tests starting... " \
198220 -f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
199221
200222 # ---------------------------------------------------------------------------
@@ -576,22 +598,46 @@ jobs:
576598 # ---------------------------------------------------------------------------
577599 set-final-status :
578600 needs : [select-cluster, e2e-tests]
579- if : always()
601+ if : >-
602+ always() &&
603+ (github.event_name == 'workflow_dispatch' ||
604+ (github.event.workflow_run.event == 'pull_request' &&
605+ github.event.workflow_run.conclusion == 'success'))
580606 runs-on : ubuntu-latest
581607 steps :
582608 - name : Set final status
583609 env :
584610 GH_TOKEN : ${{ github.token }}
585611 run : |
586- RESULT="${{ needs.e2e-tests.result }}"
612+ E2E_RESULT="${{ needs.e2e-tests.result }}"
613+ CLUSTER_RESULT="${{ needs.select-cluster.result }}"
587614 CLUSTER="${{ needs.select-cluster.outputs.cluster_name }}"
588615
589- case "$RESULT" in
590- success) STATE="success"; DESC="All tests passed on $CLUSTER" ;;
591- cancelled) STATE="error"; DESC="Tests cancelled" ;;
592- skipped) exit 0 ;;
593- *) STATE="failure"; DESC="Tests failed on $CLUSTER" ;;
594- esac
616+ echo "📊 Job results: select-cluster=$CLUSTER_RESULT, e2e-tests=$E2E_RESULT"
617+
618+ # Handle cluster selection failure first
619+ if [[ "$CLUSTER_RESULT" == "failure" ]]; then
620+ STATE="failure"
621+ DESC="Cluster health check failed - no healthy cluster available"
622+ elif [[ "$E2E_RESULT" == "success" ]]; then
623+ STATE="success"
624+ DESC="All tests passed on $CLUSTER"
625+ elif [[ "$E2E_RESULT" == "cancelled" ]]; then
626+ STATE="error"
627+ DESC="Tests cancelled"
628+ elif [[ "$E2E_RESULT" == "skipped" && "$CLUSTER_RESULT" == "skipped" ]]; then
629+ # Both skipped means test.yml failed - don't post status
630+ echo "Both jobs skipped (test.yml likely failed) - not posting status"
631+ exit 0
632+ elif [[ "$E2E_RESULT" == "skipped" ]]; then
633+ STATE="failure"
634+ DESC="Tests skipped due to upstream failure"
635+ else
636+ STATE="failure"
637+ DESC="Tests failed on ${CLUSTER:-unknown cluster}"
638+ fi
639+
640+ echo "📝 Posting status: state=$STATE, description=$DESC"
595641
596642 gh api repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha || github.sha }} \
597643 -f state="$STATE" \
@@ -605,7 +651,7 @@ jobs:
605651 cleanup-server :
606652 needs : [e2e-tests]
607653 runs-on : self-hosted
608- if : always()
654+ if : ${{ always() && (github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success')) }}
609655 steps :
610656 - name : Stop Cypress Servers
611657 run : |
0 commit comments