-
Notifications
You must be signed in to change notification settings - Fork 22
fix(ci): use gh pr view for fork PR number lookup in coverage comment #253
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(ci): use gh pr view for fork PR number lookup in coverage comment #253
Conversation
The workflow_run event's pull_requests array is empty for fork PRs due to a known GitHub limitation. This prevented coverage comments from being posted on fork PRs. Replace the JavaScript-based pull_requests array lookup with gh pr view command, which reliably finds PRs from both forks and the same repo. Add conditional logic to use the correct branch query format: - Fork PRs: "owner:branch" format - Same-repo PRs: "branch" format See: https://github.com/orgs/community/discussions/25220 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Chris Hambridge <chambrid@redhat.com>
AgentReady Code Review: PR #253OverviewPR: fix(ci): use gh pr view for fork PR number lookup in coverage comment ✅ Strengths1. Problem Analysis (Excellent)
2. Security (Strong)
3. Code Quality (Good)
|
| Attribute | Status | Score Impact | Notes |
|---|---|---|---|
| CI/CD Pipeline | ✅ Improved | +1 | Fixes fork PR coverage reporting |
| Pre-commit Hooks | 0 | actionlint validation claimed but not evidenced | |
| Code Documentation | ✅ Pass | 0 | Inline comments explain logic |
| Security Practices | ✅ Pass | 0 | Maintains PR number validation |
| Error Handling | ✅ Pass | 0 | Graceful failure with error messages |
| Test Coverage | 0 | Workflow changes (no unit tests applicable) |
Net Impact: +0.5 to 1.0 points (minor improvement in CI/CD robustness)
🔒 Security Analysis
No New Vulnerabilities Introduced ✅
- PR Number Validation: Existing security check at line 84-86 prevents cross-PR comment injection
- Trusted Context: Uses
github.event.workflow_run(trusted) for HEAD_REPO/HEAD_BRANCH - No User Input: BRANCH_QUERY constructed from GitHub context, not user-controlled
- gh CLI: Uses official GitHub CLI with proper authentication via
GH_TOKEN
Potential Edge Cases to Consider
-
Branch Names with Special Characters: The
${HEAD_REPO%%/*}expansion assumes owner is before first/. Multi-level org paths could cause issues, but this is low risk (GitHub does not support multi-level orgs in full_name). -
Rate Limiting:
gh pr viewcalls GitHub API. Multiple concurrent workflow runs could hit rate limits, but risk is low (workflow_run triggers are typically sequential and already usesgithub.tokenwhich has higher rate limits).
🎯 Best Practices Alignment
Follows AgentReady Principles ✅
- Graceful Degradation: Falls back to error message if PR not found
- Clear Error Messages: Uses
::error::syntax for GitHub Actions - Documentation: Comments explain GitHub API limitation
- Minimal Change: Surgical fix without over-engineering
📝 Recommendations Summary
Must Fix (Before Merge)
- None (PR is functionally correct)
Should Fix (Improve Quality)
- Update stderr redirect to use combined redirect pattern per CLAUDE.md (optional style improvement)
- Add actionlint output evidence to PR description or CI
Consider for Future
- Add integration test for fork PR scenario
- Document branch name assumptions
- Add metrics/notices to track fork vs same-repo query usage
Final Verdict
Approval Status: ✅ LGTM with Minor Suggestions
Reasoning:
- Correctly solves the fork PR coverage comment problem
- Maintains security properties
- No breaking changes or regressions
- Minor shell best practice improvements suggested but not blocking
Suggested Action: Merge as-is or after addressing shell redirect pattern (2-minute fix).
Review conducted by AgentReady-aware Claude Code Agent
Date: 2026-01-15
AgentReady Version: 2.22.0
## [2.22.2](v2.22.1...v2.22.2) (2026-01-15) ### Bug Fixes * **ci:** use gh pr view for fork PR number lookup in coverage comment ([#253](#253)) ([1688362](1688362))
|
🎉 This PR is included in version 2.22.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
The workflow_run event's pull_requests array is empty for fork PRs due to a known GitHub limitation. This prevented coverage comments from being posted on fork PRs.
Type of Change
Related Issues
Relates to https://github.com/orgs/community/discussions/25220
Changes Made
Replace the JavaScript-based pull_requests array lookup with gh pr view command, which reliably finds PRs from both forks and the same repo. Add conditional logic to use the correct branch query format:
Testing
Fork PR query: gh pr view "chambridge:fix/245-..." --repo ambient-code/agentready → returned PR fix(assessors): FileSizeLimitsAssessor now respects .gitignore #248
Same-repo PR query: gh pr view "automated/research-update" --repo ambient-code/agentready → returned PR Weekly Research Update: Agent-Ready Codebase Attributes #243
actionlint validation: Passed with no errors
Unit tests pass (
pytest)Integration tests pass
Manual testing performed
No new warnings or errors
Checklist
Screenshots (if applicable)
Additional Notes