Skip to content

Automatic Changelog.md idea#104

Merged
grunch merged 4 commits intomainfrom
changelog
May 6, 2025
Merged

Automatic Changelog.md idea#104
grunch merged 4 commits intomainfrom
changelog

Conversation

@arkanoider
Copy link
Collaborator

@arkanoider arkanoider commented May 4, 2025

@grunch , @Catrya

this is a simple example on the use of two tools:

they can simplify some work on version bumping and magically create new tags and versions bumping, you can read on documentation the many customization, basically you just need to install them with:

cargo install cargo-release
cargo install git-cliff

Then you have to init Cliff with your preferred style ( i used github in my example ), more details here and then configuring cargo.toml you can call cargo release and see the magic:

You will get a CHANGELOG.md automatically with latest commits like this:

## What's Changed in 0.6.39
* fix: modified cargo.toml
* : removed changelog.md
* : add cargo-release and cargo-cli to automatize version bumping and changelogs
* Bump version to v0.6.38 by @grunch

**Full Changelog**: https://github.com/MostroP2P/mostro-core/compare/v0.6.38...0.6.39

<!-- generated by git-cliff -->

Cargo release will also patch version, we can choose:

  • patch
  • minor
  • major

Tipically you run a dry test which is default and then with execute you can really create the modifications, this link has all the possible customization of cargo release.
Typically you use this only in main/master branch, but also there is the possibility to allow others. So the flow could be:

  • Create a new branch to work
  • Do the work
  • Test and merge
  • Cargo release dry
  • Cargo release execute

We can also publish and push automatically and sign the commits.

Note: I think that github bothers if you do some API request in a small time and maybe we need to setup a GITHUB_TOKEN to have more API access.
Just starting to use this

Summary by CodeRabbit

  • Chores

    • Updated project metadata and release automation settings, including changelog generation and stricter release requirements.
    • Upgraded Rust toolchain version to 1.85.0.
    • Added configuration for automated changelog generation.
  • Refactor

    • Replaced generic error handling with explicit, domain-specific error types in order and rating processing.
    • Cleaned up unused imports and improved import ordering in message handling code.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 4, 2025

Walkthrough

This set of changes updates project metadata, toolchain configuration, and error handling within the codebase. The Cargo.toml file is enhanced with release automation settings and repository links, while a new cliff.toml file is introduced to configure changelog generation using git-cliff. The Rust toolchain version is incremented from 1.82.0 to 1.85.0. In the source code, error handling in src/order.rs and src/rating.rs is refactored to use a custom ServiceError type instead of the generic anyhow::Result. Minor import cleanups are also made in src/message.rs.

Changes

File(s) Change Summary
Cargo.toml Added homepage and repository fields; introduced [package.metadata.release] for release automation and changelog generation.
cliff.toml New configuration file for git-cliff, specifying changelog template and commit parsing rules.
rust-toolchain.toml Updated Rust toolchain version from 1.82.0 to 1.85.0.
src/message.rs Removed unused import and reordered imports in test module.
src/order.rs Refactored error handling in SmallOrder methods to use ServiceError instead of anyhow::Result.
src/rating.rs Refactored Rating::from_tags to use ServiceError for error handling instead of anyhow::Result.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SmallOrder
    participant ServiceError

    User->>SmallOrder: Call from_json(json)
    SmallOrder->>SmallOrder: Deserialize JSON
    alt Deserialization fails
        SmallOrder->>ServiceError: Return MessageSerializationError
        SmallOrder-->>User: Err(ServiceError)
    else Success
        SmallOrder-->>User: Ok(SmallOrder)
    end
Loading
sequenceDiagram
    participant User
    participant Rating
    participant ServiceError

    User->>Rating: Call from_tags(tags)
    Rating->>Rating: Parse tags
    alt Missing or invalid tag
        Rating->>ServiceError: Return NostrError or ParsingNumberError
        Rating-->>User: Err(ServiceError)
    else Success
        Rating-->>User: Ok(Rating)
    end
Loading

Possibly related PRs

  • MostroP2P/mostro-core#65: Also modifies error handling in the from_tags method of the Rating struct, replacing unwrap() with explicit error returns, closely related to the error handling refactor in this PR.

Poem

In the garden where code does grow,
New errors now have names to show.
With changelogs sprouting, neat and clear,
And toolchains marching without fear.
Imports trimmed, the branches sway—
A rabbit hops and shouts, “Hooray!
For tidy code and structured play!” 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26cdd08 and 1508e68.

📒 Files selected for processing (1)
  • cliff.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cliff.toml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

@grunch grunch marked this pull request as ready for review May 5, 2025 15:46
Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@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 comments (1)
cliff.toml (1)

63-81: ⚠️ Potential issue

