gno icon indicating copy to clipboard operation
gno copied to clipboard

feat(gnovm): packages.Load

Open n0izn0iz opened this issue 5 months ago β€’ 2 comments

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

Screenshot 2024-10-11 at 13 50 18

n0izn0iz avatar Jun 17 '25 11:06 n0izn0iz

πŸ›  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:
  1. Fix any issues flagged by automated checks.
  2. 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 CHANGE notes.
    • Link related issues/PRs, where applicable.
β˜‘οΈ Reviewer Actions:
  1. 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 request

Pending 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 request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟒 Condition met
└── 🟒 On every pull request

Can be checked by

  • Any user with comment edit permission

Gno2D2 avatar Jun 17 '25 11:06 Gno2D2

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).

moul avatar Jul 21 '25 11:07 moul

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?

jeronimoalbi avatar Jul 22 '25 14:07 jeronimoalbi

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.

n0izn0iz avatar Jul 22 '25 16:07 n0izn0iz

i'm thinking, having documentation in /docs for this would help to understand usage of gnowork.toml

MikaelVallenet avatar Jul 23 '25 09:07 MikaelVallenet

Docs would be good. I intended gnowork.toml to be in Configuring Gno Projects, under Resources.

leohhhn avatar Jul 23 '25 09:07 leohhhn

can contribute to the doc after this PR is reviewed and we are sure of the final behavior :)

n0izn0iz avatar Jul 23 '25 10:07 n0izn0iz

just discovered that subworkspaces are not properly ignored, will push a fix and a test asap edit: done

n0izn0iz avatar Jul 23 '25 10:07 n0izn0iz

@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 WalkDir goes depth first.

n0izn0iz avatar Jul 24 '25 13:07 n0izn0iz

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 avatar Jul 29 '25 12:07 jefft0

@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

n0izn0iz avatar Jul 29 '25 12:07 n0izn0iz

I'm preparing the linter integration in this branch https://github.com/n0izn0iz/gno/pull/4

n0izn0iz avatar Aug 03 '25 14:08 n0izn0iz

@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 avatar Aug 11 '25 13:08 leohhhn

@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

n0izn0iz avatar Aug 11 '25 18:08 n0izn0iz

wen gnodev integration

cc @stefann-01 @matijamarjanovic

leohhhn avatar Aug 13 '25 09:08 leohhhn