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

Lint generators and commit dirty changes #507

Merged
merged 12 commits into from
Feb 19, 2025
Merged

Conversation

mkysel
Copy link
Collaborator

@mkysel mkysel commented Feb 18, 2025

Summary by CodeRabbit

  • Chores
    • Enhanced continuous integration workflows with new steps for code generation, streamlined caching, and dependency adjustments to boost overall stability and build consistency.
  • Tests
    • Upgraded internal testing mocks and tooling to ensure more reliable verification across components while maintaining existing functionality.

Copy link

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request updates several GitHub Actions workflows and mock files. In the workflows, the version of the nickcharlton/diff-check action is updated and new steps are added to the Go linting workflow, while the Solidity workflow has revised cache key generation and consolidated ABI generation steps. Additionally, multiple mock files have their code generation tool version bumped from v2.51.1 to v2.52.2, and the tools/go.mod file sees a dependency downgrade and removal of some packages.

Changes

Files Change Summary
.github/workflows/lint-go.yml Updated diff-check action version to v1.0.0; added new steps (sqlc, generate, mockery) that run specific Go commands via the diff-check action.
.github/workflows/solidity.yml Revised cache key generation by hashing the contracts directory; refined cache paths; consolidated ABI generation steps into a single abigen step using the diff-check action.
pkg/mocks/**/*.go Updated the code generation tool version from mockery v2.51.1 to v2.52.2 across multiple mock files; no changes to functionality, logic, or method signatures.
tools/go.mod Downgraded github.com/ethereum/go-ethereum from v1.15.2 to v1.14.12; removed dependencies on several github.com/pion/... packages.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as GitHub Actions Runner
    participant Diff as diff-check Action

    Runner->>Runner: Start lint-go Job
    Runner->>Diff: Execute golines step ([email protected])
    Runner->>Diff: Run SQL code generation command (go tool -modfile=tools/go.mod sqlc generate)
    Runner->>Diff: Run code generation command (go generate ./...)
    Runner->>Diff: Run mock generation command (go tool -modfile=tools/go.mod mockery)
Loading
sequenceDiagram
    participant Runner as GitHub Actions Runner
    participant Diff as diff-check Action

    Runner->>Runner: Initialize Solidity job with updated cache keys and paths
    Runner->>Diff: Execute abigen step (contracts/dev/generate)
Loading

Possibly related PRs

Suggested reviewers

  • fbac

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

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ffc98e and b3b7dac.

⛔ Files ignored due to path filters (1)
  • tools/go.sum is excluded by !**/*.sum
📒 Files selected for processing (17)
  • .github/workflows/lint-go.yml (1 hunks)
  • .github/workflows/solidity.yml (1 hunks)
  • contracts/pkg/groupmessages/GroupMessages.go (1 hunks)
  • contracts/pkg/identityupdates/IdentityUpdates.go (1 hunks)
  • contracts/pkg/nodes/Nodes.go (1 hunks)
  • pkg/mocks/authn/mock_JWTVerifier.go (1 hunks)
  • pkg/mocks/blockchain/mock_ChainClient.go (1 hunks)
  • pkg/mocks/blockchain/mock_IBlockchainPublisher.go (1 hunks)
  • pkg/mocks/indexer/mock_ChainReorgHandler.go (1 hunks)
  • pkg/mocks/indexer/mock_IBlockTracker.go (1 hunks)
  • pkg/mocks/metadata_api/mock_MetadataApiClient.go (1 hunks)
  • pkg/mocks/mls_validationv1/mock_ValidationApiClient.go (1 hunks)
  • pkg/mocks/mlsvalidate/mock_MLSValidationService.go (1 hunks)
  • pkg/mocks/registry/mock_NodeRegistry.go (1 hunks)
  • pkg/mocks/registry/mock_NodesContract.go (1 hunks)
  • pkg/mocks/storer/mock_LogStorer.go (1 hunks)
  • tools/go.mod (1 hunks)
✅ Files skipped from review due to trivial changes (13)
  • pkg/mocks/registry/mock_NodesContract.go
  • pkg/mocks/storer/mock_LogStorer.go
  • pkg/mocks/indexer/mock_ChainReorgHandler.go
  • pkg/mocks/indexer/mock_IBlockTracker.go
  • pkg/mocks/registry/mock_NodeRegistry.go
  • pkg/mocks/mlsvalidate/mock_MLSValidationService.go
  • pkg/mocks/metadata_api/mock_MetadataApiClient.go
  • pkg/mocks/authn/mock_JWTVerifier.go
  • pkg/mocks/blockchain/mock_IBlockchainPublisher.go
  • pkg/mocks/mls_validationv1/mock_ValidationApiClient.go
  • contracts/pkg/nodes/Nodes.go
  • pkg/mocks/blockchain/mock_ChainClient.go
  • contracts/pkg/identityupdates/IdentityUpdates.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test (Node)
🔇 Additional comments (5)
.github/workflows/lint-go.yml (3)

35-38: Ensure SQL Code Generation Command Accuracy
The sqlc step uses the diff-check action to run SQL code generation with the command:

go tool -modfile=tools/go.mod sqlc generate

Make sure that this command works correctly with the current toolchain and that the dependency versions (especially related to Ethereum and SQLC) in tools/go.mod are compatible with your project requirements.


39-42: Validate Go Generate Step Integration
The generate step, which runs go generate ./... via the diff-check action, is properly set up to trigger code generation. Verify that its execution does not introduce unexpected dirty changes in the repository (or that such changes are managed as intended by the workflow).


43-46: Review Mockery Generation Command
The mockery step employs the diff-check action to execute:

go tool -modfile=tools/go.mod mockery

Confirm that this command remains effective with the updated dependency configuration in tools/go.mod and that the regenerated mocks correctly reflect the current interfaces.

tools/go.mod (1)

132-132: Confirm Ethereum Dependency Downgrade
The dependency on github.com/ethereum/go-ethereum has been downgraded to version v1.14.12. Please ensure that this downgrade does not introduce regressions compared to the previously used version (v1.15.2) and that it is fully compatible with the project’s requirements.

contracts/pkg/groupmessages/GroupMessages.go (1)

1-3:

❓ Verification inconclusive

Verify that bytecode changes are generated through proper tooling.

Since this is a generated file (as indicated by the header comment), ensure that the bytecode changes in the Bin field are generated through the proper contract compilation and binding generation process, not manually edited.

Run the following script to verify the bytecode changes:

Also applies to: 34-35


🏁 Script executed:

#!/bin/bash
# Description: Verify that the bytecode changes are generated through proper tooling.

# Test: Check if the file is generated using abigen by looking for its signature patterns
rg -A 5 'Code generated - DO NOT EDIT' contracts/pkg/groupmessages/GroupMessages.go

# Test: Check if there are any manual edits to the file by looking at git history
git log -p contracts/pkg/groupmessages/GroupMessages.go | rg -v 'Code generated'

Length of output: 170


Attention: File Not Found – Verify Generated File Integration

The expected file ("contracts/pkg/groupmessages/GroupMessages.go") could not be located in the repository. Please verify the following manually:

  • Confirm that the generated binding file is produced using the proper tooling (e.g., via abigen) and that the generation process is intact.
  • Check if the file has been renamed or relocated in the repository.
  • Ensure that the bytecode changes in the Bin field come from an automatic recompilation and binding generation process rather than from manual alterations.

Once the file’s presence and correct generation are validated, update this review accordingly.

Comment on lines 167 to 170
- name: abigen
uses: nickcharlton/diff-check@main
with:
command: contracts/dev/generate
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Pin the action version for better reproducibility.

Using @main for the diff-check action version can lead to reproducibility issues as the action could change without notice. Consider pinning to a specific version.

Apply this diff to pin the action version:

-        uses: nickcharlton/diff-check@main
+        uses: nickcharlton/diff-check@v1

Additionally, consider adding error handling and output verification for the generation process to ensure it completes successfully.

📝 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
- name: abigen
uses: nickcharlton/diff-check@main
with:
command: contracts/dev/generate
- name: abigen
uses: nickcharlton/diff-check@v1
with:
command: contracts/dev/generate

@mkysel mkysel force-pushed the mkysel/lint-generators branch 2 times, most recently from 4d80f00 to 886ea59 Compare February 18, 2025 19:35
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: 0

♻️ Duplicate comments (1)
.github/workflows/solidity.yml (1)

167-170: 🛠️ Refactor suggestion

Pin the diff-check Action Version

The abigen step uses nickcharlton/diff-check@main. For better reproducibility and to adhere to our previous recommendations, please pin the version (for example, to v1):

-        uses: nickcharlton/diff-check@main
+        uses: nickcharlton/diff-check@v1
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 170-170: no new line character at the end of file

(new-line-at-end-of-file)

🧹 Nitpick comments (1)
.github/workflows/solidity.yml (1)

170-170: Ensure a Newline at the End of File

The static analysis tool flagged that there is no newline character at the end of this file. Please add a newline character after line 170 to comply with YAML linting guidelines.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 170-170: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b387655 and c6b1af1.

📒 Files selected for processing (2)
  • .github/workflows/solidity.yml (2 hunks)
  • contracts/dev/generate (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • contracts/dev/generate
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/solidity.yml

[error] 170-170: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: abis
  • GitHub Check: Push Docker Images to GitHub Packages (xmtpd)
  • GitHub Check: Test (Node)
  • GitHub Check: Lint-Go
  • GitHub Check: Build pre-baked anvil-xmtpd
🔇 Additional comments (1)
.github/workflows/solidity.yml (1)

46-46: Cache Key Generation – Verify Directory Hashing

The updated command now hashes the entire contracts directory using hashFiles('contracts'). Please confirm that this change intentionally covers the full directory instead of using a more specific glob pattern (e.g., "contracts/**/*.sol") if you only want to capture Solidity files.

@mkysel mkysel force-pushed the mkysel/lint-generators branch from c6b1af1 to 9655f5c Compare February 19, 2025 15:51
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: 0

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

46-46: File Ending Newline
YAMLlint reported that there is no newline character at the end of the file. Adding a newline at the end of the file improves compatibility with some tools and adheres to best practices.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 46-46: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/solidity.yml (3)

46-46: Review Cache Key Generation Pattern
The cache key is set using hashFiles('contracts'), which might not capture changes in nested subdirectories or individual files if the intention is to hash all contents. Consider using a glob pattern (for example, hashFiles('contracts/**/*')) to ensure that any change inside the contracts folder invalidates the cache appropriately.


167-170: Consolidated Abigen Step & Error Handling
This new step uses nickcharlton/[email protected] for ABI generation, which is excellent for reproducibility. However, adding error handling or output verification after executing contracts/dev/generate could improve robustness. Explicitly catching or logging failures would help diagnose issues during ABI generation.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 170-170: no new line character at the end of file

(new-line-at-end-of-file)


170-170: Add Newline at End of File
YAMLlint indicates that there is no newline at the end of the file. Adding a newline will satisfy the linter and adhere to best practices for file formatting.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 170-170: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6b1af1 and 9655f5c.

⛔ Files ignored due to path filters (1)
  • tools/go.sum is excluded by !**/*.sum
📒 Files selected for processing (15)
  • .github/workflows/lint-go.yml (1 hunks)
  • .github/workflows/solidity.yml (2 hunks)
  • contracts/dev/generate (3 hunks)
  • pkg/mocks/authn/mock_JWTVerifier.go (1 hunks)
  • pkg/mocks/blockchain/mock_ChainClient.go (1 hunks)
  • pkg/mocks/blockchain/mock_IBlockchainPublisher.go (1 hunks)
  • pkg/mocks/indexer/mock_ChainReorgHandler.go (1 hunks)
  • pkg/mocks/indexer/mock_IBlockTracker.go (1 hunks)
  • pkg/mocks/metadata_api/mock_MetadataApiClient.go (1 hunks)
  • pkg/mocks/mls_validationv1/mock_ValidationApiClient.go (1 hunks)
  • pkg/mocks/mlsvalidate/mock_MLSValidationService.go (1 hunks)
  • pkg/mocks/registry/mock_NodeRegistry.go (1 hunks)
  • pkg/mocks/registry/mock_NodesContract.go (1 hunks)
  • pkg/mocks/storer/mock_LogStorer.go (1 hunks)
  • tools/go.mod (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
  • pkg/mocks/registry/mock_NodesContract.go
  • pkg/mocks/blockchain/mock_IBlockchainPublisher.go
  • pkg/mocks/indexer/mock_ChainReorgHandler.go
  • pkg/mocks/storer/mock_LogStorer.go
  • pkg/mocks/mls_validationv1/mock_ValidationApiClient.go
  • pkg/mocks/authn/mock_JWTVerifier.go
  • pkg/mocks/mlsvalidate/mock_MLSValidationService.go
  • contracts/dev/generate
  • pkg/mocks/indexer/mock_IBlockTracker.go
  • pkg/mocks/metadata_api/mock_MetadataApiClient.go
  • tools/go.mod
  • pkg/mocks/registry/mock_NodeRegistry.go
  • pkg/mocks/blockchain/mock_ChainClient.go
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/solidity.yml

[error] 170-170: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/lint-go.yml

[error] 46-46: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Lint-Go
  • GitHub Check: Test (Node)
  • GitHub Check: Build pre-baked anvil-xmtpd
🔇 Additional comments (4)
.github/workflows/lint-go.yml (4)

31-35: Golines Step Update Verification
The "golines" step now uses nickcharlton/[email protected], which replaces the previous reference (presumably "main"). Please confirm that this specific version meets your stability and functionality requirements in your environment.


35-38: SQL Code Generation Step Addition
The new "sqlc" step leverages go tool -modfile=tools/go.mod sqlc generate with the diff-check action. This addition helps ensure that SQL code is generated as part of the lint workflow. Verify that the command produces the desired output and integrates well with your CI process.


39-42: Go Generate Step Addition
The "generate" step now invokes go generate ./... via the diff-check action. This helps catch generated code that might become stale. Please ensure that this change covers all your required modules and that any side effects (such as file modifications) are properly handled by your workflow.


43-46: Mockery Step Addition
A new "mockery" step has been added to run go tool -modfile=tools/go.mod mockery, aligning with the updated mock generation tool (v2.52.2). Double-check that this command correctly picks up the new version and regenerates mocks as expected.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 46-46: no new line character at the end of file

(new-line-at-end-of-file)

@mkysel mkysel marked this pull request as ready for review February 19, 2025 16:11
@mkysel mkysel requested a review from a team as a code owner February 19, 2025 16:11
@mkysel mkysel requested a review from fbac February 19, 2025 16:35
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: 0

🔭 Outside diff range comments (2)
.github/workflows/solidity.yml (2)

104-110: 🛠️ Refactor suggestion

Inconsistent Cache Restoration in Lint Job

The Lint job still restores cache with path: contracts, which is inconsistent with the updated approach used elsewhere. Consider updating this to match the refined subdirectories for better granularity and consistency.

Proposed diff:

-          path: contracts
+          path: |
+            contracts/build
+            contracts/cache
+            contracts/dependencies
+            contracts/out

128-134: 🛠️ Refactor suggestion

Inconsistent Cache Restoration in Slither Job

Similar to the Lint job, the Slither job uses path: contracts when restoring the cache. For consistency, updating it to use the specific subdirectories (as done in other jobs) is recommended.

Proposed diff:

-          path: contracts
+          path: |
+            contracts/build
+            contracts/cache
+            contracts/dependencies
+            contracts/out
🧹 Nitpick comments (1)
.github/workflows/solidity.yml (1)

184-184: Minor Formatting: Add Trailing Newline

A newline at the end of the file is missing. Adding one will prevent potential issues with certain linters or tools.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 184-184: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9655f5c and 11df252.

📒 Files selected for processing (1)
  • .github/workflows/solidity.yml (6 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/solidity.yml

[error] 184-184: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build pre-baked anvil-xmtpd
  • GitHub Check: Lint-Go
  • GitHub Check: Test (Node)
🔇 Additional comments (4)
.github/workflows/solidity.yml (4)

46-46: Cache Key Generation: Validate Hashing Scope

Using hashFiles('contracts/**/*') ensures that all files under the contracts directory are included when generating the cache key. Please verify that this glob pattern meets your caching requirements compared to the previous pattern (which targeted Solidity files only).


57-61: Cache Paths: Enhanced Precision

The cache paths are now scoped to specific subdirectories (contracts/build, contracts/cache, contracts/dependencies, and contracts/out), which should help improve the caching efficiency by excluding unnecessary files. Ensure that these directories cover all the necessary build artifacts.


77-88: Test Job Cache Restore: Correct Directory Specified

The Test job now restores the cache using the refined subdirectories instead of the entire contracts folder. This aligns with the changes in the Init job and should result in more efficient caching.


181-184: Abigen Step: Properly Pinning Diff-Check Action

The new abigen step correctly pins the nickcharlton/diff-check action to v1.0.0, ensuring reproducibility in ABI generation. Double-check that the command contracts/dev/generate is valid and that any potential errors are handled appropriately.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 184-184: no new line character at the end of file

(new-line-at-end-of-file)

@mkysel mkysel merged commit 4971f53 into main Feb 19, 2025
13 checks passed
@mkysel mkysel deleted the mkysel/lint-generators branch February 19, 2025 17:18
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