Skip to content

feat(oxcaml): add support for OxCaml testing suite #11826

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

Merged
merged 14 commits into from
Jun 18, 2025

Conversation

maiste
Copy link
Collaborator

@maiste maiste commented May 21, 2025

This PR introduces some support to OxCaml testing inside of Dune. To do so, it provides three different things:

  • It adds a variable, %{oxcaml_supported} to enable test in such case.
  • It updates the OCcaml_toolchain.t to support a is_oxcaml_supported and is_parametrized_library_supported functions. It allows building extra functionalities related to OxCaml and separate the compiler variant (needed for the variable) and the functionality (needed for a specific functionality).
  • It introduces the test suite for OxCaml and only activates it when detecting the correct compiler (OxCaml one) using the new Dune variable.
  • It adds a GitHub Actions to build this test suite with an OxCaml compiler.

The action is pinned to a specific commit to prevent it from breaking because of a change in the JaneStreet repository.

@maiste maiste force-pushed the ci/setup-oxcaml branch from e24806f to f25b79c Compare May 21, 2025 08:53
@maiste maiste added chore Something that just needs to be done. oxcaml Related to the support to OxCaml functionnalities labels May 21, 2025
@maiste maiste force-pushed the ci/setup-oxcaml branch from f25b79c to e3934e6 Compare May 21, 2025 12:19
@maiste maiste requested a review from art-w May 21, 2025 12:20
@maiste maiste changed the title chore(ci): setup OxCaml feat(oxcaml): add detection support for OxCaml May 21, 2025
@maiste maiste changed the title feat(oxcaml): add detection support for OxCaml feat(oxcaml): add support for OxCaml testing suite May 21, 2025
@maiste maiste force-pushed the ci/setup-oxcaml branch from e3934e6 to c4eaa32 Compare May 21, 2025 12:53
@maiste maiste requested a review from rgrinberg May 21, 2025 12:58
Copy link
Collaborator

@art-w art-w left a comment

Choose a reason for hiding this comment

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

Very nice! Only some small nitpicks to clean up the PR :)

@maiste maiste force-pushed the ci/setup-oxcaml branch from f0dc190 to c8591b3 Compare June 3, 2025 16:06
@maiste
Copy link
Collaborator Author

maiste commented Jun 3, 2025

@art-w I have rebased, you should be able to check again.
@rgrinberg what do you think? Would it be OK to include this part? We will open further PRs for the various functionalities.

@maiste maiste force-pushed the ci/setup-oxcaml branch from c8591b3 to fdf7f90 Compare June 4, 2025 08:38
@maiste
Copy link
Collaborator Author

maiste commented Jun 4, 2025

@rgrinberg I encounter the problem where if I develop a new feature and guard it with the next release version, I can't use it inside of Dune until this version is released. Should I add the guard to the current version deployed version (3.19) or do you think I should look at the solution we discussed to have dune use the latest version internally?

@rgrinberg
Copy link
Member

Should I add the guard to the current version deployed version (3.19) or do you think I should look at the solution we discussed to have dune use the latest version internally?

Thinking about the problem again, I think this isn't going to work because the issue is our CI. We are building the dune workspace with the version of dune coming from opam (is that right? this needs confirmation). We should just not do that and always use the bootstrapped version of dune. If we do that, no hacks will be necessary and you'll be able to upgrade dune itself to 3.20 as soon as you introduce it.

@maiste maiste force-pushed the ci/setup-oxcaml branch 3 times, most recently from 1b68283 to d56511e Compare June 12, 2025 12:10
@maiste
Copy link
Collaborator Author

maiste commented Jun 12, 2025

@rgrinberg with the help of @Alizter (thanks again 🙏), I have managed to introduce the extension as you suggested. This PR is ready for another round of review.

@@ -628,6 +634,7 @@ module Env = struct
; "ocaml-config", macro Ocaml_config
; "env", since ~version:(1, 4) Macro.Env
; "coq", macro Coq_config
; "oxcaml", since ~version:(3, 20) Macro.Oxcaml
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't you be checking this against the oxcaml extension? I think you will need to extend Since to be more generic to support that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As it is nor possible to check against the extension here (because of dependency cycle problems) the code for checking this was moved to the macro evaluation. It also helps to limit the spreading of OxCaml extension to the rest of the code. It is modelled the same way as what is done for rocq (coq). Hence, this is not necessary to add extra checks here.

Copy link
Member

Choose a reason for hiding this comment

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

I have no idea how a cycle comes into play here. It seems like it should be trivial to move the definition of the extension to avoid it.

the code for checking this was moved to the macro evaluation

