-
Notifications
You must be signed in to change notification settings - Fork 176
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
Conversation
WalkthroughOhayo, sensei! This pull request introduces several changes primarily focused on enhancing versioning and build metadata in the Katana project. The Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
⛔ 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.rsLength 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.rsLength 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/ -lLength 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/bashLet'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
crates/katana/node/build.rs
Outdated
let sha = dbg!(env::var("VERGEN_GIT_SHA"))?; | ||
let is_dirty = env::var("VERGEN_GIT_DIRTY")? == "true"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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"; | |
Summary by CodeRabbit
Release Notes
New Features
Chores