Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5566: Handle action_required status in code coverage #5574

Merged
merged 12 commits into from
Nov 14, 2024
18 changes: 14 additions & 4 deletions .github/workflows/comment_coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
check_code_coverage_completed:
name: Check code coverage completed
runs-on: ubuntu-latest
outputs:
conclusion: ${{ steps.wait-for-coverage.outputs.run-conclusion }}
steps:
- name: Wait for code coverage to complete
id: wait-for-coverage
Expand All @@ -27,16 +29,24 @@ jobs:
allowed-conclusions: |
success
failure
action_required
- name: Conclusion Analysis
if: steps.wait-for-coverage.outputs.run-conclusion == 'action_required'
run: |
echo "::warning::Code coverage workflow requires manual approval. After approval, please re-run this workflow to post the coverage report."

comment_coverage_report:
name: Comment Code Coverage Report
needs: check_code_coverage_completed
permissions:
pull-requests: write

# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
# The expression if: ${{ !cancelled() && needs.check_code_coverage_completed.outputs.conclusion != 'action_required' }}
# ensures that this job only runs if the previous job was not cancelled and does not require manual approval.
# This check prevents running the job unnecessarily when a manual approval is needed.
if: |
!cancelled() &&
needs.check_code_coverage_completed.outputs.conclusion != 'action_required'
runs-on: ubuntu-latest
steps:
- name: Find CI workflow run for PR
Expand All @@ -60,7 +70,7 @@ jobs:

const run = runs[0];
if(!run) {
core.setFailed('Could not find a succesful workflow run for the PR');
core.setFailed('Could not find a successful workflow run for the PR');
return;
}

Expand Down
Loading