-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat(e2e): add MERGE_FAILED label if mergequeue CI fails #3611
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request introduces a new job step in the GitHub Actions workflow located in Changes
Sequence Diagram(s)sequenceDiagram
participant E2E as E2E Workflow
participant Script as GitHub Script
participant PR as Pull Request
participant Log as Error Log
E2E->>Script: Trigger on merge_group event with e2e failure
Script->>Script: Extract pull request number from commit message
alt Extraction Fails
Script->>Log: Log error and terminate
else Extraction Succeeds
Script->>PR: Add `MERGE_FAILED` label
Script->>PR: Post comment with failed run link
end
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/e2e.yml (1)
340-367
: Enhanced MERGE_FAILED Labeling and Commenting LogicThe new step that adds the
MERGE_FAILED
label and posts a comment on the PR when the merge queue CI fails is implemented correctly. The script correctly extracts the PR number from the merge queue commit message using the regex/\(#(\d+)\)$/
, then uses GitHub’s REST API calls to add the label and comment with a link to the failed workflow run.Suggestions:
- Improve Debug Logging: In the extraction block, consider logging the raw commit message along with the error message when the regex fails. This will help diagnose issues if the commit message format does not match the expected pattern.
- Error Handling: Although the current implementation returns early on a failed extraction, wrapping the API calls (i.e. adding labels and creating comments) in a try-catch block could help catch and log potential errors from the GitHub API calls, ensuring better observability in production-grade workflows.
Below is an example diff to incorporate these suggestions:
- const commit_message = context.payload.merge_group.head_commit.message; - const pr_match = commit_message.split('\n')[0].match(/\(#(\d+)\)$/); - if (!pr_match) { - console.error("unable to extract PR number from mergequeue commit message"); - return; - } - const pr_number = pr_match[1]; - - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr_number, - labels: ['MERGE_FAILED'] - }); - - const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr_number, - body: `[Merge queue e2e run failed](${workflowRunUrl})` - }); + const commit_message = context.payload.merge_group.head_commit.message; + const pr_match = commit_message.split('\n')[0].match(/\(#(\d+)\)$/); + if (!pr_match) { + console.error("Unable to extract PR number from mergequeue commit message:", commit_message); + return; + } + const pr_number = pr_match[1]; + + try { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + labels: ['MERGE_FAILED'] + }); + + const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + body: `[Merge queue e2e run failed](${workflowRunUrl})` + }); + } catch (error) { + console.error("Error while adding label or creating comment:", error); + }These adjustments improve the debugging capability and resilience of the workflow step.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/e2e.yml
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: build-zetanode
- GitHub Check: lint
- GitHub Check: build-and-test
- GitHub Check: gosec
- GitHub Check: build
- GitHub Check: analyze (go)
- GitHub Check: analyze (go)
This will help us quickly identify PRs which need to be fixed or requeued.
Summary by CodeRabbit