gno
gno copied to clipboard
feat(gnovm): packages.Load
Continuation of #2932 I ripped the loader and cleared integrations to remake them
This implements a Load function with a similar interface to the packages.Load go function and uses it in gno test and gno tool lint
Also adds the gno list command to inspect packages, it is a thin cli wrapper around packages.Load
The intent of this PR is to refactor and centralize package loading for tools that use go-style package patterns like gno test, gno tool lint, gno list
It is also meant to be used by external tools to resolve packages sources like gnopls
As a side-effect it will unlock remote dependency loading for those tools
π PR Checks Summary
All Automated Checks passed. β
Manual Checks (for Reviewers):
- [ ] IGNORE the bot requirements for this PR (force green CI check)
Read More
π€ This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.
β Automated Checks (for Contributors):
π’ Maintainers must be able to edit this pull request (more info) π’ Pending initial approval by a review team member, or review from tech-staff
βοΈ Contributor Actions:
- Fix any issues flagged by automated checks.
- Follow the Contributor Checklist to ensure your PR is ready for review.
- Add new tests, or document why they are unnecessary.
- Provide clear examples/screenshots, if necessary.
- Update documentation, if required.
- Ensure no breaking changes, or include
BREAKING CHANGEnotes. - Link related issues/PRs, where applicable.
βοΈ Reviewer Actions:
- Complete manual checks for the PR, including the guidelines and additional checks if applicable.
π Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)
If
π’ Condition met βββ π’ And βββ π’ The base branch matches this pattern: ^master$ βββ π’ The pull request was created from a fork (head branch repo: n0izn0iz/gno)Then
π’ Requirement satisfied βββ π’ Maintainer can modify this pull requestPending initial approval by a review team member, or review from tech-staff
If
π’ Condition met βββ π’ And βββ π’ The base branch matches this pattern: ^master$ βββ π’ Not (π΄ Pull request author is a member of the team: tech-staff)Then
π’ Requirement satisfied βββ π’ If βββ π’ Condition β βββ π’ Or β βββ π’ User notJoon already reviewed PR 4384 with state APPROVED β βββ π’ At least 1 user(s) of the team tech-staff reviewed pull request β βββ π΄ This pull request is a draft βββ π’ Then βββ π’ And βββ π’ Not (π΄ This label is applied to pull request: review/triage-pending) βββ π’ At least 1 user(s) of the team tech-staff reviewed pull requestManual Checks
**IGNORE** the bot requirements for this PR (force green CI check)
If
π’ Condition met βββ π’ On every pull requestCan be checked by
- Any user with comment edit permission
Codecov Report
:x: Patch coverage is 70.63572% with 291 lines in your changes missing coverage. Please review.
:loudspeaker: Thoughts on this report? Let us know!
Iβve added many people to review this one, as it represents a significant step forward in making βworking outside of the monorepo a pleasant experienceβ. While code-related reviews are still necessary, Iβve requested so many reviewers to gather βusage reviewsβ. Please try it out and let us know how your non-monorepo experience has changed (or not).
These changes are a great quality of life improvement π
@n0izn0iz I tried locally and gno test works only as long as there is a gnowork.toml file present within the directory tree path, without it tests won't run. Before it was possible to test cases that only imported from standard library or example/ realms and packages, it would be great to keep that behavior, that would mean that gnowork.toml would be optional. WDYT?
Having an implicit workspace root based on cwd is bad behavior IMO (this makes dependencies resolution dependent on the directory you are in, which is confusing and deviates from go behavior) and touch gnowork.toml is cheap.
You can specify the workspace root via the LoadConfig.WorkspaceRoot field which removes the requirement for gnowork.toml but it's not used in gno test as it is meant for programmatic usage of the loader.
We can discuss specific behaviors we want to support where gnowork.toml is not required and maybe implement them (for example gno test somefile.gno that only imports stdlibs or gno test some/stdlib) but it's out of scope of this PR I think since it would make the code a lot more complex.
i'm thinking, having documentation in /docs for this would help to understand usage of gnowork.toml
Docs would be good. I intended gnowork.toml to be in Configuring Gno Projects, under Resources.
can contribute to the doc after this PR is reviewed and we are sure of the final behavior :)
just discovered that subworkspaces are not properly ignored, will push a fix and a test asap edit: done
@ajnavarro
- regarding https://github.com/gnolang/gno/pull/4384#discussion_r2228490484: applied your request and added comments in 8b071a65978253f3b6f4ccb8746757609687546e
- regarding https://github.com/gnolang/gno/pull/4384#discussion_r2228499360: reworked this routine in 507796d and 93451bb because the sub-workspace detection was broken since
WalkDirgoes depth first.
Docs would be good. I intended gnowork.toml to be in Configuring Gno Projects, under Resources.
I'm a little confused. The master branch mentions gnowork.toml. But this is the only mention in master. https://github.com/gnolang/gno/blob/de4b5b56c60126373ec0702234c196fdae365a0b/docs/README.md?plain=1#L45 Will this PR update https://github.com/gnolang/gno/blob/master/docs/resources/configuring-gno-projects.md to explain gnowork.toml?
@jefft0 yes I will add docs once the behavior is reviewed and confirmed, in this PR or another one very shortly after merge
for now, like explained in the desc of the PR, gnowork.toml is empty and used to set the project root for dependencies resolution, in most cases you only need to touch gnowork.toml at the root of your repo
I'm preparing the linter integration in this branch https://github.com/n0izn0iz/gno/pull/4
@n0izn0iz
We're about to merge this after @gfanton's approval. What do you think are the next steps in regards to the feature itself? I see:
- Docs
- Linter
replace
I can help with docs but I'd need to sync with you on a few things so I understand how this works in more detail. What we also can do is you could scaffold the docs and I'll help brush them up.
@leohhhn Totally agree with you on docs and linter, linter is already prepared in another branch and integrated in CI in some of our repos
For replace, there is a discussion to have, I think we should drop replace support in gnomod.toml and add it in gnowork.toml so you can't have conflicting replaces in a project, kinda like go does.
Also thinking about finishing the gnopls integration, I already use it but it has still many quirks
wen gnodev integration
cc @stefann-01 @matijamarjanovic