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: upgrade to go 1.22 #142

Merged
merged 2 commits into from
Oct 16, 2024
Merged

chore: upgrade to go 1.22 #142

merged 2 commits into from
Oct 16, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Oct 15, 2024

#141 will require an upgrade to go 1.22. Let's do it in a separate PR to ensure it's working regardless of go-ethereum version.

node is already on 1.22

golangci-lint failures are unrelated

Summary by CodeRabbit

  • New Features

    • Introduced a new job, upload-cache, in the testing workflow to enhance build efficiency.
  • Improvements

    • Updated the Go version across various workflows and configuration files to version 1.22, ensuring compatibility with the latest features and improvements.
    • Adjusted dependencies in the project to their latest versions for better performance and security.
  • Chores

    • Minor formatting adjustments made in workflow files for consistency.
    • Removed outdated Go 1.18 overlay configuration.

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.86%. Comparing base (044e22b) to head (9c7bcaf).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #142       +/-   ##
===========================================
- Coverage   67.81%   49.86%   -17.96%     
===========================================
  Files         125      171       +46     
  Lines       11451    16818     +5367     
===========================================
+ Hits         7766     8386      +620     
- Misses       3244     7882     +4638     
- Partials      441      550      +109     

see 46 files with indirect coverage changes

@gartnera gartnera requested a review from a team October 15, 2024 22:12
@gartnera gartnera marked this pull request as ready for review October 15, 2024 22:12
Copy link

coderabbitai bot commented Oct 15, 2024

📝 Walkthrough

Walkthrough

The pull request includes updates across multiple workflow files and configuration settings to upgrade the Go programming language version from 1.19 to 1.22. This change affects the build, release, linting, testing, and Docker configurations. Additionally, a new job for caching uploads has been introduced in the test workflow. The go.mod file has also been updated to reflect the new Go version and to adjust dependencies accordingly. Overall, the structural integrity of the workflows and configurations remains unchanged.

Changes

File Change Summary
.github/workflows/build.yml Updated go-version from 1.19 to 1.22.
.github/workflows/goreleaser.yml Updated go-version from 1.19 to 1.22 and added a newline at the end of the file.
.github/workflows/lint.yml Updated go-version from 1.19 to 1.22.
.github/workflows/test.yml Updated go-version from 1.19 to 1.22 in multiple jobs; added upload-cache job.
go.mod Updated Go version from 1.19 to 1.22; adjusted several dependencies and added replacements.
networks/local/ethermintnode/Dockerfile Updated base image from golang:1.19 to golang:1.22.
nix/default.nix Introduced nixpkgsUrl, updated Go package from pkgs.go_1_18 to go_1_22.
nix/go_1_18_overlay.nix Deleted file defining overlay for Go 1.18.

Possibly related PRs

Suggested reviewers

  • fbac
  • skosito

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

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

🧹 Outside diff range and nitpick comments (4)
networks/local/ethermintnode/Dockerfile (2)

21-21: Approve Go version upgrade with optimization suggestion.

The upgrade to Go 1.22 is consistent with the PR objectives. However, consider using a more lightweight base image for the final stage to reduce the image size and potential attack surface.

Consider replacing the base image with a more minimal version:

-FROM golang:1.22 as final
+FROM golang:1.22-alpine as final

This change would require adjusting the subsequent apt-get command to use apk for Alpine Linux:

-RUN apt-get update
+RUN apk update && apk add --no-cache bash

Line range hint 1-35: Suggest improvements to Dockerfile structure and practices.

