Skip to content

fix(ci): update the Buf CI to push tags to the Buf Schema Registry#280

Merged
rach-id merged 5 commits intocelestiaorg:mainfrom
rach-id:fix-bsr-push
Oct 7, 2024
Merged

fix(ci): update the Buf CI to push tags to the Buf Schema Registry#280
rach-id merged 5 commits intocelestiaorg:mainfrom
rach-id:fix-bsr-push

Conversation

@rach-id
Copy link
Member

@rach-id rach-id commented Oct 7, 2024

This PR fixes the push of a new tag to BSR.

Tested in my fork in here: https://buf.build/chamirachid/nmt/labels

Summary by CodeRabbit

  • New Features

    • Introduced a new GitHub Actions workflow for continuous integration of Buf-related changes.
    • Added a workflow for automating the release of protobuf definitions to the Buf Schema Registry.
    • New script for downloading the specified version of the buf binary.
  • Bug Fixes

    • Removed the outdated buf-ci workflow to streamline processes.

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 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 12 minutes and 35 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 a304db5 and c4e7110.

Walkthrough

The changes involve the removal of an existing GitHub Actions workflow file and the introduction of two new workflow files along with a shell script. The old workflow defined in .github/workflows/buf-ci.yaml was replaced by a new workflow in .github/workflows/buf-ci.yml, which enhances the CI process for Buf-related changes. Additionally, a new workflow for releasing protobuf definitions to the Buf Schema Registry was added in .github/workflows/buf-release.yml, and a script for downloading the buf binary was introduced in scripts/buf-download.sh.

Changes

File Path Change Summary
.github/workflows/buf-ci.yaml Removed the old buf-ci workflow that handled linting and breaking change checks for Protobuf.
.github/workflows/buf-ci.yml Added a new buf-ci workflow with enhanced steps for setting up the Buf environment and checks.
.github/workflows/buf-release.yml Introduced a new buf-release workflow for automating the release of protobuf definitions.
scripts/buf-download.sh Added a new script to download the buf binary, specifying the version and setting executable permissions.

Possibly related PRs

  • ci: support releasing proto definitions to BSR #274: The changes in this PR involve the introduction of a new GitHub Actions workflow for CI that includes similar functionality for managing Protocol Buffers, specifically related to the Buf tool, which aligns closely with the changes made in the main PR regarding the workflows for Buf.

Suggested labels

chore

Suggested reviewers

  • rootulp
  • MSevey

Poem

In the burrow where we play,
New workflows hop in every day.
With Buf to guide our way,
We lint and push, come what may!
A script to fetch, oh what a treat,
Protobufs ready, can't be beat! 🐇✨


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.