Conflict between commit parsing settings
You have conventional_commits = false alongside filter_unconventional = true. Since parsing is disabled, all commits will be considered “unconventional” and thus filtered out—resulting in an empty changelog. Either enable conventional_commits or set filter_unconventional = false.

🧹 Nitpick comments (2)
src/message.rs (1)

432-432: Import reordering in test module

The import for crate::user::UserInfo has been moved after the crate::message imports, improving the organization of import statements.

This is a good practice as it groups related imports together (module-specific imports first, then external module imports).

Cargo.toml (1)

14-31: Document GITHUB_TOKEN requirement
To prevent GitHub API rate limits when generating the changelog, users should export a GITHUB_TOKEN. Consider adding a note in README.md or project docs with setup instructions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1f27fd and 26cdd08.

📒 Files selected for processing (6)
  • Cargo.toml (1 hunks)
  • cliff.toml (1 hunks)
  • rust-toolchain.toml (1 hunks)
  • src/message.rs (1 hunks)
  • src/order.rs (1 hunks)
  • src/rating.rs (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/order.rs (2)
src/message.rs (6)
  • from_json (32-34)
  • from_json (150-152)
  • from_json (283-285)
  • as_json (36-38)
  • as_json (155-157)
  • as_json (287-289)
src/rating.rs (2)
  • from_json (34-36)
  • as_json (39-41)
🔇 Additional comments (11)
rust-toolchain.toml (1)

2-2:

Details

❓ Verification inconclusive

Rust toolchain updated to 1.85.0

The Rust toolchain version has been updated from 1.82.0 to 1.85.0, which includes performance improvements, bug fixes, and new language features.


🏁 Script executed:

#!/bin/bash
# Verify Rust version compatibility with the codebase

# Check if there are any compatibility warnings during compilation
cargo check
echo "Exit code: $?"

# Check if there are any deprecated feature warnings
cargo check --message-format=json | grep -i "warn.*deprecated"

Length of output: 309


Verify Rust 1.85.0 compatibility

File: rust-toolchain.toml
Lines: 2–2

channel = "1.85.0"

The Rust toolchain has been bumped from 1.82.0 to 1.85.0. Please manually confirm that:

  • The project still compiles cleanly under Rust 1.85.0 (rustup override set 1.85.0 && cargo check).
  • No new deprecation or compatibility warnings appear.
  • Your CI workflows are updated to use the new toolchain.
src/rating.rs (5)

4-5: Improved error handling with ServiceError

The code now uses a custom ServiceError type for error handling instead of generic anyhow::Result.

This change is part of a broader effort to use domain-specific error types throughout the codebase, which will improve error clarity and handling.


78-78: Method signature updated to use ServiceError

The from_tags method signature has been updated to return Result<Self, ServiceError> instead of using the generic anyhow::Result.

This change makes the error type explicit and aligns with the overall error handling improvements in the codebase.


89-90: Improved error handling for missing tag key

Error creation for missing tag keys now returns a specific ServiceError::NostrError with a descriptive message.

This provides more context about the error and makes debugging easier.


92-92: Improved error handling for missing tag value

Error creation for missing tag values now returns a specific ServiceError::NostrError with a descriptive message.

Similar to the previous change, this improves error context and debugging.


94-118: Enhanced numeric parsing error handling

Parsing of string values into numeric types (u64, f64, u8) now maps parsing errors to a specific ServiceError::ParsingNumberError rather than propagating generic errors.

This change:

  1. Makes errors more specific and easier to handle
  2. Provides consistent error types for parsing failures
  3. Aligns with domain-driven error handling
src/order.rs (2)

464-465: JSON deserialization error handling improved

The from_json method now returns Result<Self, ServiceError> and explicitly maps JSON deserialization errors to a specific ServiceError::MessageSerializationError.

This change provides clearer error handling with domain-specific error types rather than using generic errors.


469-470: JSON serialization error handling improved

The as_json method now returns Result<String, ServiceError> and explicitly maps JSON serialization errors to a specific ServiceError::MessageSerializationError.

Similar to the deserialization improvement, this change standardizes error handling across the codebase.

cliff.toml (1)

9-53: Changelog template formatting
The Tera template covers commits, PR titles, authors, and first-time contributors effectively, and trim = true will strip extra whitespace. The overall structure aligns with GitHub style; no changes needed here.

Cargo.toml (2)

8-9: Added project homepage and repository metadata
Including homepage and repository links enhances project discoverability and aligns with Cargo best practices.


14-31: Release automation configuration
The [package.metadata.release] section is correctly set up for cargo-release: tests are verified, commits/tags are signed, and the pre-release hook runs git cliff to generate CHANGELOG.md.

@grunch grunch merged commit 5ad8714 into main May 6, 2025
2 checks passed
@grunch grunch deleted the changelog branch May 6, 2025 12:15
@grunch
Copy link
Member

grunch commented May 6, 2025

Just a clarification the cliff install command is

cargo install git-cliff

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