openmeter icon indicating copy to clipboard operation
openmeter copied to clipboard

ChatOps for fixing API generated code conflicts

Open GAlexIHU opened this issue 8 months ago • 7 comments

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.
  • Tests

    • Implemented a comprehensive test suite for the rebasing functionality, ensuring robust handling of various scenarios and error conditions.

GAlexIHU avatar Mar 31 '25 14:03 GAlexIHU

📝 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Mar 31 '25 14:03 coderabbitai[bot]

/rebase-api

GAlexIHU avatar Mar 31 '25 14:03 GAlexIHU

/rebase-api

GAlexIHU avatar Mar 31 '25 14:03 GAlexIHU

/rebase-api

GAlexIHU avatar Mar 31 '25 14:03 GAlexIHU

/rebase-api

GAlexIHU avatar Mar 31 '25 14:03 GAlexIHU

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

GAlexIHU avatar Mar 31 '25 15:03 GAlexIHU

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)

GAlexIHU avatar Mar 31 '25 15:03 GAlexIHU