Skip to content

Commit b6aeebf

Browse files
committed
fix(ci): replace E2E gate polling with needs dependency
The API polling step fails intermittently due to truncated JSON responses from the GitHub API. Three different error handling approaches (--jq with ||, separated API/jq with ||, set +eo pipefail) all failed under GitHub Actions' bash environment. Replace the polling mechanism with a simple needs: [lint, test-unit] dependency. E2E setup no longer overlaps with lint/unit (~5 min cost), but the step is now 100% reliable. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 894ca93 commit b6aeebf

1 file changed

Lines changed: 2 additions & 55 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ jobs:
451451
name: E2E
452452
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
453453
timeout-minutes: 30
454-
needs: [changes]
454+
needs: [changes, lint, test-unit]
455455
if: needs.changes.outputs.go-source == 'true'
456456
env:
457457
K3D_CLUSTER_NAME: e2e-${{ github.run_id }}-${{ github.run_attempt }}
@@ -473,60 +473,7 @@ jobs:
473473
prometheus-chart-version: ${{ env.PROMETHEUS_CHART_VERSION }}
474474
stress-ng-image: ${{ env.STRESS_NG_IMAGE }}
475475

476-
# Wait for lint and unit tests before running E2E.
477-
# Cluster setup above already ran in parallel with those jobs.
478-
- name: Wait for lint and unit gate
479-
env:
480-
GH_TOKEN: ${{ github.token }}
481-
run: |
482-
echo "Waiting for lint and test-unit jobs to complete..."
483-
for i in $(seq 1 60); do
484-
# Disable errexit for API+jq; command substitution under
485-
# bash -Eeuo pipefail kills the script before || can catch.
486-
set +eo pipefail
487-
raw=$(gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs?per_page=100" 2>/dev/null)
488-
api_rc=$?
489-
jq_rc=1
490-
jobs_json=""
491-
if [[ $api_rc -eq 0 ]]; then
492-
jobs_json=$(echo "$raw" | jq -c '[.jobs[] | select(.name == "Lint" or .name == "Unit Tests") | {name: .name, status: .status, conclusion: .conclusion}]' 2>/dev/null)
493-
jq_rc=$?
494-
fi
495-
set -eo pipefail
496-
497-
if [[ $api_rc -ne 0 || $jq_rc -ne 0 || -z "$jobs_json" ]]; then
498-
echo "API/JSON failed (attempt $i, api=$api_rc jq=$jq_rc), retrying..."
499-
sleep 5; continue
500-
fi
501-
502-
all_done=true
503-
any_failed=false
504-
for row in $(echo "$jobs_json" | jq -c '.[]'); do
505-
status=$(echo "$row" | jq -r '.status')
506-
conclusion=$(echo "$row" | jq -r '.conclusion')
507-
name=$(echo "$row" | jq -r '.name')
508-
if [[ "$status" != "completed" ]]; then
509-
all_done=false
510-
elif [[ "$conclusion" != "success" && "$conclusion" != "skipped" ]]; then
511-
echo "::error::$name failed ($conclusion), aborting E2E"
512-
any_failed=true
513-
fi
514-
done
515-
516-
if [[ "$any_failed" == "true" ]]; then
517-
exit 1
518-
fi
519-
if [[ "$all_done" == "true" ]]; then
520-
echo "Lint and unit tests passed, proceeding with E2E"
521-
break
522-
fi
523-
524-
if (( i == 60 )); then
525-
echo "::error::Timed out waiting for lint/unit (5 min)"
526-
exit 1
527-
fi
528-
sleep 5
529-
done
476+
# Lint and unit tests are guaranteed complete via needs: [lint, test-unit].
530477

531478
- name: Install Chainsaw
532479
uses: kyverno/action-install-chainsaw@1223ef75bedeb59c4e7b5455463d4316e76dff01 # v0.2.15

0 commit comments

Comments
 (0)