Skip to content

Commit 1423491

Browse files
fix: update release_pr_checker job to wait for outside CI jobs (Mellanox#1392)
Now the job is skipping important e2e CI jobs which is not ideal for auto-merged release PRs example of running on fork can be found here: almaslennikov#9 https://github.com/almaslennikov/network-operator/actions/runs/14034173037/job/39288276871?pr=9
2 parents ac5cadd + 40d79c4 commit 1423491

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

.github/workflows/release-pr-checker.yaml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,63 @@ jobs:
88
wait_for_ci:
99
if: ${{ startsWith(github.event.pull_request.title, 'cicd:') && github.actor == 'nvidia-ci-cd'}}
1010
runs-on: ubuntu-latest
11+
timeout-minutes: 180
1112
permissions:
13+
pull-requests: read
1214
checks: read
15+
statuses: read
1316
steps:
14-
- name: GitHub Checks
15-
uses: poseidon/[email protected]
16-
with:
17-
token: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
18-
timeout: 14400
19-
interval: 60
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
- name: Wait for CI checks
20+
env:
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
PR_NUMBER: ${{ github.event.pull_request.number }}
23+
CURRENT_JOB_NAME: wait_for_ci
24+
REQUIRED_CHECKS: |
25+
nic_operator_helm CI
26+
nic_operator_kind CI
27+
image_scan CI
28+
blackduck_scan CI
29+
Copy Right Validation
30+
WAIT_INTERVAL: 60
31+
run: |
32+
echo "Waiting $WAIT_INTERVAL seconds for checks to start..."
33+
sleep $WAIT_INTERVAL
34+
35+
mapfile -t REQUIRED_CHECKS_ARRAY < <(echo "$REQUIRED_CHECKS" | grep -v '^\s*$')
36+
37+
while true; do
38+
echo "Fetching checks for PR #$PR_NUMBER..."
39+
CHECKS_OUTPUT=$(gh pr checks "$PR_NUMBER" --json name,state)
40+
41+
for CHECK in "${REQUIRED_CHECKS_ARRAY[@]}"; do
42+
if ! echo "$CHECKS_OUTPUT" | jq -e ".[] | select(.name == \"$CHECK\")" >/dev/null; then
43+
echo "Required check '$CHECK' not found. Waiting $WAIT_INTERVAL seconds..."
44+
sleep $WAIT_INTERVAL
45+
fi
46+
done
47+
48+
# Exit immediately if any check fails
49+
FAILED_CHECKS=$(echo "$CHECKS_OUTPUT" | jq -r '.[] | select(.state == "FAILURE") | .name')
50+
if [[ -n "$FAILED_CHECKS" ]]; then
51+
echo "The following checks have failed:"
52+
echo "$FAILED_CHECKS"
53+
exit 1
54+
fi
55+
56+
# Verify all checks are either SUCCESS or SKIPPED
57+
INCOMPLETE_CHECKS=$(echo "$CHECKS_OUTPUT" | jq -r '.[] | select(.name != env.CURRENT_JOB_NAME) | select(.state != "SUCCESS" and .state != "SKIPPED") | .name')
58+
59+
if [[ -z "$INCOMPLETE_CHECKS" ]]; then
60+
echo "All checks have succeeded or are skipped."
61+
break
62+
else
63+
echo "Waiting $WAIT_INTERVAL seconds for the following checks to complete successfully:"
64+
echo "$INCOMPLETE_CHECKS"
65+
sleep $WAIT_INTERVAL
66+
fi
67+
done
2068
update_network_operator_version:
2169
needs:
2270
- wait_for_ci

0 commit comments

Comments
 (0)