Skip to content

Conversation

@aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Feb 13, 2025

  • Removed the deprecated pre-commit repo pre-commit-golang.
  • Added a new CI step to run golangci-lint using the github action.

Summary by CodeRabbit

  • New Features

    • Introduced an automated linting workflow for Go projects, enhancing code quality checks on pull requests and branch updates.
    • Added new linting capabilities with gofmt and goimports, improving code formatting and import validation.
    • Implemented a skip-dirs option in the linting configuration to exclude specific directories from checks.
  • Chores

    • Updated pre-commit procedures to streamline the setup by removing outdated Go linting steps and using current version controls.
    • Removed repository configuration for Go-related pre-commit hooks, simplifying the configuration structure.

… new CI step to run golangci-lint using the github action
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

This pull request introduces several modifications to the project's Go linting and pre-commit setups. A new GitHub Actions workflow for running golangci-lint has been added, triggered by pull requests and pushes on designated branches. In addition, the pre-commit workflow has been updated by bumping the checkout action version and omitting the installation steps for certain Go tools. The linting configuration file has been enhanced by enabling additional linters, while the pre-commit configuration for Go hooks has been removed.

Changes

File(s) Change Summary
.github/workflows/golangci-lint.yml,
.github/workflows/pre-commit.yml
Added a new GitHub Actions workflow for golangci-lint; updated pre-commit workflow by switching checkout action version to @V3 and removing Go tool installations.
.golangci.yml Updated lint configuration by enabling the gofmt and goimports linters and added skip-dirs option for linting.
.pre-commit-config.yaml Removed the repository configuration for Go pre-commit hooks (including go-fmt, go-imports, and golangci-lint hooks).
eip712_cosmos.go,
ethereum/util/noncecache.go
Updated import statements and added overflow checks for chainID in eip712_cosmos.go; modified nonce handling logic in noncecache.go for error handling.

Sequence Diagram(s)

sequenceDiagram
    participant PR as Pull Request/Push Event
    participant GA as GitHub Actions
    participant CO as Checkout Action
    participant SG as Setup Go
    participant GL as GolangCI-Lint

    PR->>GA: Trigger workflow on push/PR event
    GA->>CO: Checkout repository
    CO-->>GA: Repository checked out
    GA->>SG: Set up Go environment from go.mod
    SG-->>GA: Go environment configured
    GA->>GL: Execute golangci-lint with specified parameters
    GL-->>GA: Return linting results
Loading

Poem

I am a bunny, hopping through code so bright,
New workflows and linters keep my paths light.
I nibble on errors, crunch through lint with glee,
Pre-commit hooks vanish—oh, what a spree!
In fields of Go, my heart sings with delight.
🐇💻 Happy coding in every byte!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbc043b and b192fa9.

📒 Files selected for processing (1)
  • eip712_cosmos.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eip712_cosmos.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint

🪧 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.

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

@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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49b9c7f and 73bbcef.

📒 Files selected for processing (4)
  • .github/workflows/golangci-lint.yml (1 hunks)
  • .github/workflows/pre-commit.yml (1 hunks)
  • .golangci.yml (1 hunks)
  • .pre-commit-config.yaml (0 hunks)
💤 Files with no reviewable changes (1)
  • .pre-commit-config.yaml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pre-commit.yml

11-11: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/golangci-lint.yml

16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


41-41: input "skip-pkg-cache" is not defined in action "golangci/golangci-lint-action@v6". available inputs are "args", "cache-invalidation-interval", "github-token", "install-mode", "only-new-issues", "problem-matchers", "skip-cache", "skip-save-cache", "version", "working-directory"

(action)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint
  • GitHub Check: run-tests
  • GitHub Check: pre-commit
🔇 Additional comments (2)
.golangci.yml (1)

12-13: LGTM! Good addition of formatting linters.

The addition of gofmt and goimports linters will help maintain consistent code formatting and import organization.

.github/workflows/golangci-lint.yml (1)

1-35: LGTM! Well-structured workflow configuration.

The workflow is well-configured with appropriate permissions, triggers, and timeout settings. The verbosity flag will help in debugging any linting issues.

🧰 Tools
🪛 actionlint (1.7.4)

16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

steps:
- uses: actions/setup-python@v4
- uses: actions/checkout@master
- uses: actions/checkout@v3
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the checkout action version.

The actions/checkout@v3 action might be outdated. Consider updating to the latest version.


🌐 Web query:

What is the latest version of actions/checkout GitHub Action?

💡 Result:

The latest stable version of the actions/checkout GitHub Action is v4, as referenced across multiple sources[1][2][5][7]. This version addresses Node.js compatibility issues (deprecating Node.js 16 in favor of Node.js 20)[4][7] and includes reliability improvements for various environments[5].

For most workflows, you can implement it with:

- uses: actions/checkout@v4

Key updates in recent versions:

  • Compatibility with GitHub's updated runner environments
  • Reduced dependency on Node.js tooling[5]
  • Improved security practices for token handling[2]

Always check the official repository for new releases, as GitHub periodically updates actions to maintain compatibility with platform changes[6].

Citations:


Action Required: Update GitHub Checkout Action Version

File: .github/workflows/pre-commit.yml (Line 11)

The workflow currently uses:

      - uses: actions/checkout@v3

Based on the latest information, the current stable version of the checkout action is v4. This update addresses Node.js compatibility (switching to Node.js 20), improves security practices, and enhances overall reliability. Please update the workflow step to:

      - uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

11-11: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
skip-pkg-cache: true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove unsupported cache parameter.

The skip-pkg-cache parameter is not supported by the golangci/golangci-lint-action@v6 action.

Remove this line as it's not a valid input parameter. If you need to skip caching, use the supported skip-cache: true parameter instead.

-          skip-pkg-cache: true
📝 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
skip-pkg-cache: true
🧰 Tools
🪛 actionlint (1.7.4)

41-41: input "skip-pkg-cache" is not defined in action "golangci/golangci-lint-action@v6". available inputs are "args", "cache-invalidation-interval", "github-token", "install-mode", "only-new-issues", "problem-matchers", "skip-cache", "skip-save-cache", "version", "working-directory"

(action)

Copy link

@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

🧹 Nitpick comments (1)
.github/workflows/golangci-lint.yml (1)

21-44: Consider enabling caching for better performance.

Currently, all caching is disabled with skip-cache: true. Enabling caching can significantly improve workflow execution time by reusing previous results.

Consider applying this diff to enable caching:

          # Optional: if set to true then the all caching functionality will be complete disabled,
          #           takes precedence over all other caching options.
          # skip-cache: true

          # Optional: if set to true then the action don't cache or restore ~/go/pkg.
-          skip-cache: true
+          # skip-cache: true

          # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
          # skip-build-cache: true
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73bbcef and e02f973.

📒 Files selected for processing (2)
  • .github/workflows/golangci-lint.yml (1 hunks)
  • .golangci.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .golangci.yml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/golangci-lint.yml

16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint
🔇 Additional comments (2)
.github/workflows/golangci-lint.yml (2)

1-9: LGTM! Well-configured workflow triggers and permissions.

The workflow is properly configured to run on pull requests and specific branch pushes, with appropriate minimal permissions.


11-14: LGTM! Appropriate job configuration.

The job setup uses standard configuration with latest Ubuntu runner.

Comment on lines +16 to +20
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update checkout action to latest version.

The actions/checkout action should be updated to v4 for better compatibility and security.

Apply this diff:

-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
📝 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
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
🧰 Tools
🪛 actionlint (1.7.4)

16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Copy link

@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

🧹 Nitpick comments (2)
ethereum/util/noncecache.go (1)

131-136: Consider logging overflow events.

The overflow handling is good, but consider logging when overflow occurs to help with monitoring and debugging.

 if nonce > uint64(math.MaxInt64) {
+    log.Printf("warning: nonce overflow detected for account %s: %d > MaxInt64", account.String(), nonce)
     n.nonces[account] = math.MaxInt64
 } else {
     n.nonces[account] = int64(nonce)
 }
eip712_cosmos.go (1)

68-72: Consider extracting duplicate chainID validation.

The chainID validation logic is duplicated in both WrapTxToEIP712 and WrapTxToEIP712V2.

Consider extracting it into a helper function:

+func validateAndConvertChainID(chainID uint64) (int64, error) {
+    if chainID > uint64(math.MaxInt64) {
+        return 0, fmt.Errorf("chainID is too large: %d (max supported value is %d)", chainID, math.MaxInt64)
+    }
+    return int64(chainID), nil
+}

Then use it in both functions:

-if chainID > uint64(math.MaxInt64) {
-    err := fmt.Errorf("chainID is too large: %d (max supported value is %d)", chainID, math.MaxInt64)
-    return typeddata.TypedData{}, err
-}
-intChainId := int64(chainID)
+intChainId, err := validateAndConvertChainID(chainID)
+if err != nil {
+    return typeddata.TypedData{}, err
+}

Also applies to: 542-546

🧰 Tools
🪛 GitHub Check: lint

[failure] 69-69:
printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

🪛 GitHub Actions: golangci-lint

[error] 69-69: printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e02f973 and dbc043b.

📒 Files selected for processing (2)
  • eip712_cosmos.go (5 hunks)
  • ethereum/util/noncecache.go (2 hunks)
🧰 Additional context used
🪛 GitHub Check: lint
eip712_cosmos.go

[failure] 69-69:
printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)


[failure] 543-543:
printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

🪛 GitHub Actions: golangci-lint
eip712_cosmos.go

[error] 69-69: printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

Comment on lines 68 to 71
if chainID > uint64(math.MaxInt64) {
err := fmt.Errorf("chainID is too large: %s (max supported value is %s)", chainID, math.MaxInt64)
return typeddata.TypedData{}, err
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix formatting in error messages.

The error messages use incorrect format specifier for uint64 values.

Apply this fix to both error messages:

-err := fmt.Errorf("chainID is too large: %s (max supported value is %s)", chainID, math.MaxInt64)
+err := fmt.Errorf("chainID is too large: %d (max supported value is %d)", chainID, math.MaxInt64)

Also applies to: 542-545

🧰 Tools
🪛 GitHub Check: lint

[failure] 69-69:
printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

🪛 GitHub Actions: golangci-lint

[error] 69-69: printf: fmt.Errorf format %s has arg chainID of wrong type uint64 (govet)

@aarmoa aarmoa merged commit 291a94f into dev Feb 13, 2025
6 checks passed
@aarmoa aarmoa deleted the feat/remove_deprecated_pre_commit_repo branch February 13, 2025 18:43
@coderabbitai coderabbitai bot mentioned this pull request Mar 17, 2025
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