ChatOps for fixing API generated code conflicts
Overview
Adds a custom GH Action to listen to chat commands.
You can use /rebase-api to execute the following (resolving 90% of conflicts that need manual rebasing):
git rebase origin/main
git add .
make gen-api
git add .
git rebase --continue
The action has reasonable safety measures (fails on unknown conflicts)
⚠️ This action force pushes to the PR branch ⚠️
📜 Check the README for details 📜
Summary by CodeRabbit
-
New Features
- Introduced an automated pull request rebasing process triggered by comment commands. This new functionality seamlessly updates branches and manages API-related conflicts, providing clear status feedback.
-
Documentation
- Added clear instructions to help users activate and integrate the new rebasing feature into their workflow.
-
Configuration
- Added new configuration files for GitHub Actions, including
.gitignore,.prettierignore, and.prettierrc.json, to streamline development and formatting processes.
- Added new configuration files for GitHub Actions, including
-
Tests
- Implemented a comprehensive test suite for the rebasing functionality, ensuring robust handling of various scenarios and error conditions.
📝 Walkthrough
Walkthrough
This pull request introduces a new GitHub Action, "Rebase API Action", built with TypeScript to automate the rebasing of pull requests when triggered by specific comment commands. It adds several configuration files, including version control ignores, Prettier settings, and TypeScript/Vitest configurations, alongside comprehensive documentation and a dedicated workflow. The changes include source code implementing Git operations, GitHub API interactions, conflict resolution, input management, and tests to validate functionality.
Changes
| File(s) | Change Summary |
|---|---|
| .github/actions/rebase-api/{.gitignore, .prettierignore, .prettierrc.json} | Added new configuration files: .gitignore for excluding unnecessary files, .prettierignore to specify files/directories for Prettier, and .prettierrc.json with formatting options. |
| .github/actions/rebase-api/{README.md, action.yml} | Introduced the GitHub Action documentation and the action definition file detailing inputs, execution steps, and trigger settings for the Rebase API Action. |
| .github/actions/rebase-api/package.json | Created to define the action’s metadata, dependencies, scripts, and main entry point. |
| .github/actions/rebase-api/src/{git.ts, github.ts, main.ts, types.ts, utils.ts, main.test.ts} | Added TypeScript source files implementing Git operations, GitHub API interactions, orchestration of the rebase process, type definitions, utility functions, and tests using Vitest. |
| .github/actions/rebase-api/{tsconfig.json, vitest.config.ts} | New configuration files for TypeScript compilation and Vitest testing environment setup. |
| .github/workflows/rebase-api.yml | Introduced a new GitHub workflow to trigger the rebase process on pull request comments, with conditions based on user roles and comment actions. |
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
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)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai planto trigger planning for file edits and PR creation.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
/rebase-api
/rebase-api
/rebase-api
/rebase-api
For the workflow to run it needs to be checked in to main.
Check this example run on openmeter-internal to see it working https://github.com/openmeterio/openmeter-internal/actions/runs/14175346671/job/39708768654
https://github.com/openmeterio/openmeter-internal/pull/10#issuecomment-2766602162
Will do some further testing if approved (as testing the actual conflicts isn't really possible on openemter-internal due to it being such an old version)