Skip to content

Commit 1222228

Browse files
authored
better messaging when skipping concurrent runs (docker#101)
Signed-off-by: Derek Misler <derek.misler@docker.com>
1 parent 87405a1 commit 1222228

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

review-pr/action.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ runs:
162162
if [ "$AGE" -lt 2500 ]; then # ~42 min TTL (slightly longer than the 40-min review timeout)
163163
echo "⏭️ Review already in progress (started ${AGE}s ago) — skipping"
164164
echo "skip=true" >> $GITHUB_OUTPUT
165+
echo "skip-reason=concurrent" >> $GITHUB_OUTPUT
166+
echo "lock-age=${AGE}" >> $GITHUB_OUTPUT
165167
exit 0
166168
fi
167169
echo "🔓 Stale lock (${AGE}s old) — proceeding"
@@ -819,11 +821,23 @@ runs:
819821
EXIT_CODE: ${{ steps.run-review.outputs.exit-code }}
820822
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
821823
VERBOSE_LOG_FILE: ${{ steps.run-review.outputs.verbose-log-file }}
824+
SKIP_REASON: ${{ steps.lock-check.outputs.skip-reason }}
825+
LOCK_AGE: ${{ steps.lock-check.outputs.lock-age }}
822826
run: |
823827
REVIEW_URL="https://github.com/$REPOSITORY/pull/$PR_NUMBER"
824828
echo "review-url=$REVIEW_URL" >> $GITHUB_OUTPUT
825829
826-
if [ "$EXIT_CODE" != "0" ]; then
830+
if [ "$SKIP_REASON" = "concurrent" ]; then
831+
STATUS="⏭️ **Review skipped** — another review is already in progress"
832+
gh api "repos/$REPOSITORY/issues/$PR_NUMBER/comments" \
833+
-f body="⏭️ **Review skipped** — another review for this PR is already in progress (started ${LOCK_AGE}s ago). Only one review runs at a time to avoid duplicate comments. The in-progress review will post its results when complete." \
834+
2>&1 || {
835+
echo "::warning::Failed to post skip comment to PR"
836+
STATUS="${STATUS} (⚠️ failed to notify on PR)"
837+
}
838+
elif [ -z "$EXIT_CODE" ]; then
839+
STATUS="⏭️ **Review skipped** — agent did not run"
840+
elif [ "$EXIT_CODE" != "0" ]; then
827841
# Check if agent actually posted a review despite the error exit code.
828842
# This happens when a sub-agent fails (e.g., API overload) but the root
829843
# agent recovers and posts the review itself.
@@ -855,7 +869,7 @@ runs:
855869
} >> $GITHUB_STEP_SUMMARY
856870
857871
- name: Add completion reaction
858-
if: steps.resolve-context.outputs.comment-id != '' && always()
872+
if: steps.resolve-context.outputs.comment-id != '' && always() && steps.lock-check.outputs.skip != 'true'
859873
shell: bash
860874
env:
861875
GH_TOKEN: ${{ steps.resolve-token.outputs.token }}

0 commit comments

Comments
 (0)