Skip to content

ref: new version in adodb publish now should be different, not greater#752

Merged
crnbarr93 merged 11 commits intomainfrom
adodb-publish-adjustment
Jan 15, 2025
Merged

ref: new version in adodb publish now should be different, not greater#752
crnbarr93 merged 11 commits intomainfrom
adodb-publish-adjustment

Conversation

@joemonem
Copy link
Contributor

@joemonem joemonem commented Jan 7, 2025

Motivation

The version provided while publishing to the ADODB should now be different than the current version, not necessarily greater.

Implementation

ensure!(
            new_version != current_version,
            ContractError::InvalidADOVersion {
                msg: Some("Version must be different than the current version".to_string())
            }
        );

Testing

No tests were impacted

Version Changes

andromeda-adodb: 1.1.2 -> 1.1.3

Notes

Removed some outdated TODO comments, reworded the contract error accordingly for the above change.

Future work

None

Summary by CodeRabbit

Summary by CodeRabbit

  • Changed

    • Updated version validation during publish to ensure versions are different, not just greater.
    • Updated package version to 1.1.3-b.1.
  • Chores

    • Enhanced error handling and logic flow in version management functions.
    • Added rstest for parameterized testing and introduced new test scenarios for version updates.
    • Updated dependency versions across multiple packages to reflect the new version of andromeda-adodb.

@joemonem joemonem requested a review from crnbarr93 January 7, 2025 15:15
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Walkthrough

The pull request introduces a change in the version validation logic for the ADODB (Andromeda Database) functionality. The modification ensures that during the publish process, the new version must be different from the current version, rather than simply being greater. This change is reflected in the publish function within the ADODB contract, updating the version comparison logic and error messaging. Additionally, the package version has been updated from 1.1.2 to 1.1.3-b.1, and new test cases have been added to improve testing coverage.

Changes

File Change Summary
CHANGELOG.md Added entry about version validation change during publish
contracts/os/andromeda-adodb/Cargo.toml Updated package version from 1.1.2 to 1.1.3-b.1; added rstest as a development dependency
contracts/os/andromeda-adodb/src/execute.rs Modified version comparison logic in publish function to check for difference instead of greater than; removed outdated comments
contracts/os/andromeda-adodb/src/state.rs Enhanced error handling and logic flow in store_code_id and remove_code_id functions
contracts/os/andromeda-adodb/src/tests.rs Added parameterized tests using rstest for version updates; improved existing test structure
contracts/os/andromeda-kernel/src/execute.rs Removed import of merge_coins from andromeda_std::common
contracts/os/andromeda-kernel/src/query.rs Removed import of Ics20PacketInfo from kernel module
packages/andromeda-testing-e2e/Cargo.toml Updated andromeda-adodb dependency version from 1.0.0 to 1.1.3-b.1
packages/andromeda-testing/Cargo.toml Updated andromeda-adodb dependency version from 1.0.0 to 1.1.3-b.1 and added "testing" feature
packages/deploy/Cargo.toml Updated andromeda-adodb dependency version from 1.1.1 to 1.1.3-b.1

Possibly related PRs

  • chore: Version Updates #488: This PR updates the version of the andromeda-adodb dependency in multiple Cargo.toml files, which is directly related to the version validation changes made in the main PR.
  • Removed Rates module from Point ADO #761: This PR involves the removal of the Rates module from the Point ADO, which may relate to the overall version management and validation logic discussed in the main PR, particularly in how versions are handled across different modules.

Poem

🐰 A Rabbit's Versioning Verse 🐰

In the world of code, a change so neat,
Where versions dance to a different beat.
Not just greater, but uniquely styled,
Our ADODB logic, now reconciled!
A version's worth is more than just height,
With tests in place, our future's bright! 🌟


📜 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 1403abb and d7861e7.

📒 Files selected for processing (1)
  • contracts/os/andromeda-adodb/src/state.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • contracts/os/andromeda-adodb/src/state.rs
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Contract Tests (ubuntu-latest, unit-test)
  • GitHub Check: Contract Tests (ubuntu-latest, integration-test)
  • GitHub Check: Schemas
  • GitHub Check: Contracts
  • GitHub Check: Linting
  • GitHub Check: Summary

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@joemonem joemonem requested a review from SlayerAnsh January 7, 2025 15:23
Copy link
Contributor

@SlayerAnsh SlayerAnsh left a comment

Choose a reason for hiding this comment

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

In store_code_id, new version is automatically assigned to Latest version if its not a prerelease version. It should now have a check for new version being greater than Latest version to update Latest Version

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

♻️ Duplicate comments (2)
contracts/os/andromeda-adodb/src/state.rs (2)

31-32: 🛠️ Refactor suggestion

Avoid using unwrap_or with default values in critical logic

Using unwrap_or(ADOVersion::from_string(String::default())) may lead to unintended behavior if curr_type is None, as it defaults to an empty ADOVersion, which may not match ado_version. Since you've already checked curr_type.is_none(), you can avoid the unnecessary unwrapping for clarity and correctness.


71-72: 🛠️ Refactor suggestion

Avoid using unwrap_or with default values in critical logic

Similar to the earlier instance in store_code_id, using unwrap_or(ADOVersion::from_string(String::default())) may lead to unintended behavior. It's better to handle the Option without defaulting to an empty ADOVersion to ensure the logical checks are accurate.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 070eaf5 and f116c10.

