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

fix(cmd/gno/clean): allow to run gno clean -modcache from anywhere + rename and use gnomod.ModCachePath #3083

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

Conversation

n0izn0iz
Copy link
Contributor

@n0izn0iz n0izn0iz commented Nov 7, 2024

  • In gno clean, run the -modcache case before checking for presence of a gno.mod to allow to run gno clean -modcache from anywhere (like go)
  • Refactor gno clean -modcache to use the gnomod.GetGnoModPath helper to get the modcache path
  • Rename gnomod.GetGnoModPath -> gnomod.ModCachePath
  • Improve gno cmd tests by using a tmp GNOHOME instead of the system one
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Nov 7, 2024
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.35%. Comparing base (7ef606c) to head (e056c68).

Files with missing lines Patch % Lines
gnovm/cmd/gno/clean.go 70.00% 2 Missing and 1 partial ⚠️
gnovm/pkg/gnomod/gnomod.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3083      +/-   ##
==========================================
+ Coverage   63.34%   63.35%   +0.01%     
==========================================
  Files         548      548              
  Lines       78680    78681       +1     
==========================================
+ Hits        49836    49848      +12     
+ Misses      25482    25468      -14     
- Partials     3362     3365       +3     
Flag Coverage Δ
contribs/gnodev 61.16% <ø> (ø)
contribs/gnofaucet 14.82% <ø> (ø)
gno.land 67.13% <ø> (ø)
gnovm 67.92% <71.42%> (+0.02%) ⬆️
misc/genstd 79.72% <ø> (ø)
tm2 62.44% <ø> (+0.09%) ⬆️

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: Norman Meier <[email protected]>
@n0izn0iz n0izn0iz marked this pull request as draft November 7, 2024 01:01
Signed-off-by: Norman Meier <[email protected]>
@n0izn0iz n0izn0iz marked this pull request as ready for review November 7, 2024 01:47
@jefft0 jefft0 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Nov 7, 2024
Comment on lines 62 to 67
if test.tmpGnoHome {
gnohome, err := os.MkdirTemp(os.TempDir(), "gnotesthome_")
require.NoError(t, err)
t.Cleanup(func() { os.RemoveAll(gnohome) })
t.Setenv("GNOHOME", gnohome)
}
Copy link
Member

Choose a reason for hiding this comment

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

This can just be done always, I would say, rather than with the flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay but this breaks some other tests, I'd rather do it separately from this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually it was straightforward, I reverted the condition and disabled the tmp gnohome on the 3 offending test

51c93bd

@@ -64,6 +63,19 @@ func execClean(cfg *cleanCfg, args []string, io commands.IO) error {
return flag.ErrHelp
}

if cfg.modCache {
modCacheDir := gnomod.GetGnoModPath()
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename the method to ModCachePath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if cfg.dryRun || cfg.verbose {
io.Println("rm -rf", modCacheDir)
}
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Remove? (ie. support cleaning modcache as well as cached files in current dir?)

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can return here (without an error, maybe a log message) if there is no gno.mod.

Copy link
Contributor Author

@n0izn0iz n0izn0iz Nov 7, 2024

Choose a reason for hiding this comment

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

are you sure we want that, I follow go behavior here:

the dry run with no arguments shows only a removal of the modcache

❯ go clean -modcache -n
rm -rf /Users/norman/go/pkg/mod

with arguments it's explicitely disabled

❯ go clean -modcache .
go: clean -modcache cannot be used with package arguments

@thehowl thehowl removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Nov 7, 2024
@n0izn0iz n0izn0iz changed the title fix(cmd/gno/clean): allow to run gno clean -modcache from anywhere + use GetGnoModPath fix(cmd/gno/clean): allow to run gno clean -modcache from anywhere + rename and use gnomod.ModCachePath Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: In Progress
Status: Triage
Development

Successfully merging this pull request may close these issues.

3 participants