@@ -20,7 +20,80 @@ defaults:
2020 working-directory : ./
2121
2222jobs :
23+ # Wait for CI checks to pass before running E2E tests
24+ wait-for-ci :
25+ name : Wait for CI checks
26+ runs-on : ubuntu-latest
27+ if : github.event_name == 'pull_request'
28+ steps :
29+ - name : Wait for CI workflow
30+ uses : actions/github-script@v7
31+ with :
32+ script : |
33+ const checkNames = [
34+ 'Build',
35+ 'Unit Tests',
36+ 'Linting',
37+ 'License Check',
38+ 'Ko Resolve (Multi-arch)'
39+ ];
40+
41+ const maxAttempts = 60; // 5 minutes max wait
42+ const delayMs = 5000; // 5 seconds between checks
43+
44+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
45+ const { data: checkRuns } = await github.rest.checks.listForRef({
46+ owner: context.repo.owner,
47+ repo: context.repo.repo,
48+ ref: context.payload.pull_request.head.sha
49+ });
50+
51+ const relevantChecks = checkRuns.check_runs.filter(check =>
52+ checkNames.includes(check.name)
53+ );
54+
55+ console.log(`Attempt ${attempt + 1}/${maxAttempts}`);
56+ console.log('Check statuses:', relevantChecks.map(c => `${c.name}: ${c.status} (${c.conclusion})`).join(', '));
57+
58+ // Check if all required checks exist and are completed
59+ const allChecksPresent = checkNames.every(name =>
60+ relevantChecks.some(check => check.name === name)
61+ );
62+
63+ if (allChecksPresent) {
64+ const allCompleted = relevantChecks.every(check =>
65+ check.status === 'completed'
66+ );
67+
68+ if (allCompleted) {
69+ const allPassed = relevantChecks.every(check =>
70+ check.conclusion === 'success'
71+ );
72+
73+ if (allPassed) {
74+ console.log('✅ All CI checks passed!');
75+ return;
76+ } else {
77+ const failedChecks = relevantChecks.filter(c => c.conclusion !== 'success');
78+ console.log('❌ Some CI checks failed:', failedChecks.map(c => c.name).join(', '));
79+ core.setFailed('CI checks failed. E2E tests will not run.');
80+ return;
81+ }
82+ }
83+ }
84+
85+ // Wait before next attempt
86+ console.log(`Waiting ${delayMs/1000} seconds before next check...`);
87+ await new Promise(resolve => setTimeout(resolve, delayMs));
88+ }
89+
90+ console.log('⏱️ Timeout waiting for CI checks');
91+ core.setFailed('Timeout waiting for CI checks to complete');
92+
2393 k8s :
94+ needs : [wait-for-ci]
95+ # Skip the wait-for-ci dependency on push/merge_group events
96+ if : ${{ !failure() && (github.event_name != 'pull_request' || needs.wait-for-ci.result == 'success') }}
2497 strategy :
2598 fail-fast : false # Keep running if one leg fails.
2699 matrix :
34107 pipelines-release : v0.65.0
35108 # This job is for testing the latest LTS version of Tekton Pipelines
36109 pipelines-lts :
110+ needs : [wait-for-ci]
111+ # Skip the wait-for-ci dependency on push/merge_group events
112+ if : ${{ !failure() && (github.event_name != 'pull_request' || needs.wait-for-ci.result == 'success') }}
37113 strategy :
38114 fail-fast : false # Keep running if one leg fails.
39115 matrix :
0 commit comments