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

feat(katana): build version #2590

Merged
merged 3 commits into from
Oct 28, 2024
Merged

feat(katana): build version #2590

merged 3 commits into from
Oct 28, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Oct 28, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Updated the command line interface to reflect the current version dynamically.
    • Introduced a new public module for versioning information.
    • Added constants for package version, Git SHA, and a formatted version string.
  • Chores

    • Updated dependencies in the project to enhance build capabilities.
    • Introduced a build script to generate metadata for builds.

Copy link

coderabbitai bot commented Oct 28, 2024

Walkthrough

Ohayo, sensei! This pull request introduces several changes primarily focused on enhancing versioning and build metadata in the Katana project. The Cli struct now references a constant VERSION for its version attribute. Additionally, new dependencies have been added to the Cargo.toml file, and a new build.rs script has been introduced to generate build metadata using vergen and vergen_gitcl. A new public module version has also been added, which contains constants for versioning information, including the package version and commit SHA.

Changes

File Change Summary
bin/katana/src/cli/mod.rs Updated Cli struct's version attribute to use constant VERSION.
crates/katana/node/Cargo.toml Added new dependency const_format = "0.2.33" and build dependencies vergen and vergen-gitcl with specific versions and features.
crates/katana/node/build.rs Introduced a new build script that generates build metadata using vergen and vergen_gitcl.
crates/katana/node/src/lib.rs Added a new public module version.
crates/katana/node/src/version.rs Added constants: CARGO_PKG_VERSION, VERGEN_GIT_SHA, and VERSION.

Possibly related PRs


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8c75a3e and c41c885.

📒 Files selected for processing (1)
  • crates/katana/node/build.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/katana/node/build.rs

🪧 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.

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

@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: 3

🧹 Outside diff range and nitpick comments (2)
crates/katana/node/src/version.rs (2)

4-5: Consider enhancing the git SHA documentation.