@rach-id rach-id requested review from MSevey and rootulp October 7, 2024 17:54
@rach-id rach-id self-assigned this Oct 7, 2024
@codecov
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.01%. Comparing base (d6a3436) to head (a304db5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #280   +/-   ##
=======================================
  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: 2

🧹 Outside diff range and nitpick comments (4)
scripts/buf-download.sh (2)

5-6: Consider improving version management.

While setting the BUF_VERSION variable is good for consistency, consider the following improvements:

  1. Add a comment explaining why this specific version was chosen.
  2. Consider making the version configurable, either through an environment variable or a command-line argument, to make it easier to update in the future.

Example:

# Set BUF_VERSION to 1.44.0 or use the value from the BUF_VERSION environment variable if set
BUF_VERSION=${BUF_VERSION:-1.44.0}

7-10: Approve download logic with suggestions for improvement.

The download logic is well-constructed:

  • Uses curl with appropriate options.
  • Dynamically constructs the URL based on the OS and architecture.
  • Correctly sets the executable permission.

However, consider adding error handling:

  1. Check if the download was successful.
  2. Verify the integrity of the downloaded binary (e.g., using checksums).
  3. Add error messages for failed downloads or permission changes.

Example improvement:

if ! curl -sSL \
    "https://github.com/bufbuild/buf/releases/download/v$BUF_VERSION/buf-$(uname -s)-$(uname -m)" \
    -o "./buf"; then
    echo "Failed to download buf binary" >&2
    exit 1
fi

if ! chmod +x "./buf"; then
    echo "Failed to set executable permission on buf binary" >&2
    exit 1
fi

if ! ./buf --version; then
    echo "Failed to verify buf binary" >&2
    exit 1
fi
.github/workflows/buf-ci.yml (1)

15-15: Consider specifying a version for the Buf setup action.

While using the latest version is often desirable, it's generally a good practice to pin action versions to ensure reproducibility and prevent unexpected changes. Consider updating the Buf setup action to use a specific version:

- uses: bufbuild/buf-setup-action@v1
+ uses: bufbuild/buf-setup-action@v1.27.1

Replace 1.27.1 with the latest stable version available at the time of implementation.

.github/workflows/buf-release.yml (1)

7-14: LGTM: Job setup and initial steps are well-configured.

The job setup and initial steps are well-configured:

  • Using the latest Ubuntu ensures up-to-date dependencies.
  • The checkout action is at the latest major version (v4).
  • The Buf setup action uses a specific version (1.44.0), which is good for reproducibility.

Consider setting up a process to periodically review and update the Buf version (currently 1.44.0) to ensure you're using the latest features and security updates.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d6a3436 and a304db5.

📒 Files selected for processing (4)
  • .github/workflows/buf-ci.yaml (0 hunks)
  • .github/workflows/buf-ci.yml (1 hunks)
  • .github/workflows/buf-release.yml (1 hunks)
  • scripts/buf-download.sh (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/buf-ci.yaml
🧰 Additional context used
🪛 yamllint
.github/workflows/buf-release.yml

[error] 26-26: trailing spaces

(trailing-spaces)

🔇 Additional comments (8)
scripts/buf-download.sh (1)

1-4: LGTM: Clear shebang and descriptive comment.

The script starts with the correct shebang for a bash script, and the comment clearly explains the purpose of the script.

.github/workflows/buf-ci.yml (5)

1-6: LGTM: Workflow name and trigger events are well-defined.

The workflow name 'buf-ci' is concise and descriptive. The trigger events (push to main and pull requests) are appropriate for a continuous integration workflow.


7-9: LGTM: Permissions are appropriately set.

The permissions follow the principle of least privilege, granting only the necessary access: read for contents and write for pull requests. This is a good security practice.


10-12: LGTM: Job definition is clear and uses an appropriate runner.

The job is well-named as 'buf' and uses the latest Ubuntu runner, which is a good practice for ensuring up-to-date dependencies.


13-22: Clarify the implementation of pushing changes to the Buf Schema Registry.

The PR objectives mention implementing a test for pushing a new tag to the Buf Schema Registry (BSR). However, the current workflow doesn't include a step for this. Could you clarify if this functionality is implemented elsewhere or if it should be added to this workflow?

#!/bin/bash
# Description: Check for Buf push commands in other workflow files

# Test: Search for Buf push commands in other workflow files
echo "Searching for Buf push commands in other workflow files:"
grep -R "buf push" .github/workflows/*.y*ml

# Test: Check for a separate release workflow
echo "Checking for a separate release workflow:"
ls .github/workflows/*release*.y*ml

If you'd like assistance in adding a step to push changes to the Buf Schema Registry, please let me know, and I can provide a code snippet for that.


18-22: Verify the 'pb' directory usage.

The workflow uses the 'pb' directory as input for both the breaking change check and lint actions. Please confirm that this directory contains all the necessary protobuf files for your project.

✅ Verification successful

Further verification needed. Please run the following scripts to confirm the 'pb' directory and its .proto files:


'pb' directory is present and contains the required .proto files.

  • No further action needed regarding the 'pb' directory usage in the workflow.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and contents of the 'pb' directory

# Test: Check if the 'pb' directory exists and list its contents
if [ -d "pb" ]; then
    echo "The 'pb' directory exists. Contents:"
    ls -R pb
else
    echo "Error: The 'pb' directory does not exist."
    exit 1
fi

# Test: Check for .proto files in the 'pb' directory
proto_files=$(find pb -name "*.proto")
if [ -n "$proto_files" ]; then
    echo "Found .proto files in the 'pb' directory:"
    echo "$proto_files"
else
    echo "Warning: No .proto files found in the 'pb' directory."
fi

Length of output: 664


Script:

#!/bin/bash
# Description: Verify the existence and contents of the 'pb' directory

# Check if the 'pb' directory exists
if [ -d "pb" ]; then
    echo "The 'pb' directory exists."
    # List contents of the 'pb' directory
    echo "Contents of 'pb' directory:"
    ls -R pb
else
    echo "Error: The 'pb' directory does not exist."
    exit 1
fi

# Check for .proto files in the 'pb' directory
echo "Searching for .proto files in 'pb' directory..."
proto_files=$(find pb -type f -name "*.proto")
if [ -n "$proto_files" ]; then
    echo "Found .proto files:"
    echo "$proto_files"
else
    echo "Warning: No .proto files found in the 'pb' directory."
fi

Length of output: 483

.github/workflows/buf-release.yml (2)

1-5: LGTM: Workflow name and trigger are well-defined.

The workflow name "buf-release" is descriptive and the trigger on tags matching "v*" is appropriate for a release workflow. This ensures that the workflow runs when version tags are pushed, which is typically when releases are made.


15-18: LGTM: Buf push action is correctly configured.

The Buf push action is well-configured:

  • It uses the official bufbuild/buf-push-action@v1.
  • The Buf token is correctly stored and accessed as a GitHub secret, which is a good security practice.
  • The comment above the action provides clarity on its purpose.

@rach-id
Copy link
Member Author

rach-id commented Oct 7, 2024

failing go build CI is because I am creating the PR from a fork and codecov doesn't have permissions to check it.

the failing linter is fixed in #278

the markdown contains some dead links but there is an issue to fix them

Copy link
Contributor

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

utACK

@rach-id rach-id enabled auto-merge (squash) October 7, 2024 18:32
@rach-id rach-id merged commit b2a0187 into celestiaorg:main Oct 7, 2024
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.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants