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

chore: prepare depinject 1.0.0 #21001

Merged
merged 4 commits into from
Jul 19, 2024
Merged

chore: prepare depinject 1.0.0 #21001

merged 4 commits into from
Jul 19, 2024

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Jul 19, 2024

Description

Prepare depinject 1.0.0 release.
Tested on v0.50 (#21000) simapp and chain-minimal (app.yaml)
Modified counter to use gogo instead of pulsar module proto

Updated WrapAny to support a gogo module so we don't have to regenerate our module.pulsar.go as module.pb.go.
(we could do it however if we wanted to, just need to change things in protocgen.sh then)


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced support for defining appconfig module configuration types, enhancing flexibility for users.
    • Added automatic command-line interface (CLI) configuration for the counter module, improving user interaction.
  • Bug Fixes

    • Enhanced the WrapAny function to handle a broader range of input types and improve message processing robustness.
  • Documentation

    • Updated changelog to reflect versioning and improved formatting for clarity.

@julienrbrt julienrbrt requested a review from a team as a code owner July 19, 2024 16:16
Copy link
Contributor

coderabbitai bot commented Jul 19, 2024

Walkthrough

Walkthrough

The recent changes involve a significant restructuring and enhancement of the Cosmos SDK's dependency injection and configuration capabilities. The transition to version 1.0.0 reflects improved module organization, expanded support for various proto message types, and the introduction of features for automatic command-line interface (CLI) generation. These updates enhance flexibility, usability, and integration, particularly for the counter module, while clarifying the codebase’s structure.

Changes

File Change Summary
depinject/CHANGELOG.md Updated to version 1.0.0; changed formatting to asterisk notation; added support for appconfig module types; relocated core/appconfig to depinject/appconfig.
depinject/appconfig/config.go Enhanced WrapAny function to accept both protoreflect.ProtoMessage and gogoproto.Message, improving type handling.
simapp/app_config.go Modified import statements and added counter module to configuration for improved dependency injection testing.
testutil/x/counter/autocli.go Introduced autocli.go to implement autocli.HasAutoCLIConfig, allowing for automatic CLI generation.
testutil/x/counter/depinject.go Replaced modulev1.Module with types.Module in dependency injection setup, enhancing maintainability.
testutil/x/counter/proto/cosmos/counter/module/v1/module.proto Added option go_package to define the Go package for generated code, improving integration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant CounterModule
    participant AppConfig

    User->>CLI: Input command
    CLI->>CounterModule: Parse command options
    CounterModule->>AppConfig: Retrieve configurations
    AppConfig->>CounterModule: Return configurations
    CounterModule->>User: Output result
Loading

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 (3)
testutil/x/counter/proto/cosmos/counter/module/v1/module.proto (1)

7-7: Add a brief comment explaining the purpose of the go_package option.

The go_package option specifies the Go package path for the generated code. Adding a comment will help maintainers understand its purpose.

+ // Specifies the Go package path for the generated code.
option go_package = "github.com/cosmos/cosmos-sdk/testutil/x/counter/types";
testutil/x/counter/autocli.go (1)

1-6: Conform to the Uber Go Style Guide for imports.

Group standard library, third-party, and local imports separately.

import (
	autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
	counterv1 "cosmossdk.io/api/cosmos/counter/v1"
)
+import (
+	"fmt"
+	"strings"
+)
simapp/app_config.go (1)

72-73: Conform to the Uber Go Style Guide for imports.

Group standard library, third-party, and local imports separately.

import (
	"time"

	"google.golang.org/protobuf/types/known/durationpb"

	"github.com/cosmos/cosmos-sdk/runtime"
	_ "github.com/cosmos/cosmos-sdk/testutil/x/counter" // import for side-effects
	countertypes "github.com/cosmos/cosmos-sdk/testutil/x/counter/types"
	genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c2a1268 and 2d6491d.

Files ignored due to path filters (1)
  • testutil/x/counter/types/module.pb.go is excluded by !**/*.pb.go
Files selected for processing (6)
  • depinject/CHANGELOG.md (1 hunks)
  • depinject/appconfig/config.go (1 hunks)
  • simapp/app_config.go (2 hunks)
  • testutil/x/counter/autocli.go (1 hunks)
  • testutil/x/counter/depinject.go (2 hunks)
  • testutil/x/counter/proto/cosmos/counter/module/v1/module.proto (1 hunks)
Additional context used
Path-based instructions (5)
testutil/x/counter/depinject.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

testutil/x/counter/autocli.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/appconfig/config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/app_config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (7)
testutil/x/counter/depinject.go (3)

9-9: LGTM! The import of types is correct.

The import statement for types is correct and aligns with the changes made.


19-21: LGTM! The module registration change is correct.

The module registration now uses &types.Module{}, which aligns with the updated structure.


27-27: LGTM! The ModuleInputs struct change is correct.

The Config field in ModuleInputs now uses *types.Module, which aligns with the updated structure.

depinject/CHANGELOG.md (2)

25-25: Ensure the release date is added for version 1.0.0.

The release date for version 1.0.0 is missing. Ensure it is added before merging.


27-28: LGTM! The changelog entries are clear and correct.

The changelog entries for version 1.0.0 are clear and correctly formatted.

testutil/x/counter/autocli.go (1)

8-34: LGTM!

The function AutoCLIOptions correctly implements the autocli.HasAutoCLIConfig interface and returns the expected configurations.

simapp/app_config.go (1)

284-288: LGTM!

The new module entry for countertypes.ModuleName and appconfig.WrapAny(&countertypes.Module{}) is correctly added for testing the depinject module registration.

depinject/appconfig/config.go Outdated Show resolved Hide resolved
Copy link
Member

@kocubinski kocubinski left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines 65 to 73
pbz, err := gogoproto.Marshal(cfg)
if err != nil {
panic(err)
}

return &anypb.Any{
TypeUrl: "/" + gogoproto.MessageName(cfg),
Value: pbz,
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure the code can be shortened to this snippet because gogoproto 1.5 supports protoreflect too

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated 👍🏾

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.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2d6491d and 702115b.

Files selected for processing (3)
  • depinject/appconfig/config.go (2 hunks)
  • simapp/app_config.go (2 hunks)
  • simapp/upgrades.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • simapp/upgrades.go
Files skipped from review as they are similar to previous changes (2)
  • depinject/appconfig/config.go
  • simapp/app_config.go

@julienrbrt julienrbrt added this pull request to the merge queue Jul 19, 2024
@julienrbrt
Copy link
Member Author

julienrbrt commented Jul 19, 2024

I'll tag 1.0.0 once everything here is passing: #21000 as app works but CI isn't happy there.

Merged via the queue into main with commit 748352e Jul 19, 2024
74 checks passed
@julienrbrt julienrbrt deleted the julien/depinject-100 branch July 19, 2024 20:20
alpe added a commit that referenced this pull request Jul 23, 2024
* main: (48 commits)
  build(deps): add missing replaces and remove unnecessary ones (#21033)
  build(deps): Bump bufbuild/buf-setup-action from 1.34.0 to 1.35.0 (#21028)
  chore: fix some comments for struct field (#21027)
  chore(x): replace `fmt.Errorf` without parameters with `errors.New` (#21032)
  chore: fix errors reported by running `make lint` (#21015)
  ci: skip spelling check in go.mod/go.sum (#21021)
  chore(all)!: use gogoproto/any instead of codec/types/any (#21013)
  chore(server/v2/cometbft): ensure consistent dash-case in app.toml (#21018)
  docs(server): wrong function comments (#21017)
  refactor(storev2): update snapshot manager and migration manager tests (#20441)
  feat(server/v2/cometbft): config (#20989)
  refactor: set `help` as default target of Makefile (#21011)
  fix(simapp): duplicated import (#21014)
  chore(docs): fix functions and struct comments (#21010)
  fix(simapp/v2): panic with testnet init-files command (#21012)
  fix: make help won't work (#21005)
  fix: NewIntegrationApp does not write default genesis to state (#21006)
  chore(x/staking,x/upgrade): replace `fmt.Errorf` without parameters with `errors.New` (#21004)
  chore: prepare depinject 1.0.0 (#21001)
  docs: Fix typos in RFC Creation Process (#20998)
  ...
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.

3 participants