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

Move to upstream mockery #4937

Merged
merged 13 commits into from
May 24, 2024
Merged

Move to upstream mockery #4937

merged 13 commits into from
May 24, 2024

Conversation

eapolinario
Copy link
Contributor

@eapolinario eapolinario commented Feb 23, 2024

Tracking issue

#4934

Why are the changes needed?

Harder to contribute code for newer contributors and the codebase don't get upstream changes

What changes were proposed in this pull request?

In order to facilitate the migration to vektra/mockery, this PR sets up an environment where both versions of mockery are available. The current use of mockery is kept, and we can start moving to upstream mockery mock by mock, by switching to using mockery-v2 binary in the //go:generate directive, e.g. //go:generate mockery-v2 ... (notice that flags are passed using --, not -).

I added one example in flyteadmin. Notice how the call to generate the mock is slightly different SignalInterface:

- //go:generate mockery -name=SignalInterface -output=../mocks -case=underscore
+ //go:generate mockery-v2 --name=SignalInterface --output=../mocks --case=underscore --with-expecter

Notice the need to add --with-expecter in order to generate expecter structs.

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request housekeeping Issues that help maintain flyte and keep it tech-debt free labels Feb 23, 2024
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.08%. Comparing base (0583f77) to head (8b12e0a).
Report is 130 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4937      +/-   ##
==========================================
- Coverage   61.10%   61.08%   -0.02%     
==========================================
  Files         793      793              
  Lines       51156    51156              
==========================================
- Hits        31257    31251       -6     
- Misses      17027    17033       +6     
  Partials     2872     2872              
Flag Coverage Δ
unittests-datacatalog 69.31% <ø> (ø)
unittests-flyteadmin 58.86% <ø> (-0.05%) ⬇️
unittests-flytecopilot 17.79% <ø> (ø)
unittests-flytectl 68.31% <ø> (ø)
unittests-flyteidl 79.30% <ø> (ø)
unittests-flyteplugins 61.94% <ø> (ø)
unittests-flytepropeller 57.32% <ø> (ø)
unittests-flytestdlib 65.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Eduardo Apolinario <[email protected]>
@eapolinario
Copy link
Contributor Author

Once #5134 is merged I'm going to update this PR.

@eapolinario eapolinario changed the title wip - Move to upstream mockery Move to upstream mockery May 23, 2024
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
This reverts commit 9f7d745.

Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
@eapolinario
Copy link
Contributor Author

codespell CI check is being fixed in #5418.

# If tool is named vektra/mockery/v2, we need to rename the binary to mockery-v2
if [[ $tool == "github.com/vektra/mockery/[email protected]" ]]; then
echo "Renaming mockery to mockery-v2"
mv $(go env GOPATH)/bin/mockery $(go env GOPATH)/bin/mockery-v2
Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on the timeline to manage the migration, do you know of a linter that would let us block new usage of go:generate mockery? I was looking at forbidigo, but I don't see a file exclusion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, although in the case of forbidigo it looks like it can't handle comments. In any case, I'm going to experiment with this in a separate PR. Maybe there's a way to restrict the linter to files in a PR (this might involve running a command via a run block in a gh action to list the go files in a PR, something like git diff --name-only master | grep '.go$' and pass that list to this tool).

@eapolinario eapolinario merged commit 470621e into master May 24, 2024
48 of 50 checks passed
@eapolinario eapolinario deleted the move-to-official-mockery branch May 24, 2024 07:25
robert-ulbrich-mercedes-benz pushed a commit to robert-ulbrich-mercedes-benz/flyte that referenced this pull request Jul 2, 2024
* Switch to vektra/mockery

Signed-off-by: Eduardo Apolinario <[email protected]>

* Add support for both versions of mockery to coexist

Signed-off-by: Eduardo Apolinario <[email protected]>

* Fix a few typos

Signed-off-by: Eduardo Apolinario <[email protected]>

* Rename binaries to reflect their sources

Signed-off-by: Eduardo Apolinario <[email protected]>

* Add missing pflags binary

Signed-off-by: Eduardo Apolinario <[email protected]>

* Install upstream mockery in boilerplate

Signed-off-by: Eduardo Apolinario <[email protected]>

* Add example in flyteadmin

Signed-off-by: Eduardo Apolinario <[email protected]>

* Rename to mockery-v2

Signed-off-by: Eduardo Apolinario <[email protected]>

* Move WorkflowExecutor to mockery-v2

Signed-off-by: Eduardo Apolinario <[email protected]>

* Revert "Move WorkflowExecutor to mockery-v2"

This reverts commit 9f7d745.

Signed-off-by: Eduardo Apolinario <[email protected]>

* Revert changes to executor

Signed-off-by: Eduardo Apolinario <[email protected]>

* Modify SignalInterface to use mockery-v2

Signed-off-by: Eduardo Apolinario <[email protected]>

---------

Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request housekeeping Issues that help maintain flyte and keep it tech-debt free size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants