From 922e2c0ef3248cfba4bfc1d6f29d117bed3db85b Mon Sep 17 00:00:00 2001 From: Navin Chandra Date: Tue, 20 Aug 2024 16:36:41 +0000 Subject: [PATCH] Remove retry logic and check for completed workflows Signed-off-by: Navin Chandra --- .github/workflows/ci-merge-coverage.yaml | 66 +++++++++--------------- 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci-merge-coverage.yaml b/.github/workflows/ci-merge-coverage.yaml index 783def764..5df5da3ca 100644 --- a/.github/workflows/ci-merge-coverage.yaml +++ b/.github/workflows/ci-merge-coverage.yaml @@ -15,58 +15,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 --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'