I don't really understand this.

It also helps to limit the spreading of OxCaml extension to the rest of the code

At the cost of making the implementation inconsistent and buggy wrt the rest of dune.

It is modelled the same way as what is done for rocq (coq). Hence, this is not necessary to add extra checks here.

This is not the example we should follow. The coq extension is maintained exclusively by the coq folks and we don't control their quality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem I encountered is: to use extensions, I need to deal with the Dune_project module because this is where the information about extensions are stored. However Dune_project already depends on pform so I can't do anything there without creating a cycle. The idea was to move the check to where all of this would be instantiated, more particularly when we are expanding the values. At this point of the code, we know everything is instantiated.

You made me realized it doesn't need to be a macro as I can also get the Dune_project.t from the Var expander.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rgrinberg I have moved it back to the variable and port the check directly inside the expander. Would it be better this way?

@@ -0,0 +1,23 @@
The test ensures we are able to run OxCaml tests for Dune.

$ cat > dune-project << EOF
Copy link
Member

Choose a reason for hiding this comment

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

I think your test should demonstrate usage of this variable and the error message that you get when oxcaml isn't enabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

535e83b demonstrates the features with and without the extension.

@@ -628,6 +634,7 @@ module Env = struct
; "ocaml-config", macro Ocaml_config
; "env", since ~version:(1, 4) Macro.Env
; "coq", macro Coq_config
; "oxcaml", since ~version:(3, 20) Macro.Oxcaml
Copy link
Member

Choose a reason for hiding this comment

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

I have no idea how a cycle comes into play here. It seems like it should be trivial to move the definition of the extension to avoid it.

the code for checking this was moved to the macro evaluation

I don't really understand this.

It also helps to limit the spreading of OxCaml extension to the rest of the code

At the cost of making the implementation inconsistent and buggy wrt the rest of dune.

It is modelled the same way as what is done for rocq (coq). Hence, this is not necessary to add extra checks here.

This is not the example we should follow. The coq extension is maintained exclusively by the coq folks and we don't control their quality.

@maiste maiste force-pushed the ci/setup-oxcaml branch 3 times, most recently from 535e83b to 7cdc1ec Compare June 16, 2025 14:11
Copy link
Collaborator

@art-w art-w left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks :)

@rgrinberg
Copy link
Member

Some background: before dune 3.0, all percent forms were dynamically resolved during evaluation. This was a very painful situations because it meant that users could write junk in a section of their dune file, never evaluate the said section, and be unaware that their dune file is invalid.

In 3.0, we decided to change our frontend to resolve percent forms during parsing. This way, any invalid percent form would trigger an error when the dune file is first loaded. This indeed was a much better experience, but we left some escape hatches for backwards compatibility, and we never made it general enough to work with language extensions.

I pushed a commit that moves the validation of this percent form to the parser. This way, even if you don't hit the branch that evaluates the form, you should still get the error that the dune file is invalid. There might be some polish lacking, but this is the general direction to take.

@maiste
Copy link
Collaborator Author

maiste commented Jun 17, 2025

Indeed, I was lacking the context and thought you wanted to have the expander fail faster. Thank you for the commit and the explanation, it is clearer to me.

I will extract your commit and split this PR in two to make smaller and more targeted PRs.

@maiste maiste force-pushed the ci/setup-oxcaml branch from f0d9058 to 6b85083 Compare June 17, 2025 15:07
@maiste maiste changed the base branch from main to feat/use-syntax-on-extension June 17, 2025 15:10
@maiste
Copy link
Collaborator Author

maiste commented Jun 17, 2025

I have extracted the commit to another branch. The other one must be merged first. Then, I'll rebase this one on main to add the specific OxCaml functionalities.

@maiste maiste changed the base branch from feat/use-syntax-on-extension to main June 18, 2025 07:26
maiste and others added 13 commits June 18, 2025 10:28
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Rudi Grinberg <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Co-authored-by: Rudi Grinberg <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
@maiste maiste force-pushed the ci/setup-oxcaml branch from 6b85083 to 39da5e3 Compare June 18, 2025 08:31
Signed-off-by: Etienne Marais <[email protected]>
@maiste maiste merged commit f3e8380 into ocaml:main Jun 18, 2025
25 checks passed
@maiste maiste deleted the ci/setup-oxcaml branch June 18, 2025 12:22
Sudha247 pushed a commit to Sudha247/dune that referenced this pull request Jul 23, 2025
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Rudi Grinberg <[email protected]>
Co-authored-by: Rudi Grinberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Something that just needs to be done. oxcaml Related to the support to OxCaml functionnalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants