Skip to content

Commit 716dea7

Browse files
committed
chore: Adding workflow to trigger sdk e2e test
1 parent c0a1559 commit 716dea7

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Trigger SDK E2E Tests on PR
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
branches:
7+
- main
8+
9+
jobs:
10+
trigger-remote-e2e:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- name: SDK PR Notebook E2E Runner
16+
uses: peter-evans/repository-dispatch@v3
17+
with:
18+
token: ${{ secrets.KUBEFLOW_E2E_DISPATCH_TOKEN }}
19+
repository: project-codeflare/kubeflow-devx-post-merge-tests
20+
event-type: run-sdk-pr-e2e-tests
21+
client-payload: '{
22+
"sdk_repo": "${{ github.repository }}",
23+
"sdk_ref": "${{ github.event.pull_request.head.ref }}",
24+
"sdk_sha": "${{ github.event.pull_request.head.sha }}",
25+
"training_operator_repo_owner": "opendatahub-io",
26+
"training_operator_repo_name": "trainer",
27+
"training_operator_ref": "main"
28+
}'
29+
30+
- name: Poll for remote E2E workflow completion
31+
env:
32+
GH_TOKEN: ${{ secrets.KUBEFLOW_E2E_DISPATCH_TOKEN }}
33+
ORG: project-codeflare
34+
REPO: kubeflow-devx-post-merge-tests
35+
run: |
36+
sleep 30 # to allow for run to start
37+
echo "Polling $ORG/$REPO..."
38+
39+
workflow_id=$(gh api repos/$ORG/$REPO/actions/workflows \
40+
| jq -r '.workflows[] | select(.name=="SDK PR Notebook E2E Runner") | .id' \
41+
| head -1)
42+
43+
if [ -z "$workflow_id" ]; then
44+
echo "Error: Workflow ID not found. Make sure the workflow name matches exactly." && exit 1
45+
fi
46+
47+
echo "Found the workflow ID: $workflow_id"
48+
49+
# Wait for the workflow run to appear (retry up to 10 times, 5 seconds apart)
50+
for i in {1..10}; do
51+
run_id=$(
52+
gh api repos/$ORG/$REPO/actions/runs \
53+
| jq -r ".workflow_runs[] | select(.workflow_id==$workflow_id) | .id" \
54+
| head -1 \
55+
|| true
56+
)
57+
58+
echo "Attempt $i: run_id=$run_id"
59+
60+
if [[ -n "$run_id" && "$run_id" != "null" ]]; then
61+
break
62+
fi
63+
64+
echo "Waiting for run to start..."
65+
sleep 5
66+
done
67+
68+
if [ -z "$run_id" ]; then
69+
echo "Error: Workflow run not found" && exit 1
70+
fi
71+
72+
echo "Monitoring run ID $run_id..."
73+
echo "View logs at: https://github.com/$ORG/$REPO/actions/runs/$run_id"
74+
75+
# Poll for completion (up to 90 times, 30 seconds apart = 45 minutes max)
76+
for i in {1..90}; do
77+
status=$(gh api repos/$ORG/$REPO/actions/runs/$run_id --jq '.status')
78+
conclusion=$(gh api repos/$ORG/$REPO/actions/runs/$run_id --jq '.conclusion')
79+
80+
echo "Status: $status | Conclusion: $conclusion"
81+
82+
if [[ "$status" == "completed" ]]; then
83+
if [[ "$conclusion" == "success" ]]; then
84+
echo "Success: Remote E2E tests completed successfully"
85+
exit 0
86+
else
87+
echo "Error: Remote E2E tests failed with conclusion: $conclusion"
88+
echo "View logs at: https://github.com/$ORG/$REPO/actions/runs/$run_id"
89+
exit 1
90+
fi
91+
fi
92+
93+
sleep 30
94+
done
95+
96+
echo "Error: Timeout waiting for remote E2E workflow"
97+
exit 1

0 commit comments

Comments
 (0)