📒 Files selected for processing (3)
  • contracts/os/andromeda-adodb/Cargo.toml (1 hunks)
  • contracts/os/andromeda-adodb/src/execute.rs (2 hunks)
  • contracts/os/andromeda-adodb/src/state.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • contracts/os/andromeda-adodb/Cargo.toml
  • contracts/os/andromeda-adodb/src/execute.rs
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Contract Tests (ubuntu-latest, unit-test)
  • GitHub Check: Contract Tests (ubuntu-latest, integration-test)
  • GitHub Check: Contract Tests (ubuntu-latest, unit-test)
  • GitHub Check: Contract Tests (ubuntu-latest, integration-test)
  • GitHub Check: Schemas
  • GitHub Check: Contracts
  • GitHub Check: Summary

Comment on lines 91 to 93
let current_version =
semver::Version::parse(version).unwrap_or(Version::new(0, 0, 0));
if penultimate_version < current_version && current_version < latest_version
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Review version selection logic in remove_code_id to align with the new versioning requirement

The current logic for finding the penultimate version relies on comparing versions using < operators to identify the next highest version below the latest. Since the requirement now is that the version must be different, not necessarily greater or lesser, this logic may not correctly identify the appropriate version to set as the new latest when the current latest version is removed. Consider adjusting the logic to select any different version as the new latest.

Comment on lines +44 to +49
let should_update = current_ado_version
.map(|(ver, _)| {
let current_version = semver::Version::parse(&ver).unwrap_or(Version::new(0, 0, 0));
version > current_version
})
.unwrap_or(true); // If there's no current version, we should update
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update version comparison logic to ensure the new version is different, not necessarily greater

The current logic checks if the new version is greater than the current version (version > current_version), but according to the PR objectives, the new version must be different from the current version, regardless of whether it's greater or lesser. To align with this requirement, please update the comparison to check for inequality instead.

Apply this diff to correct the logic:

-                    version > current_version
+                    version != current_version
📝 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 should_update = current_ado_version
.map(|(ver, _)| {
let current_version = semver::Version::parse(&ver).unwrap_or(Version::new(0, 0, 0));
version > current_version
})
.unwrap_or(true); // If there's no current version, we should update
let should_update = current_ado_version
.map(|(ver, _)| {
let current_version = semver::Version::parse(&ver).unwrap_or(Version::new(0, 0, 0));
version != current_version
})
.unwrap_or(true); // If there's no current version, we should update

Copy link
Contributor

@crnbarr93 crnbarr93 left a comment

Choose a reason for hiding this comment

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

We should also add unit tests for this to ensure designed outcome.

If an ADO has version 1.0.0-b.1 then the following versions should be valid:

  • 1.0.0-b.2
  • 1.0.1
  • 1.0.1-b.x
  • 1.1.0
  • 1.1.0-b.x
  • 2.0.0
  • 2.0.0-b.x

As they all bump at least one of the elements of the version. However only a strictly greater than should update the LATEST_VERSION.

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: 0

🧹 Nitpick comments (1)
contracts/os/andromeda-adodb/src/tests.rs (1)

754-771: Consider adding documentation for test cases.

While the test cases are well-structured, adding documentation to explain the purpose and expected behavior of each test case would improve maintainability.

+// Test cases for version updates:
+// 1. Beta version scenarios:
+//    - Increment beta version number
+//    - Transition from beta to regular version
+//    - Maintain beta status with version changes
+// 2. Regular version scenarios:
+//    - Patch, minor, and major increments
+//    - Transition to beta versions
+//    - Lower version handling
 #[rstest]
 #[case("1.0.0-b.1", "1.0.0-b.2", false, true)] // Beta version increment
 #[case("1.0.0-b.1", "1.0.1", true, true)] // Patch increment from beta
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f116c10 and 761909b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • contracts/os/andromeda-adodb/Cargo.toml (2 hunks)
  • contracts/os/andromeda-adodb/src/state.rs (4 hunks)
  • contracts/os/andromeda-adodb/src/tests.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • contracts/os/andromeda-adodb/Cargo.toml
  • contracts/os/andromeda-adodb/src/state.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (3)
contracts/os/andromeda-adodb/src/tests.rs (3)

12-12: LGTM! Good use of parameterized testing.

The addition of the rstest crate is a good choice for organizing test cases.


722-726: LGTM! Improved readability.

The array initialization is now more readable with each version on a separate line.


754-771: LGTM! Comprehensive test coverage for version updates.

The test cases thoroughly cover various version update scenarios including beta versions, regular versions, and their transitions.

@joemonem joemonem requested a review from crnbarr93 January 9, 2025 13:16
Copy link
Contributor

@crnbarr93 crnbarr93 left a comment

Choose a reason for hiding this comment

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

Small version change then LGTM!

@joemonem joemonem requested a review from SlayerAnsh January 10, 2025 14:55
.for_each(|v| {
if let Some((_, version)) = v.split_once('@') {
let current_version = semver::Version::parse(version).unwrap();
let current_version =
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove doesn't check if the new latest version is prerelease version or not. Pre release can never be latest according to our store code logic.

@crnbarr93 crnbarr93 added the backport/release/4 backport to release/4 label Jan 14, 2025
@joemonem joemonem requested a review from SlayerAnsh January 15, 2025 07:52
@crnbarr93 crnbarr93 merged commit 93abfa9 into main Jan 15, 2025
12 checks passed
@crnbarr93 crnbarr93 deleted the adodb-publish-adjustment branch January 15, 2025 11:09
mergify bot pushed a commit that referenced this pull request Jan 15, 2025
crnbarr93 pushed a commit that referenced this pull request Jan 15, 2025
…r (backport #752) (#766)

Co-authored-by: Joe Monem <66594578+joemonem@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/release/4 backport to release/4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants