ci: fix gh api review-state query in ready-for-review workflow #566
ci: fix gh api review-state query in ready-for-review workflow #566xdustinface merged 1 commit intov0.42-devfrom
gh api review-state query in ready-for-review workflow #566Conversation
📝 WalkthroughWalkthroughThe workflow changes how PR reviews are fetched: the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/ready-for-review.yml (1)
130-142:⚠️ Potential issue | 🔴 CriticalCritical: Missing
-rflag causes comparison to always fail.The
jq -scommand outputs JSON strings with quotes (e.g.,"APPROVED"), butgh api --jqoutputs raw strings by default. Without the-rflag,$CODERABBIT_STATEwill contain"APPROVED"(with literal quote characters), and the comparison on line 139 againstAPPROVED(without quotes) will never match.This means the
ready-for-reviewlabel will never be added, defeating the purpose of this fix.🐛 Proposed fix: Add `-r` flag to jq
- CODERABBIT_STATE=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/reviews" | jq -s ' + CODERABBIT_STATE=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/reviews" | jq -rs ' add | map(select(.user.login == "coderabbitai[bot]")) | sort_by(.submitted_at) | last | .state // "NONE" ')🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ready-for-review.yml around lines 130 - 142, The comparison fails because jq -s produces quoted JSON strings so CODERABBIT_STATE contains quotes (e.g., "APPROVED"); update the command that sets CODERABBIT_STATE (the gh api | jq -s ... pipeline) to output raw strings by adding the jq -r option so the variable holds APPROVED without quotes, ensuring the subsequent if [ "$CODERABBIT_STATE" != "APPROVED" ] check works as intended.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In @.github/workflows/ready-for-review.yml:
- Around line 130-142: The comparison fails because jq -s produces quoted JSON
strings so CODERABBIT_STATE contains quotes (e.g., "APPROVED"); update the
command that sets CODERABBIT_STATE (the gh api | jq -s ... pipeline) to output
raw strings by adding the jq -r option so the variable holds APPROVED without
quotes, ensuring the subsequent if [ "$CODERABBIT_STATE" != "APPROVED" ] check
works as intended.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4e31c882-7592-4a51-93f6-ddfdb147b353
📒 Files selected for processing (1)
.github/workflows/ready-for-review.yml
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v0.42-dev #566 +/- ##
=============================================
- Coverage 66.37% 66.36% -0.02%
=============================================
Files 311 311
Lines 64979 64979
=============================================
- Hits 43130 43121 -9
- Misses 21849 21858 +9
|
`gh api` does not support combining `--slurp` with `--jq`. Pipe paginated output to `jq -rs` instead so pages are concatenated into a single array before the filter runs.
12db4eb to
0799eb6
Compare
gh api --paginate to jq -s instead of using --slurp --jqgh api review-state query in ready-for-review workflow
gh apidoes not support combining--slurpwith--jq. Pipe paginated output tojq -rsinstead so pages are concatenated into a single array before the filter runs.This is issue was preventing the
ready-for-reviewlabel from being added when CI completes after CodeRabbit approval.Summary by CodeRabbit