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

test(melange): demonstrate melange.emit doesn't respect -p #7849

Merged
merged 2 commits into from
Jun 3, 2023

Conversation

anmonteiro
Copy link
Collaborator

@anmonteiro anmonteiro commented Jun 1, 2023

  • dune build -p some-package was trying to build melange.emit stanzas belonging to other packages
  • the fix is to teach the stanza_package function about the melange package field

Copy link
Collaborator

@jchavarri jchavarri left a comment

Choose a reason for hiding this comment

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

I found similar code (match over stanzas type) in install_rules.ml (here and here).I wonder if Melange_emit should be included in those cases too.

@rgrinberg
Copy link
Member

dune build -p some-package was trying to build melange.emit stanzas belonging to other packages

Isn't that how it works for private executables? Given that there's no way to mark melange.emit as "public", this behavior seems consistent.

@anmonteiro
Copy link
Collaborator Author

So what’s the package field in the emit stanza for?

@anmonteiro
Copy link
Collaborator Author

@rgrinberg FWIW this was found in a real world use case (reason-react). The setup works like this:

  • reactjs-ppx.opam defines a ppx that only depends on ppxlib
  • reason-react is preprocessed with the react PPX, and defines its own melange tests with melange.emit
  • when trying to run dune build -p react-ppx for a release, we get an error in the JS tests (package reason-react not found)

@rgrinberg
Copy link
Member

rgrinberg commented Jun 1, 2023

So what’s the package field in the emit stanza for?

No idea tbh. For executables, it's used to attach those executables with public names to packages.

when trying to run dune build -p react-ppx for a release, we get an error in the JS tests (package reason-react not found)

Is it because you're building @all instead of @install? Otherwise, I'm not sure how the melange.emit is being picked up by the @install stanza.

@anmonteiro
Copy link
Collaborator Author

The test in this PR still fails if I change the command to dune build -p my-ppx @install.

Is the issue that melange.emit is being picked up, then?

@rgrinberg
Copy link
Member

rgrinberg commented Jun 1, 2023

Actually, it's just an issue with rule loading. The failure comes from the rule loading stage rather than rule execution stage. The issue is that the melange rules use read_memo which blows up when searching for @install dependencies in test/

@anmonteiro
Copy link
Collaborator Author

Interesting. What's the best way to address this?

@rgrinberg
Copy link
Member

Resolve.t is just a result type, so you can just inspect it instead of assuming it has a value. In the case where something can't be resolved, we could add some dummy targets that will fail with Action_builder.fail. It's not perfect, but it's the best we can do without proper target masks.

@anmonteiro
Copy link
Collaborator Author

OK, I pushed an alternative fix that also satisfies the test.

I'm not sure 1. what to name the dummy target 2. what to write inside Action_builder.fail, so would appreciate guidance there.

in
setup_js_rules_libraries ~dir ~scope ~target_dir ~sctx ~requires_link ~mode
mel
match Resolve.is_ok requires_link_resolve with
Copy link
Member

Choose a reason for hiding this comment

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

Resolve.to_result can be used here.

@rgrinberg
Copy link
Member

  1. what to name the dummy target

I would pick some target names that match what we would setup if the dependencies weren't absent. So for melange.emit, that could be the entry point .js files. The intent is to convert "missing rule for target" errors into "missing dependency" errors.

@anmonteiro anmonteiro force-pushed the anmonteiro/melange-emit-package branch 2 times, most recently from b71cb13 to 9b6e227 Compare June 2, 2023 08:14
@anmonteiro
Copy link
Collaborator Author

Thank you. The latest push follows that approach.

@anmonteiro anmonteiro force-pushed the anmonteiro/melange-emit-package branch from 9b6e227 to 7db23be Compare June 2, 2023 08:19
src/dune_rules/resolve.ml Show resolved Hide resolved
@anmonteiro anmonteiro force-pushed the anmonteiro/melange-emit-package branch 2 times, most recently from eabd40f to 02b0af4 Compare June 3, 2023 08:25
src/dune_rules/resolve.ml Outdated Show resolved Hide resolved
@rgrinberg rgrinberg force-pushed the anmonteiro/melange-emit-package branch from c10e959 to eb7bda9 Compare June 3, 2023 16:45
@Alizter
Copy link
Collaborator

