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

Unify version name constants in images #2096

Merged
merged 2 commits into from
Aug 16, 2024
Merged

Unify version name constants in images #2096

merged 2 commits into from
Aug 16, 2024

Conversation

roy-dydx
Copy link
Contributor

@roy-dydx roy-dydx commented Aug 15, 2024

Changelist

Version names for building images moved to a single source of truth.

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive versioning system for better management of upgrades and tests.
    • Added documentation to guide developers on version updates and management.
  • Bug Fixes

    • Enhanced flexibility in version management by removing hardcoded version strings.
  • Chores

    • Streamlined the build process by including multiple version files in the Docker images.
    • Updated scripts to source the new versioning files, improving maintainability.
  • Documentation

    • Added a README file detailing the versioning system and upgrade protocols.

Copy link
Contributor

coderabbitai bot commented Aug 15, 2024

Walkthrough

The recent changes enhance the versioning management within the protocol's testing framework. Key modifications include introducing a dynamic versioning system, where version details are sourced from dedicated files, improving maintainability. Shell scripts and Dockerfiles have been updated to accommodate these changes, ensuring that version information is consistently referenced throughout the application. These adjustments support agile development practices by streamlining version updates and reducing hardcoded values.

Changes

File Path Change Summary
protocol/testing/containertest/Dockerfile Added a line to copy version files, enhancing the build with version-related resources.
protocol/testing/containertest/containertest.sh Sourced version.sh for dynamic versioning, removed hardcoded variable PREUPGRADE_VERSION.
protocol/testing/containertest/testnet.go Introduced a new import for versioning and replaced hardcoded UpgradeToVersion with version.CurrentVersion.
protocol/testing/containertest/testnet_test.go Changed UpgradeTestnet argument to use version.CurrentVersion, aligning with dynamic versioning.
protocol/testing/mainnet/Dockerfile Replaced single script copy with copying all files from the version directory.
protocol/testing/mainnet/vars.sh Updated sourced file from current_version.sh to version.sh.
protocol/testing/testnet/Dockerfile Changed file copy command from current_version.sh to copy all from the version directory.
protocol/testing/testnet/vars.sh Sourced version.sh instead of current_version.sh.
protocol/testing/version/README.md Introduced documentation for the versioning system used in tests and internal nodes.
protocol/testing/version/VERSION_CURRENT New file added specifying the current protocol version as v6.0.0.
protocol/testing/version/VERSION_PREUPGRADE New file added updating the pre-upgrade version to v5.2.0.
protocol/testing/version/version.go New package managing version information, embedding version from VERSION_CURRENT.
protocol/testing/version/version.sh New script managing versioning, initializing variables and mapping versions to URLs.

Poem

🐇 In a world of code, so bright and bold,
Versioning tales of stories told.
With every change, we hop and cheer,
Dynamic paths, the future is near!
Files unite, a seamless blend,
Together we grow, on this we depend!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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

Outside diff range, codebase verification and nitpick comments (2)
protocol/testing/containertest/testnet.go (1)

12-12: CurrentVersion is not defined in the version package.

The version package located at protocol/testing/version/ does not define CurrentVersion. This suggests that the package might not provide the expected versioning functionality. Please verify the intended use of this package and ensure it meets the necessary requirements.

Analysis chain

Confirm the import of version package.

The import of github.com/dydxprotocol/v4-chain/protocol/testing/version suggests using dynamic versioning. Ensure this package provides the necessary functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence and functionality of the `version` package.

# Test: Check if `version.CurrentVersion` is defined and used correctly.
ast-grep --lang go --pattern $'package version\n\nconst CurrentVersion = $_'

Length of output: 540


Script:

#!/bin/bash
# Description: Verify the presence and functionality of the `version` package.

# Test: Check if `CurrentVersion` is defined in the `version` package.
ast-grep --lang go --pattern $'const CurrentVersion = $_' -- 'protocol/testing/version/*.go'

Length of output: 170


Script:

#!/bin/bash
# Description: Search for the `version` package in the repository.

# Find directories or files related to `version`.
fd version --type d
fd version.go --type f