While the Go version upgrade is the primary focus of this PR, consider the following improvements to enhance the overall Dockerfile:

  1. Update the build stage to use a newer Go version:

    -FROM golang:stretch as build-env
    +FROM golang:1.22 as build-env
  2. Combine RUN commands to reduce layers:

    -RUN apt-get update && \
    -    apt-get upgrade -y && \
    -    apt-get install -y $PACKAGES
    +RUN apt-get update && \
    +    apt-get upgrade -y && \
    +    apt-get install -y $PACKAGES && \
    +    rm -rf /var/lib/apt/lists/*
  3. Use specific versions for all base images to enhance reproducibility.

  4. Consider using COPY --from=build-env /go/src/github.com/zeta-chain/ethermint/build/ethermintd /usr/local/bin/ to place the binary in a standard location.

  5. Add a non-root user for running the application:

    RUN adduser --disabled-password --gecos "" ethermintuser
    USER ethermintuser

These changes will improve the Dockerfile's maintainability, security, and efficiency.

nix/default.nix (1)

4-7: Approve the introduction of nixpkgsUrl and nixpkgs variables with a suggestion.

The introduction of nixpkgsUrl and nixpkgs variables is a commendable approach to ensure version consistency for Go. The explanatory comment provides valuable context for future maintenance.

To further enhance maintainability, consider extracting the commit hash into a separate variable:

nixpkgsCommit = "e544a67ebac014e7932840e277363b0b46bac751";
nixpkgsUrl = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsCommit}.tar.gz";

This modification would facilitate easier updates and improve traceability.

.github/workflows/test.yml (1)

Line range hint 122-140: Review of new upload-cache job.

The addition of the upload-cache job is a positive step towards improving workflow efficiency. However, there are a few points to consider:

  1. The matrix strategy seems unnecessary for a single OS. Consider simplifying by directly specifying runs-on: macos-latest.
  2. The purpose of instantiating the integration test environment in this job is not immediately clear. Consider adding a comment to explain the rationale behind this step.

Suggested modifications:

upload-cache:
  if: github.event_name == 'push'
  needs: ['integration_tests']
  runs-on: macos-latest
  steps:
    - uses: actions/checkout@v3
    - uses: cachix/install-nix-action@v20
    - uses: cachix/cachix-action@v15
      with:
        name: ethermint
        signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
    - name: 'Instantiate integration test env for caching'
      run: nix-store -r "$(nix-instantiate tests/integration_tests/shell.nix)"
      # Add a comment here explaining why this step is necessary for caching

These changes will streamline the job configuration while maintaining its functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 044e22b and 9c7bcaf.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • .github/workflows/build.yml (1 hunks)
  • .github/workflows/goreleaser.yml (2 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/test.yml (3 hunks)
  • go.mod (1 hunks)
  • networks/local/ethermintnode/Dockerfile (1 hunks)
  • nix/default.nix (1 hunks)
  • nix/go_1_18_overlay.nix (0 hunks)
💤 Files with no reviewable changes (1)
  • nix/go_1_18_overlay.nix
🧰 Additional context used
🔇 Additional comments (11)
.github/workflows/goreleaser.yml (2)

18-18: Go version update is appropriate and aligns with project objectives.

The update from Go 1.19 to 1.22 is in line with the pull request's primary objective. This change ensures that the goreleaser job uses the latest Go version, which is crucial for maintaining compatibility and leveraging new language features.


28-28: Minor formatting improvement: newline added at end of file.

The addition of a newline at the end of the file adheres to best practices in file formatting. This change, while subtle, contributes to maintaining a clean and consistent codebase.

.github/workflows/build.yml (1)

22-22: Approval: Go version update implemented correctly.

The modification to update the Go version from 1.19 to 1.22 in the setup-go action is correct and aligns with the pull request objective.

To ensure consistency across the project, please verify that all workflow files have been updated to use Go 1.22. Execute the following script to check for any inconsistencies:

Additionally, it is advisable to review the go.mod file to ensure all dependencies are compatible with Go 1.22. Consider running the following command to update dependencies if necessary:

nix/default.nix (1)

8-8: Approve the declaration of go_1_22 variable.

The declaration of go_1_22 is succinct and appropriate. It correctly utilizes the newly imported nixpkgs to access the Go 1.22 package, ensuring consistency with the intended upgrade.

.github/workflows/lint.yml (1)

19-19: Approve Go version update and suggest verification.

The update to Go 1.22 in the linting workflow is appropriate and aligns with the PR objective. This change ensures consistency between the project's Go version and the linting environment.

To ensure all workflow files are consistently updated, please run the following verification script:

This script will help identify any remaining references to older Go versions in other workflow files, ensuring complete consistency across the CI/CD pipeline.

.github/workflows/test.yml (3)

23-23: Go version update approved.

The modification to use Go version 1.22 is in line with the pull request objectives and ensures consistency across the workflow.


50-50: Go version update approved.

The modification to use Go version 1.22 in the test-importer job maintains consistency with the overall upgrade strategy.


71-71: Go version update approved.

The modification to use Go version 1.22 in the test-rpc job completes the consistent upgrade across all relevant jobs in the workflow.

go.mod (3)

Line range hint 11-51: Verify compatibility of updated dependencies

The updates to key dependencies, particularly cosmos-sdk, cometbft, and grpc, are significant. While these updates are likely necessary for compatibility with Go 1.22, it's crucial to ensure they don't introduce breaking changes.

Please run the following commands to verify dependency compatibility:

#!/bin/bash
# Verify dependencies and check for any conflicts
go mod tidy
go mod verify

Line range hint 246-246: Clarify the necessity of the go-ethereum fork

The addition of a replacement directive for go-ethereum with a ZetaChain-maintained fork is notable. While this may be necessary for specific functionality, it's important to understand the implications.

Please provide information on:

  1. The reasons for using a fork instead of the official repository.
  2. The specific modifications in this fork compared to the original.
  3. The strategy for keeping this fork up-to-date with upstream changes.

Additionally, run the following command to check for any potential conflicts:

#!/bin/bash
# Check for any conflicts with the go-ethereum replacement
go list -m all | grep ethereum

3-3: Verify compatibility with Go 1.22

The upgrade to Go 1.22 is in line with the PR objectives. However, it's crucial to ensure that all code is compatible with this new version.

Please run the following commands to verify compatibility:

nix/default.nix Show resolved Hide resolved
@gartnera gartnera merged commit 8db76d7 into main Oct 16, 2024
28 of 29 checks passed
@gartnera gartnera deleted the upgrade-go122 branch October 16, 2024 14:41
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants