Skip to content

Commit

Permalink
Remove retry logic and check for completed workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Navin Chandra <[email protected]>
  • Loading branch information
navin772 committed Aug 23, 2024
1 parent c04b43e commit 753934b
Showing 1 changed file with 26 additions and 42 deletions.
68 changes: 26 additions & 42 deletions .github/workflows/ci-merge-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ci-merge-coverage

on:
workflow_run:
workflows: ["ci-test-ginkgo"]
workflows: [ci-test-ginkgo]
types:
- completed

Expand All @@ -12,58 +12,42 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Check if all required workflows completed successfully
id: check-workflows
run: |
workflows=("ci-test-ginkgo")
max_retries=20 # Set a max retry limit (e.g., 20 retries with 120-second intervals)
interval=120 # Set interval in seconds between retries
all_completed=false
commit_sha=$(git rev-parse HEAD)
for workflow in "${workflows[@]}"; do
echo "${workflow}_status=pending" >> $GITHUB_ENV
done
workflows=("ci-test-ginkgo")
all_completed=true
for (( i=0; i<$max_retries; i++ )); do
all_completed=true
commit_sha=$(git rev-parse HEAD)
for workflow in "${workflows[@]}"; do
conclusion=$(gh run list --workflow=$workflow --branch=main --json conclusion,headSha | jq -r --arg sha "$commit_sha" '.[] | select(.headSha == $sha) | .conclusion')
for workflow in "${workflows[@]}"; do
conclusion=$(gh run list --workflow=$workflow --json conclusion,headSha,event,headBranch | jq -r --arg sha "$commit_sha" --arg event "pull_request" '.[] | select(.headSha == $sha and .event == $event) | .conclusion')
if [[ -z "$conclusion" ]]; then
conclusion="pending"
fi
if [[ -z "$conclusion" ]]; then
conclusion="pending"
fi
if [[ "$conclusion" != "success" ]]; then
all_completed=false
fi
if [[ "$conclusion" != "success" ]]; then
all_completed=false
fi
echo "${workflow}_status=$conclusion" >> $GITHUB_ENV
done
echo "${workflow}_status=$conclusion" >> $GITHUB_ENV
done
if [[ "$all_completed" == "true" ]]; then
echo "All workflows completed successfully for commit $commit_sha."
echo "all_succeeded=true" >> $GITHUB_ENV
break
fi
if [[ "$i" -eq $((max_retries - 1)) ]]; then
echo "Timeout waiting for workflows to complete for commit $commit_sha."
exit 1
else
sleep $interval
fi
done
if [[ "$all_completed" == "true" ]]; then
echo "All workflows completed successfully for commit $commit_sha."
echo "all_succeeded=true" >> $GITHUB_ENV
else
echo "Not all workflows completed successfully for commit $commit_sha."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v3
with:
submodules: true

- uses: actions/setup-go@v5
with:
go-version-file: 'KubeArmor/go.mod'
Expand Down

0 comments on commit 753934b

Please sign in to comment.