Length of output: 108


Script:

#!/bin/bash
# Description: Verify the presence of `CurrentVersion` in the `version` package.

# Check if `CurrentVersion` is defined in `version.go`.
ast-grep --lang go --pattern $'const CurrentVersion = $_' protocol/testing/version/version.go

Length of output: 94

protocol/testing/containertest/containertest.sh (1)

8-8: Update sourcing path for version.sh in containertest.sh.

The version.sh file is located at protocol/testing/version/version.sh. Update the sourcing path in containertest.sh to correctly reference this file to avoid runtime errors.

  • Update line 8 in protocol/testing/containertest/containertest.sh to source "../version/version.sh"
Analysis chain

Ensure version.sh is correctly sourced.

The addition of source "./version.sh" suggests that version information is now dynamically sourced. Verify that version.sh is present in the expected directory and correctly defines the necessary variables or functions.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `version.sh` is present and correctly defines the necessary variables or functions.

# Test: Check for the existence of `version.sh` and inspect its contents.
if [[ -f "./version.sh" ]]; then
  echo "version.sh exists."
  echo "Contents of version.sh:"
  cat ./version.sh
else
  echo "version.sh is missing."
fi

Length of output: 78


Script:

#!/bin/bash
# Search for `version.sh` in the entire repository to see if it exists elsewhere.
fd version.sh

Length of output: 51

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 04197f4 and f79d582.

Files selected for processing (13)
  • protocol/testing/containertest/Dockerfile (1 hunks)
  • protocol/testing/containertest/containertest.sh (1 hunks)
  • protocol/testing/containertest/testnet.go (3 hunks)
  • protocol/testing/containertest/testnet_test.go (2 hunks)
  • protocol/testing/mainnet/Dockerfile (1 hunks)
  • protocol/testing/mainnet/vars.sh (1 hunks)
  • protocol/testing/testnet/Dockerfile (1 hunks)
  • protocol/testing/testnet/vars.sh (1 hunks)
  • protocol/testing/version/README.md (1 hunks)
  • protocol/testing/version/VERSION_CURRENT (1 hunks)
  • protocol/testing/version/VERSION_PREUPGRADE (1 hunks)
  • protocol/testing/version/version.go (1 hunks)
  • protocol/testing/version/version.sh (1 hunks)
Files skipped from review due to trivial changes (5)
  • protocol/testing/containertest/Dockerfile
  • protocol/testing/version/README.md
  • protocol/testing/version/VERSION_CURRENT
  • protocol/testing/version/VERSION_PREUPGRADE
  • protocol/testing/version/version.go
Additional context used
Shellcheck
protocol/testing/version/version.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 1-1: CURRENT_VERSION appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 6-6: version_to_url appears unused. Verify use (or export if used externally).

(SC2034)

Additional comments not posted (8)
protocol/testing/mainnet/vars.sh (1)

4-4: Verify the impact of sourcing version.sh.

The change from sourcing current_version.sh to version.sh suggests a centralized approach to versioning. Ensure that version.sh provides all the necessary version information previously available in current_version.sh and that no dependent scripts are broken by this change.

protocol/testing/mainnet/Dockerfile (1)

6-6: Verify the inclusion of multiple files from the version directory.

The change from copying a single script to copying the entire version directory suggests a shift to using multiple version-related resources. Ensure that the Docker image correctly utilizes these resources and that no unnecessary files are included.

protocol/testing/testnet/Dockerfile (1)

6-6: Verify the inclusion of multiple files from the version directory.

This change mirrors the mainnet Dockerfile. Ensure the Docker image correctly uses the version-related resources and that no unnecessary files are included.

protocol/testing/version/version.sh (2)

1-1: Verify the usage of CURRENT_VERSION.

The variable CURRENT_VERSION appears unused in this file. Ensure it is used or exported if needed elsewhere.

Verification successful

CURRENT_VERSION is used in the codebase.

The variable CURRENT_VERSION is used in constructing a path for current_version_path. Ensure that its usage aligns with the intended functionality.

  • Usage found in constructing paths:
    • current_version_path="$HOME/cosmovisor/upgrades/$CURRENT_VERSION/bin"
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `CURRENT_VERSION` is used elsewhere in the codebase.

