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(scripts): simplify mock.gen.sh to use go generate commands #721

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

qdm12
Copy link
Collaborator

@qdm12 qdm12 commented Dec 27, 2024

Why this should be merged

⚠️ Blocked by ava-labs/avalanchego#3628

💁 Sibling PR for subnet-evm so both repositories would look similar in this aspect

  • Localized mockgen commands in the package where they are needed
  • Generate mocks from your IDE directly
  • Platform independent way of generating mocks
  • Check automatically mocks are kept up to date
  • Check automatically mocks without a source controlled generation command
  • Remove license headers for generated mocks

How this works

  • New mocks_generate_test.go file per package where mocks need to be generated, containing only //go:generate commands for mock generation. Each command is relative to the current package directory
  • Use //go:generate go run go.uber.org/mock/mockgen@v0.4 to avoid requiring to pre-install mockgen
  • no shell script, just go command needed with go generate -run "mockgen" ./...
    • Remove now unneeded scripts/mocks.gen.sh and scripts/mocks.mockgen.txt
  • Add step to CI test job to check:
    • mocks are up to date, by re-generating all of them and running a git diff
    • mocks each have a source controlled //go:generate generation command, by removing all of them before re-generating them
  • Documentation added to .github/CONTRIBUTING.md

How this was tested

Need to be documented?

Yes in .github/CONTRIBUTING.md

Need to update RELEASES.md?

Not really

Copy link
Collaborator

@darioush darioush left a comment

Choose a reason for hiding this comment

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

IMO the license header is not needed, otherwise it's a great simplification.

Copy link
Collaborator

@darioush darioush left a comment

Choose a reason for hiding this comment

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

Let's add the CI check to this PR as well and close 720.

precompile/contract/mocks.go Outdated Show resolved Hide resolved
precompile/contract/mocks.go Outdated Show resolved Hide resolved
@qdm12 qdm12 force-pushed the qdm12/mock-gen-script branch from b763d0c to 9f1d7cb Compare December 30, 2024 16:10
@darioush darioush enabled auto-merge (squash) December 30, 2024 16:26
@qdm12 qdm12 force-pushed the qdm12/mock-gen-script branch 2 times, most recently from 127bcbd to d11e682 Compare December 30, 2024 17:08
@darioush darioush disabled auto-merge December 30, 2024 17:26
@qdm12 qdm12 force-pushed the qdm12/mock-gen-script branch from c12338a to 3d7c598 Compare December 30, 2024 19:03
@qdm12 qdm12 force-pushed the qdm12/mock-gen-script branch from 3d7c598 to 084214f Compare December 30, 2024 19:04
@qdm12 qdm12 force-pushed the qdm12/mock-gen-script branch 2 times, most recently from b75c7f5 to 548c3e5 Compare December 31, 2024 08:46
@qdm12 qdm12 force-pushed the qdm12/mock-gen-script branch from 548c3e5 to e98de07 Compare December 31, 2024 12:50
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