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

[Go] ♻️ Replace quicktype by go-codegen #38

Merged
merged 6 commits into from
Aug 7, 2024
Merged

Conversation

bdeneux
Copy link
Contributor

@bdeneux bdeneux commented Jun 26, 2024

This PR introduces the use of the go-codegen library to generate Go types from the Cosmwasm JSON Schema. This change was necessitated due to compatibility issues encountered with quicktype when generating the JSON Schema (refer to issue #9).

In addition to the Go type generation, this PR also includes the generation of a gRPC client in Go.

⚠️ DISABLE COGNITARIUM
Due to issues with the generation of the axone-cognitarium contract, it has been temporarily disabled. This issue needs to be resolved in the codegen library or by finding an alternative solution. The exclusion is implemented silently in the build script, allowing the CI matrix to continue functioning for other languages without errors. This temporary measure enables the use of other contracts as libraries and potentially allows for manual generation of the cognitarium schema code for Go.

🔗 Related fixes

Summary by CodeRabbit

  • New Features

    • Introduced a new job create_release in the release workflow for streamlined release processes.
    • Added functionality to manage the go-codegen dependency, enhancing code generation for Go.
  • Bug Fixes

    • Removed unnecessary installation steps for the quicktype package across workflows, streamlining the build process.
  • Documentation

    • Updated version handling for the Go code generation tool with the new constant GO_CODEGEN_VERSION.

Copy link

coderabbitai bot commented Jun 26, 2024

Walkthrough

The recent changes streamline the GitHub Actions workflows by removing the installation of the quicktype package, enhancing efficiency. A new create_release job was added to facilitate the release process, dependent on prior successful jobs. Additionally, the code generation process in the Go files was updated to utilize go-codegen instead of quicktype, ensuring that the build pipeline remains effective while minimizing unnecessary dependencies.

Changes

Files Change Summary
.github/workflows/build.yml Removed quicktype installation step, streamlining the build process while preserving core functionality.
.github/workflows/publish.yml Removed quicktype installation, added create_release job conditioned on tags, dependent on lint and build.
.github/workflows/update-schema.yml Removed quicktype installation step, allowing direct transition to the build step, which may alter previous behavior.
magefiles/build.go Added condition to skip generation for "axone-cognitarium"; replaced ensureQuicktype() with ensureGoCodegen() for Go type generation.
magefiles/magefile.go Introduced GO_CODEGEN_VERSION constant set to "0.2.5", updating versioning for Go code generation tools.
magefiles/utils.go Added ensureGoCodegen() function for managing go-codegen dependency; removed ensureQuicktype(), reflecting a shift in focus for dependencies.

Sequence Diagram(s)

sequenceDiagram
    participant A as Developer
    participant B as GitHub Actions
    participant C as Code Generation Tool

    A->>B: Push changes
    B->>B: Run lint job
    B->>B: Run build job
    B->>C: Generate code using go-codegen
    C-->>B: Code generation successful
    B->>B: Create release if tagged
Loading

🐰 In a world of code so bright,
Changes hopped in, pure delight!
Quicktype's gone, no need to fret,
Go-codegen’s here—our new best bet!
With every build, we leap and cheer,
A streamlined path, let's persevere! 🐇✨


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.

@bdeneux bdeneux changed the title ♻️ Replace quciktype by go-codegen ♻️ Replace quicktype by go-codegen Jun 26, 2024
@bdeneux bdeneux changed the title ♻️ Replace quicktype by go-codegen [Go] ♻️ Replace quicktype by go-codegen Jun 26, 2024
@bdeneux bdeneux force-pushed the refactor/go-codegen branch from 1d4165a to 5a792ee Compare August 5, 2024 13:06
@bdeneux bdeneux force-pushed the refactor/go-codegen branch from b2842ab to a1f86c8 Compare August 5, 2024 13:32
@bdeneux bdeneux force-pushed the refactor/go-codegen branch from da93745 to 468e1a8 Compare August 7, 2024 06:01
@bdeneux bdeneux force-pushed the refactor/go-codegen branch from fd896eb to bb6767e Compare August 7, 2024 12:36
@bdeneux bdeneux marked this pull request as ready for review August 7, 2024 12:37
@bdeneux bdeneux changed the title [Go] ♻️ Replace quicktype by go-codegen [Go] ♻️ Replace quicktype by go-codegen @coderabbitai Aug 7, 2024
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ebb752a and bb6767e.

Files selected for processing (6)
  • .github/workflows/build.yml (1 hunks)
  • .github/workflows/publish.yml (1 hunks)
  • .github/workflows/update-schema.yml (1 hunks)
  • magefiles/build.go (1 hunks)
  • magefiles/magefile.go (1 hunks)
  • magefiles/utils.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • .github/workflows/build.yml
  • .github/workflows/update-schema.yml
Additional comments not posted (6)
magefiles/magefile.go (1)

9-9: LGTM!

The addition of GO_CODEGEN_VERSION is correctly defined and follows the existing pattern.

.github/workflows/publish.yml (1)

75-81: New release job integration looks good!

The create_release job is correctly defined with dependencies on lint and build. Ensure that the condition startsWith(github.ref, 'refs/tags/') is appropriate for your release process.

magefiles/build.go (4)

51-54: Conditional check for axone-cognitarium schema looks good!

The conditional statement correctly skips the generation process for the axone-cognitarium schema, ensuring the function returns early.


65-69: Go type generation command updated correctly!

The command for generating Go types using go-codegen is correctly defined and replaces the previous quicktype command.


74-82: Go client generation command added correctly!

The new section for generating a Go client using go-codegen is correctly defined and includes appropriate error handling.


58-58: Ensure ensureGoCodegen is defined.

The call to ensureGoCodegen() is correct, but verify that this function is defined and correctly replaces ensureQuicktype().

Verification successful

Verification successful: ensureGoCodegen is defined and ensureQuicktype has been removed.

  • The function ensureGoCodegen is defined in magefiles/utils.go.
  • No definition or usage of ensureQuicktype was found in the codebase, indicating it has been replaced.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition of `ensureGoCodegen`.

# Test: Search for the function definition. Expect: The function is defined.
rg --type go 'func ensureGoCodegen'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify the definition and usage of `ensureQuicktype`.

# Test 1: Search for the function definition of `ensureQuicktype`.
rg --type go 'func ensureQuicktype'

# Test 2: Search for any usage of `ensureQuicktype` in the codebase.
rg --type go 'ensureQuicktype'

Length of output: 68

magefiles/utils.go Show resolved Hide resolved
@bdeneux bdeneux changed the title [Go] ♻️ Replace quicktype by go-codegen @coderabbitai [Go] ♻️ Replace quicktype by go-codegen Aug 7, 2024
@bdeneux bdeneux requested review from ccamel and amimart August 7, 2024 12:47
@bdeneux bdeneux self-assigned this Aug 7, 2024
Copy link
Member

@amimart amimart left a comment

Choose a reason for hiding this comment

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

Excellent thanks!

Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

Great! Thx 😌

@bdeneux bdeneux merged commit 0be755e into main Aug 7, 2024
16 checks passed
@bdeneux bdeneux deleted the refactor/go-codegen branch August 7, 2024 14:00
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