# Test: Search for the usage of `CURRENT_VERSION`. Expect: Occurrences of the variable usage.
rg --type shell 'CURRENT_VERSION'

Length of output: 63


Script:

#!/bin/bash
# Description: Find all shell script files and search for the usage of `CURRENT_VERSION`.

# Find all shell script files by looking for files with a .sh extension
fd --extension sh --exec rg 'CURRENT_VERSION' {}

Length of output: 234

Tools
Shellcheck

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 1-1: CURRENT_VERSION appears unused. Verify use (or export if used externally).

(SC2034)


6-6: Verify the usage of version_to_url.

The associative array version_to_url appears unused in this file. Ensure it is used or exported if needed elsewhere.

Verification successful

version_to_url is used within the script.

The associative array version_to_url is indeed used in the script. It is iterated over to retrieve URLs based on versions.

  • The array is declared and populated.
  • It is used in a loop to access URLs associated with versions.

No further action is needed regarding its usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `version_to_url` is used elsewhere in the codebase.

# Test: Search for the usage of `version_to_url`. Expect: Occurrences of the array usage.
rg --type shell 'version_to_url'

Length of output: 62


Script:

#!/bin/bash
# Description: Correctly search for the usage of `version_to_url` in the codebase.

# Find all shell script files and search for `version_to_url` within them.
fd -e sh -x rg 'version_to_url' {}

Length of output: 419

Tools
Shellcheck

[warning] 6-6: version_to_url appears unused. Verify use (or export if used externally).

(SC2034)

protocol/testing/testnet/vars.sh (1)

4-4: Ensure compatibility with the new version script.

The script now sources version.sh. Verify that all necessary variables and functions are correctly imported and utilized.

protocol/testing/containertest/testnet.go (1)

159-159: Use version.CurrentVersion dynamically.

The use of version.CurrentVersion replaces a hardcoded version, improving maintainability. Ensure that this dynamic approach is consistent throughout the codebase.

protocol/testing/containertest/testnet_test.go (1)

286-286: Verify version.CurrentVersion usage.

The change from UpgradeToVersion to version.CurrentVersion indicates a move to a centralized versioning system. Ensure that version.CurrentVersion is correctly defined and used consistently throughout the codebase.

Verification successful

version.CurrentVersion is correctly defined and used.

The CurrentVersion variable is defined as a string in the version package and is used consistently across the codebase in contexts related to versioning.

  • Defined in protocol/testing/version/version.go.
  • Used in protocol/testing/containertest/testnet_test.go and protocol/testing/containertest/testnet.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `version.CurrentVersion` is correctly defined and used.

# Test: Search for the definition of `CurrentVersion` in the `version` package.
ast-grep --lang go --pattern $'package version\n\nvar CurrentVersion = $_'

Length of output: 536


Script:

#!/bin/bash
# Corrected script to find the definition of `CurrentVersion` in the `version` package.

# Search for the definition of `CurrentVersion` in Go files.
ast-grep --lang go --pattern 'var CurrentVersion = $_'

# Search for the usage of `CurrentVersion` across the codebase.
rg 'CurrentVersion' --type go --context 2

Length of output: 1057

protocol/testing/version/version.sh Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f79d582 and 78a5a8a.

Files selected for processing (1)
  • protocol/testing/version/version.sh (1 hunks)
Additional context used
Shellcheck
protocol/testing/version/version.sh

[warning] 2-2: CURRENT_VERSION appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 7-7: version_to_url appears unused. Verify use (or export if used externally).

(SC2034)

Additional comments not posted (7)
protocol/testing/version/version.sh (7)

1-1: Shebang is correctly specified.

The shebang line #!/bin/bash is correctly added to specify the shell interpreter.


3-3: Assignment of PREUPGRADE_VERSION is correct.

The variable PREUPGRADE_VERSION is correctly assigned and used in the URL mapping.


4-4: Blank line for readability is appropriate.

The blank line improves readability by separating variable declarations from the following section.


5-5: Comment provides useful context.

The comment clearly explains the purpose of the version-to-URL mapping.


2-2: Verify usage of CURRENT_VERSION.

The variable CURRENT_VERSION is assigned but not used in the script. Verify if it should be used or exported for external use.

Verification successful

CURRENT_VERSION is used in other scripts.

The variable CURRENT_VERSION is indeed used in other scripts within the codebase, specifically in protocol/testing/testnet/testnet.sh and protocol/testing/mainnet/mainnet.sh. This indicates that the assignment in protocol/testing/version/version.sh is necessary for these scripts to function correctly. No changes are needed regarding its usage.

  • protocol/testing/testnet/testnet.sh: Uses CURRENT_VERSION to set current_version_path.
  • protocol/testing/mainnet/mainnet.sh: Uses CURRENT_VERSION to set current_version_path.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of `CURRENT_VERSION` in the codebase.

# Test: Search for the usage of `CURRENT_VERSION`. Expect: Occurrences where it is used or exported.
rg --type shell 'CURRENT_VERSION'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify usage of `CURRENT_VERSION` in the codebase.

# Test: Search for the usage of `CURRENT_VERSION`. Expect: Occurrences where it is used or exported.
rg --type sh 'CURRENT_VERSION'

Length of output: 322

Tools
Shellcheck

[warning] 2-2: CURRENT_VERSION appears unused. Verify use (or export if used externally).

(SC2034)


6-6: Verify usage of version_to_url.

The associative array version_to_url is declared but not used in the script. Verify if it should be used or exported for external use.

Verification successful

version_to_url is used in multiple scripts.

The associative array version_to_url is indeed used in other parts of the codebase:

  • It is populated in protocol/testing/version/version.sh.
  • It is accessed in loops in protocol/testing/testnet/testnet.sh and protocol/testing/mainnet/mainnet.sh.

This indicates that the array is utilized properly across different scripts.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of `version_to_url` in the codebase.

# Test: Search for the usage of `version_to_url`. Expect: Occurrences where it is used or exported.
rg --type shell 'version_to_url'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify usage of `version_to_url` in the codebase.

# Test: Search for the usage of `version_to_url`. Expect: Occurrences where it is used or exported.
rg 'version_to_url'

Length of output: 618


7-7: Initialization of version_to_url is correct, but verify its usage.

The initialization logic for version_to_url is correct, using PREUPGRADE_VERSION. However, ensure that this array is used or exported.

Verification successful

version_to_url is correctly initialized and used in the codebase.

The version_to_url array is initialized in version.sh and used in both testnet.sh and mainnet.sh. This confirms that it is utilized as intended.

  • Files and usage:
    • protocol/testing/version/version.sh: Initialization.
    • protocol/testing/testnet/testnet.sh: Usage in a loop.
    • protocol/testing/mainnet/mainnet.sh: Usage in a loop.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify initialization and usage of `version_to_url`.

# Test: Search for the usage of `version_to_url`. Expect: Occurrences where it is used or exported.
rg --type shell 'version_to_url'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify initialization and usage of `version_to_url`.

# Test: Search for the usage of `version_to_url` in all files.
rg 'version_to_url'

Length of output: 618

Tools
Shellcheck

[warning] 7-7: version_to_url appears unused. Verify use (or export if used externally).

(SC2034)

@roy-dydx roy-dydx merged commit 3540618 into main Aug 16, 2024
22 checks passed
@roy-dydx roy-dydx deleted the roy/versionname branch August 16, 2024 17:03
@roy-dydx
Copy link
Contributor Author

!Mergifyio backport release/protocol/v6.x

@roy-dydx
Copy link
Contributor Author

@Mergifyio backport release/protocol/v6.x

Copy link
Contributor

mergify bot commented Aug 16, 2024

backport release/protocol/v6.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Aug 16, 2024
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
(cherry picked from commit 3540618)
roy-dydx added a commit that referenced this pull request Aug 16, 2024
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
(cherry picked from commit 3540618)
roy-dydx added a commit that referenced this pull request Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants