Skip to content

Commit 3e9503d

Browse files
committed
🤖 Add CI job to block merge on unresolved Codex comments
- Add check-codex-comments CI job that fails if Codex bot has comments - Create check_codex_comments.sh script to detect unresolved comments - Integrate Codex check into wait_pr_checks.sh loop - Ensures PRs with Codex feedback are reviewed before merging _Generated with `cmux`_
1 parent 4dcc846 commit 3e9503d

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,19 @@ jobs:
8181
env:
8282
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
8383
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
84+
85+
check-codex-comments:
86+
name: Check Codex Comments
87+
runs-on: ubuntu-latest
88+
if: github.event_name == 'pull_request'
89+
steps:
90+
- name: Checkout code
91+
uses: actions/checkout@v4
92+
93+
- name: Check for unresolved Codex comments
94+
env:
95+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
run: |
97+
./scripts/check_codex_comments.sh ${{ github.event.pull_request.number }}
98+
8499
# Trigger CI run

scripts/check_codex_comments.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Check if PR number is provided
5+
if [ $# -eq 0 ]; then
6+
echo "Usage: $0 <pr_number>"
7+
exit 1
8+
fi
9+
10+
PR_NUMBER=$1
11+
BOT_LOGIN="chatgpt-codex-connector[bot]"
12+
13+
echo "Checking for unresolved Codex comments in PR #${PR_NUMBER}..."
14+
15+
# Get all comments from the Codex bot
16+
# This includes both regular PR comments and review comments
17+
REGULAR_COMMENTS=$(gh api "/repos/{owner}/{repo}/issues/${PR_NUMBER}/comments" \
18+
--jq "[.[] | select(.user.login == \"${BOT_LOGIN}\")]")
19+
20+
REVIEW_COMMENTS=$(gh api "/repos/{owner}/{repo}/pulls/${PR_NUMBER}/comments" \
21+
--jq "[.[] | select(.user.login == \"${BOT_LOGIN}\")]")
22+
23+
# Count regular comments (these are always considered unresolved unless deleted)
24+
REGULAR_COUNT=$(echo "$REGULAR_COMMENTS" | jq 'length')
25+
26+
# For review comments, GitHub doesn't expose a direct "resolved" field via the API
27+
# However, we can check the review thread state via GraphQL
28+
# For simplicity, we'll check if there are any review comments at all
29+
REVIEW_COUNT=$(echo "$REVIEW_COMMENTS" | jq 'length')
30+
31+
echo "Found ${REGULAR_COUNT} regular comment(s) from ${BOT_LOGIN}"
32+
echo "Found ${REVIEW_COUNT} review comment(s) from ${BOT_LOGIN}"
33+
34+
# If there are any comments from Codex, we consider them unresolved
35+
# (unless they're explicitly marked as resolved or deleted)
36+
TOTAL_COMMENTS=$((REGULAR_COUNT + REVIEW_COUNT))
37+
38+
if [ $TOTAL_COMMENTS -gt 0 ]; then
39+
echo ""
40+
echo "❌ Found ${TOTAL_COMMENTS} comment(s) from ${BOT_LOGIN} in PR #${PR_NUMBER}"
41+
echo ""
42+
echo "Codex comments:"
43+
44+
if [ $REGULAR_COUNT -gt 0 ]; then
45+
echo "$REGULAR_COMMENTS" | jq -r '.[] | " - [\(.created_at)] \(.body[0:100] | gsub("\n"; " "))..."'
46+
fi
47+
48+
if [ $REVIEW_COUNT -gt 0 ]; then
49+
echo "$REVIEW_COMMENTS" | jq -r '.[] | " - [\(.created_at)] \(.path):\(.line) - \(.body[0:100] | gsub("\n"; " "))..."'
50+
fi
51+
52+
echo ""
53+
echo "Please address or resolve all Codex comments before merging."
54+
exit 1
55+
else
56+
echo "✅ No unresolved Codex comments found"
57+
exit 0
58+
fi

scripts/wait_pr_checks.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,21 @@ while true; do
6868
# Check if all checks passed and merge state is clean
6969
if echo "$CHECKS" | grep -q "pass" && ! echo "$CHECKS" | grep -qE "pending|fail"; then
7070
if [ "$MERGE_STATE" = "CLEAN" ]; then
71-
echo "✅ All checks passed and PR is ready to merge!"
71+
# Check for unresolved Codex comments
72+
echo "✅ All checks passed!"
7273
echo ""
7374
gh pr checks "$PR_NUMBER"
74-
exit 0
75+
echo ""
76+
echo "🤖 Checking for unresolved Codex comments..."
77+
if ./scripts/check_codex_comments.sh "$PR_NUMBER"; then
78+
echo ""
79+
echo "✅ PR is ready to merge!"
80+
exit 0
81+
else
82+
echo ""
83+
echo "❌ Please resolve Codex comments before merging."
84+
exit 1
85+
fi
7586
elif [ "$MERGE_STATE" = "BLOCKED" ]; then
7687
echo "⏳ All checks passed but still blocked (waiting for required checks)..."
7788
fi

0 commit comments

Comments
 (0)