ci: fix the bug of No open pull request found#53
Conversation
📝 WalkthroughWalkthroughThe workflow's PR lookup step was refactored to retrieve pull request details using a commit SHA-based API query instead of filtering by repository owner and branch. The corresponding error message was updated to reflect this change. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 unit tests (beta)
📝 Coding Plan
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/coverage-upload.yml (1)
45-56:⚠️ Potential issue | 🔴 Critical
headBranchis undefined and will crash this step.On line 55,
headBranchis used but never declared in the script. This causes aReferenceErrorat runtime and prevents PR outputs from being set, blocking the Codecov upload.Proposed fix
const headSha = context.payload.workflow_run.head_sha; + const headBranch = context.payload.workflow_run.head_branch; const { data: pulls } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ owner: context.repo.owner, repo: context.repo.repo, commit_sha: headSha, });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/coverage-upload.yml around lines 45 - 56, The script uses headBranch when setting outputs but headBranch is never defined; replace its usage by deriving the branch from the PR object (use pr.head.ref) or define headBranch before use (e.g., const headBranch = pr.head.ref) so core.setOutput('pr_branch', ...) uses a valid string; update the block that handles pulls[0] (the pr variable) and the core.setOutput calls to reference pr.head.ref (or the new headBranch) to avoid the ReferenceError.
🤖 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/coverage-upload.yml:
- Around line 45-56: The script uses headBranch when setting outputs but
headBranch is never defined; replace its usage by deriving the branch from the
PR object (use pr.head.ref) or define headBranch before use (e.g., const
headBranch = pr.head.ref) so core.setOutput('pr_branch', ...) uses a valid
string; update the block that handles pulls[0] (the pr variable) and the
core.setOutput calls to reference pr.head.ref (or the new headBranch) to avoid
the ReferenceError.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2ab40438-d22e-4809-8c95-bdbe2af24fb1
📒 Files selected for processing (1)
.github/workflows/coverage-upload.yml
What does this PR do?
Why are these changes required?
This PR has been tested by:
Follow up
Extra details
Summary by cubic
Fixes the coverage upload workflow to find the pull request by commit SHA, preventing false “No open pull request found” failures and restoring reliable Codecov uploads.
github.rest.repos.listPullRequestsAssociatedWithCommitwithcommit_shainstead ofgithub.rest.pulls.listfiltered byhead.Written for commit 639e64c. Summary will update on new commits.
Summary by CodeRabbit
Release Notes