The documentation could be more specific about the SHA format (e.g., whether it's a full or short SHA).

-/// The SHA of the latest commit.
+/// The SHA of the latest commit (first 7 characters).

7-8: Document the timestamp format, sensei!

The build timestamp's format should be specified in the documentation for clarity.

-/// The build timestamp.
+/// The build timestamp in UTC (YYYY-MM-DD HH:MM:SS.SSSSSS).
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ef696ea and 4b0ea86.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • bin/katana/src/cli/mod.rs (1 hunks)
  • crates/katana/node/Cargo.toml (1 hunks)
  • crates/katana/node/build.rs (1 hunks)
  • crates/katana/node/src/lib.rs (1 hunks)
  • crates/katana/node/src/version.rs (1 hunks)
🔇 Additional comments (9)
crates/katana/node/src/version.rs (2)

1-2: Ohayo! Clean and correct package version handling, sensei!

The use of env! macro ensures compile-time version extraction from Cargo.toml.


10-18: Verify DEV_BUILD_SUFFIX environment variable.

The version format looks good, but let's verify the DEV_BUILD_SUFFIX environment variable setup.

✅ Verification successful

DEV_BUILD_SUFFIX is properly configured, sensei! ✨

The build script correctly sets up DEV_BUILD_SUFFIX based on git state:

  • Uses vergen to get git information
  • Adds "-dev" suffix when:
    • Working directory is dirty (VERGEN_GIT_DIRTY)
    • Not on a tagged commit (VERGEN_GIT_DESCRIBE)
  • Empty suffix for clean, tagged releases

The version format implementation is solid and follows best practices! 🎉

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify build.rs sets up DEV_BUILD_SUFFIX correctly

# Test: Check if build.rs handles DEV_BUILD_SUFFIX
rg -l "DEV_BUILD_SUFFIX" build.rs

# Test: Check the actual implementation
ast-grep --pattern 'println!("cargo:rustc-env=DEV_BUILD_SUFFIX=$_")'

Length of output: 153


Script:

#!/bin/bash
# Let's search for build.rs files in the entire repository
fd "build.rs$"

# Search for DEV_BUILD_SUFFIX in all Rust files
rg "DEV_BUILD_SUFFIX" -t rust

# Search for environment variable setup patterns in build scripts
ast-grep --pattern 'println!("cargo:rustc-env=$_=$_")'

Length of output: 438


Script:

#!/bin/bash
# Let's check the implementation in build.rs
rg "DEV_BUILD_SUFFIX" -A 5 -B 5 crates/katana/node/build.rs

# Also check if there's any git-related logic for dev detection
rg "is_dev" crates/katana/node/build.rs

Length of output: 578


Script:

#!/bin/bash
# Let's check how is_dirty is determined
rg "is_dirty" -A 5 -B 5 crates/katana/node/build.rs

# And check the full context of the build script
cat crates/katana/node/build.rs

Length of output: 1583

crates/katana/node/build.rs (2)

1-6: Ohayo! Clean and focused imports, sensei!

The imports are well-organized, separating standard library and external dependencies clearly.


24-26: Clean error handling approach, sensei!

The error handling using Result and ? operator is appropriate for a build script.

crates/katana/node/Cargo.toml (2)

32-33: LGTM! Using const_format for compile-time version string generation.

Ohayo sensei! The const_format crate is a good choice for compile-time string manipulation, which aligns well with version string generation needs.


34-36: Verify build script implementation with these dependencies.

The selected features for vergen and vergen-gitcl look appropriate for generating build metadata. Let's verify the build script implementation:

✅ Verification successful

Ohayo sensei! After analyzing the implementation, I can provide the final response:

Build script implementation correctly uses vergen dependencies ✨

The build.rs implementation properly utilizes both vergen and vergen-gitcl:

  • Correctly configures build timestamp using BuildBuilder
  • Properly sets up git metadata using GitclBuilder with describe, dirty state, and SHA
  • Emits and sets environment variables for version tracking
  • Implements dev build suffix logic based on git state
  • Version constants are properly used in version.rs
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify build.rs exists and uses these dependencies correctly

# Test: Check if build.rs exists and contains vergen usage
echo "Checking build.rs implementation..."
rg -l "use.*vergen" "build.rs"

# Test: Verify the generated constants are used
echo "Checking version constant usage..."
rg "const.*VERSION|use.*vergen" "src/"

Length of output: 323


Script:

#!/bin/bash
# Let's first find the build.rs file location
fd "build.rs$"

# Then check for src directory
fd "^src$" -t d

# Let's also check the actual path of the Cargo.toml to ensure we're in the right location
fd "Cargo.toml$" | grep -i "katana/node"

Length of output: 1969


Script:

#!/bin/bash
# Let's check the build.rs content in the katana node crate
cat crates/katana/node/build.rs

# Also check if version constants are used in the node's src directory
rg "const.*VERSION|use.*vergen" crates/katana/node/src/

Length of output: 1187


Script:

#!/bin/bash
# Let's check the complete version.rs implementation
cat crates/katana/node/src/version.rs

# And see where these version constants are being used
rg "VERSION" crates/katana/node/src/ -l

Length of output: 317

bin/katana/src/cli/mod.rs (2)

7-7: Ohayo! Clean import statement, sensei!

The VERSION constant import is well-placed and properly scoped.


10-10: ```shell
#!/bin/bash

Let's check the version module in katana-node

rg -p "pub.*VERSION" crates/katana/node/src/version.rs

Also check the Cargo.toml version

cat bin/katana/Cargo.toml | grep -A 1 "^[package]"


</blockquote></details>
<details>
<summary>crates/katana/node/src/lib.rs (1)</summary><blockquote>

`5-5`: **Ohayo! The version module addition looks clean, sensei! 🎋**

The placement of the new `version` module follows the existing module organization pattern and maintains good code structure.


Let's verify the version module implementation:

<details>
<summary>✅ Verification successful</summary>

Let me gather more information about the version module implementation.

---

**Ohayo! The version module addition is perfectly aligned, sensei! 🎋**

The new version module in `crates/katana/node/src/version.rs` is well-implemented, providing essential version-related constants that are populated during build time via environment variables. The module:
- Exposes build metadata (version, git SHA, timestamp)
- Uses proper environment variables from vergen and cargo
- Maintains clean separation from other version modules in the codebase

The implementation is non-invasive and follows good practices for version tracking.



</details>

<details>
<summary>🏁 Scripts executed</summary>

The following scripts were executed for the analysis:

Script:

```shell
#!/bin/bash
# Description: Verify the version module implementation and its usage

# Test 1: Check if version.rs exists in the same directory
fd --type f "version.rs" "crates/katana/node/src"

# Test 2: Check for any direct usage of version constants
rg "version::" "crates/katana"

# Test 3: Verify build.rs integration with vergen
fd --type f "build.rs" "crates/katana" --exec rg "vergen"

Length of output: 2896


Script:

#!/bin/bash
# Check the actual implementation of the version module
cat crates/katana/node/src/version.rs

# Check if there are any other version modules in the codebase
fd --type f "version.rs" "crates/katana"

# Check for any direct imports of the new version module
rg "use (crate|super)::version" "crates/katana/node"

Length of output: 780

Comment on lines 15 to 17
let sha = dbg!(env::var("VERGEN_GIT_SHA"))?;
let is_dirty = env::var("VERGEN_GIT_DIRTY")? == "true";

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove debug print statement, sensei!

The dbg! macro should be removed from production code.

-    let sha = dbg!(env::var("VERGEN_GIT_SHA"))?;
+    let sha = env::var("VERGEN_GIT_SHA")?;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let sha = dbg!(env::var("VERGEN_GIT_SHA"))?;
let is_dirty = env::var("VERGEN_GIT_DIRTY")? == "true";
let sha = env::var("VERGEN_GIT_SHA")?;
let is_dirty = env::var("VERGEN_GIT_DIRTY")? == "true";

crates/katana/node/build.rs Show resolved Hide resolved
crates/katana/node/build.rs Show resolved Hide resolved
crates/katana/node/build.rs Outdated Show resolved Hide resolved
crates/katana/node/build.rs Outdated Show resolved Hide resolved
@kariy kariy merged commit 7addea8 into main Oct 28, 2024
13 checks passed
@kariy kariy deleted the katana/version branch October 28, 2024 18:02
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.

2 participants