Skip to content
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

ci: support releasing proto definitions to BSR #274

Merged
merged 9 commits into from
Sep 25, 2024
Merged

ci: support releasing proto definitions to BSR #274

merged 9 commits into from
Sep 25, 2024

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Sep 24, 2024

Adds support for pushing the proto definitions to BSR

Summary by CodeRabbit

  • New Features

    • Introduced a continuous integration (CI) workflow for automated checks on Protocol Buffers.
    • Added a new module configuration for managing protocol buffers.
  • Documentation

    • New workflow file created to outline CI processes.
    • Configuration file established for module versioning and structure.

@rach-id rach-id added the chore label Sep 24, 2024
@rach-id rach-id requested a review from MSevey September 24, 2024 18:21
@rach-id rach-id self-assigned this Sep 24, 2024
Copy link

coderabbitai bot commented Sep 24, 2024

Warning

Rate limit exceeded

@rach-id has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 55 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 0813aca and 2ef7a65.

Walkthrough

The changes introduce a new GitHub Actions workflow file, buf-ci.yaml, to automate continuous integration processes for a project utilizing Buf for managing Protocol Buffers. Additionally, a new configuration file, buf.yaml, is added, specifying the module's structure and versioning, along with linting rules. These updates collectively enhance the project's CI capabilities and define the module's configuration while addressing potential breaking changes.

Changes

Files Change Summary
.github/workflows/buf-ci.yaml New workflow added for continuous integration using Buf, triggered by specific events.
buf.yaml New configuration file created, defining a module with path pb and name buf.build/celestia/nmt, version v2. Linting rules added to ignore specific issues for pb/proof.proto.

Poem

In the meadow where code does play,
A new workflow hops in, hip-hip-hooray!
With Buf by our side, we’ll check and refine,
Protocols dancing, all in a line.
So let’s celebrate with a joyful cheer,
For CI is here, bringing us near! 🐇✨


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?

Share
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 resolve resolve all the CodeRabbit review comments.
  • @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.

Copy link

github-actions bot commented Sep 24, 2024

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedSep 24, 2024, 7:10 PM

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.01%. Comparing base (29e9433) to head (2ef7a65).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #274   +/-   ##
=======================================
  Coverage   68.01%   68.01%           
=======================================
  Files           6        6           
  Lines        1138     1138           
=======================================
  Hits          774      774           
  Misses        337      337           
  Partials       27       27           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a 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

Outside diff range and nitpick comments (2)
.github/workflows/buf-ci.yaml (2)

1-12: Workflow name and trigger events look good, but consider removing the delete event trigger.

The workflow name "Buf CI" is clear and descriptive. The trigger events appropriately cover pushes to the main branch, version tags, and pull requests. However, the inclusion of the delete event (line 12) is unusual for a CI workflow and may not be necessary.

Consider removing the delete event trigger:

  pull_request:
- delete:

22-30: Buf action configuration is well-structured, but comments could be improved.

The configuration for the Buf action is appropriate:

  • Uses a secret token for secure authentication.
  • Clearly specifies the input directory.
  • Sets up breaking change checks against the main branch.
  • Optimizes the workflow by conditionally running checks only on push events.

Consider cleaning up the comments on lines 26-27 by formatting them as proper YAML comments:

-          # Run breaking change, lint, and format checks for Protobuf sources against all branches,
-          'pb' # subdirectory, then push to the BSR once validated
+          # Run breaking change, lint, and format checks for Protobuf sources against all branches,
+          # then push to the BSR once validated
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 29e9433 and bbf5dc5.

Files selected for processing (2)
  • .github/workflows/buf-ci.yaml (1 hunks)
  • buf.yaml (1 hunks)
Additional comments not posted (4)
buf.yaml (1)

1-4: LGTM! The buf.yaml configuration looks correct.

The configuration is well-structured and aligns with the PR objective of supporting the release of proto definitions to BSR (Binary Serialization Repository). It correctly specifies the Buf version and defines a module with the appropriate path and name.

Consider adding a comment at the top of the file to explain its purpose, for example:

# Configuration for Buf (https://buf.build) to manage and publish Protocol Buffer definitions

This will improve maintainability and help other developers understand the file's role in the project.

Let's verify if there are any .proto files in the repository that this configuration will apply to:

Verification successful

Verification Successful: .proto files are present in the repository.

The buf.yaml configuration correctly specifies the module path and is set up to manage and publish Protocol Buffer definitions.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for the existence of .proto files in the repository

# Test: Search for .proto files
fd -e proto

# If no .proto files are found, it might indicate a potential issue or missing files
if [ $? -ne 0 ]; then
    echo "No .proto files found in the repository. Please verify if this is intended."
fi

Length of output: 46

.github/workflows/buf-ci.yaml (3)

13-15: Permissions are well-defined and follow the principle of least privilege.

The permissions are appropriately set:

  • Read access for contents is sufficient for most CI operations.
  • Write access for pull-requests allows the workflow to update PR status and comments.

This configuration ensures the workflow has the necessary permissions without over-privileging.


16-21: Job definition and steps are well-structured and use appropriate actions.

The job definition is clear and concise:

  • Uses the latest Ubuntu runner for compatibility.
  • Employs the latest major version of the checkout action (v4).
  • Utilizes a specific major version of the buf-action (v1) for stability.

This setup provides a good balance between using up-to-date tools and maintaining stability.


1-30: Overall, the Buf CI workflow is well-designed and follows best practices.

The workflow effectively sets up a CI pipeline for Protocol Buffers using Buf. It covers essential aspects such as:

  • Appropriate trigger events
  • Least privilege permissions
  • Proper job and step definitions
  • Secure and optimized Buf action configuration

The minor suggestions provided earlier (removing the delete event trigger and cleaning up comments) would further refine this already solid workflow.

Copy link

@coderabbitai coderabbitai bot left a 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

Outside diff range and nitpick comments (3)
buf.yaml (3)

1-4: LGTM! Consider adding a brief comment for clarity.

The version and module configuration look good. The use of version "v2" is appropriate, and the module naming follows a standard convention.

Consider adding a brief comment above the modules section to explain the purpose of this configuration, e.g.:

# Define the Protocol Buffer module for the NMT (Namespaced Merkle Tree) project
modules:
  - path: pb
    name: buf.build/celestia/nmt

5-12: Linting exceptions noted. Consider creating follow-up tasks.

The linting configuration is ignoring two rules for pb/proof.proto to avoid breaking changes. While this is understandable, it's important to address these issues in the future.

Consider the following suggestions:

  1. Create GitHub issues to track these linting exceptions.
  2. Add TODO comments in the pb/proof.proto file to highlight these exceptions.
  3. Plan for addressing these in the next major version update when breaking changes are acceptable.

This will ensure that these exceptions are not forgotten and can be addressed at an appropriate time.


1-12: Good addition for Protocol Buffer management. Consider documentation updates.

The addition of buf.yaml is a positive step towards better management of Protocol Buffers in the project. It sets up a clear structure for the module and acknowledges current limitations with a plan to address them in the future.

To fully leverage this addition:

  1. Update the project's README or documentation to mention the use of Buf for Protocol Buffer management.
  2. If not already in place, consider adding a section in the contributing guidelines about working with Protocol Buffers and using the Buf tool.
  3. Ensure that the CI/CD pipeline is updated to use this configuration for validating Protocol Buffer changes.

These steps will help team members and contributors understand and effectively use this new configuration.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bbf5dc5 and 0813aca.

Files selected for processing (2)
  • .github/workflows/buf-ci.yaml (1 hunks)
  • buf.yaml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/buf-ci.yaml

@rach-id
Copy link
Member Author

rach-id commented Sep 24, 2024

CI will be fixed by:
#276
and
#275

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was this PR tested? Did your fork push proto definitions to Buf Schema Registry successfully? Or will it be tested after this PR merges?

.github/workflows/buf-ci.yaml Outdated Show resolved Hide resolved
.github/workflows/buf-ci.yaml Outdated Show resolved Hide resolved
@rach-id
Copy link
Member Author

rach-id commented Sep 24, 2024

How was this PR tested? Did your fork push proto definitions to Buf Schema Registry successfully? Or will it be tested after this PR merges?

it should be tested after the PR is merged

Copy link

The latest Buf updates on your PR. Results from workflow buf-ci / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedSep 24, 2024, 7:12 PM

branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless you are creating a bunch of tags that start with v that aren't version tags, I think you can simplify this to just v*.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just followed the same tags we're using in all other repos. and I think it's better since we know the exact tags formats we target

@MSevey
Copy link
Member

MSevey commented Sep 25, 2024

How was this PR tested? Did your fork push proto definitions to Buf Schema Registry successfully? Or will it be tested after this PR merges?

it should be tested after the PR is merged

For GH actions that can't be tested on the PR, because they require being on main to be tested, I recommend either using a fork or having a personal repo like workflows where you can do all testing on the action to make sure it works.

I have a MSevey/workflows repo or example that I do a lot of testing on for new actions to better understand them prior to merging into a project.

@rach-id
Copy link
Member Author

rach-id commented Sep 25, 2024

I tried running this in a personal repo but I keep hitting certain upload permission errors. I will merge this one, test it. if it works, there is no need to waste more time on it. If not, I will fix in a follow up PR

@rach-id rach-id merged commit d6a3436 into main Sep 25, 2024
8 of 10 checks passed
@rach-id rach-id deleted the buf-release branch September 25, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants