-
Notifications
You must be signed in to change notification settings - Fork 722
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(all): mocks generation improved #3628
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f9864be
to
a4b393a
Compare
qdm12
commented
Dec 31, 2024
a4b393a
to
79c6a89
Compare
This was referenced Dec 31, 2024
79c6a89
to
44eaab4
Compare
qdm12
commented
Jan 2, 2025
44eaab4
to
89a41e4
Compare
89a41e4
to
a35197a
Compare
Once linting passes this lgtm |
- Rely only on `grep`, `xargs` and `git` - Does not rely on `mapfile` which is *sigh* still not there on macos default bash 3.2 - Use `git diff --exit-code` to print diffs - Simplify script
- No need to check twice for outdated mocks - Only the CI should really check for outdated mocks, the developer should only care about re-generating mocks - One less script / more cross platform mocks generation
- requires a `tools.go` blank importing golang.org/x/mod/semver in order to have the `golang.org/x/mod` dependency satisfied for mockgen v0.5
d347ff5
to
ccfdecd
Compare
StephenButtolph
approved these changes
Jan 3, 2025
marun
approved these changes
Jan 3, 2025
Signed-off-by: marun <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Happy new year 🎉 🎆 🆕
Why this should be merged
💁 This PR is created because of similar PRs created on coreth (ava-labs/coreth#721) and subnet-evm (ava-labs/subnet-evm#1413)
ℹ️ Each commit can be separated in a different PR, and the few last commits can be dropped if necessary.
go
onlyHow this works
mocks_generate_test.go
file per package where interface(s) need a corresponding mock(s) generated, containing only//go:generate
commands for mock generation. Each command is relative to the current package directory.//go:generate go run go.uber.org/mock/[email protected]
to avoid requiring to pre-install mockgengo
command needed withgo generate -run "mockgen" ./...
- remove now unneededscripts/mocks.gen.sh
,scripts/mocks.mockgen.txt
andscripts/mocks.mockgen.source.txt
grep
,xargs
andgit
. This is now for CI only since the developer should mostly care about re-generating mocks and not detecting outdated mocks. The developer can still use the CI job inlined commands locally if needed.mocks_test.go
to reduce Go production code namespace pollutionmock files in the same directory are now combined into a single mock file "mocks.go" to reduce the number of mockgen calls to make full re-generation a bit fasterremoved to reduce 4000+ lines of diffs, will do later eventuallyHow this was tested
go generate -run "go.uber.org/mock/mockgen" ./...
Need to documented in RELEASES.md?
Not really