Alizter commented Jun 3, 2023

Weird that thr Coq tests have lost some location info in the trace.

@rgrinberg
Copy link
Member

Mystery is solved

@anmonteiro anmonteiro force-pushed the anmonteiro/melange-emit-package branch 2 times, most recently from 6d5f0fe to 5222d32 Compare June 3, 2023 20:31
@anmonteiro
Copy link
Collaborator Author

Thanks, Rudi.

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
@anmonteiro anmonteiro force-pushed the anmonteiro/melange-emit-package branch from 5222d32 to 6d52a64 Compare June 3, 2023 21:06
@anmonteiro anmonteiro merged commit 59d6ed1 into ocaml:main Jun 3, 2023
@anmonteiro anmonteiro deleted the anmonteiro/melange-emit-package branch June 3, 2023 21:38
@anmonteiro
Copy link
Collaborator Author

@emillon can you port this for 3.8.2 please?

@emillon emillon mentioned this pull request Jun 7, 2023
7 tasks
@emillon
Copy link
Collaborator

emillon commented Jun 7, 2023

Will do, but this needs a changelog entry.

@anmonteiro
Copy link
Collaborator Author

anmonteiro commented Jun 7, 2023

I don’t think it needs a changes entry since melange support is still 0.1 (we haven’t included melange anywhere in the change log previously)

@emillon
Copy link
Collaborator

emillon commented Jun 8, 2023

I don't think it's a hard rule. mdx is 0.x but is present in the changelog for example. Given it's documented now I think future melange changes should get a changelog entry now (and for backports it helps knowing what's been backported)

@rgrinberg
Copy link
Member

Didn't we announce melange support in dune? If we did, I think we should include updates in CHANGES. They're informative to users and allow them to follow the development of the feature more easily - even if we aren't yet obligated to maintain backwards compatibility.

anmonteiro added a commit to anmonteiro/dune that referenced this pull request Jun 8, 2023
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
emillon added a commit that referenced this pull request Jun 9, 2023
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Co-authored-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this pull request Jun 9, 2023
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Co-authored-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this pull request Jun 9, 2023
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Co-authored-by: Etienne Millon <me@emillon.org>
emillon added a commit that referenced this pull request Jun 9, 2023
* test(melange): demonstrate melange.emit doesn't respect `-p`

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* fix(melange): resolve libraries lazily for melange.emit

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

* chore: add changelog entry for #7849 (#7925)

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Co-authored-by: Etienne Millon <me@emillon.org>

---------

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
Co-authored-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
emillon added a commit to emillon/opam-repository that referenced this pull request Jun 16, 2023
CHANGES:

- Switch back to threaded console for all systems; fix unresponsive console on
  Windows (ocaml/dune#7906, @nojb)

- Respect `-p` / `--only-packages` for `melange.emit` artifacts (ocaml/dune#7849, @anmonteiro)

- Fix scanning of Coq installed files (@ejgallego, reported by
  @palmskog, ocaml/dune#7895 , fixes ocaml/dune#7893)

- Fix RPC buffer corruption issues due to multi threading. This issue was only
  reproducible with large RPC payloads (ocaml/dune#7418)

- Fix printing errors from excerpts whenever character offsets span multiple
  lines (ocaml/dune#7950, fixes ocaml/dune#7905, @rgrinberg)
davesnx added a commit to reasonml/reason-react that referenced this pull request Sep 13, 2023
shadow-shaman0209 pushed a commit to shadow-shaman0209/reason-react that referenced this pull request Oct 3, 2023
jchavarri added a commit to jchavarri/opam-repository that referenced this pull request Oct 21, 2023
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants