ocaml-ci icon indicating copy to clipboard operation
ocaml-ci copied to clipboard

Should we skip linting when ocamlformat_source is None?

Open favonia opened this issue 5 years ago • 6 comments

I have a question about this part of the code:

https://github.com/ocurrent/ocaml-ci/blob/a94d6da100da44df0988322b69980e82cbc75f03/lib/lint.ml#L22-L26

It seems when ocamlformat_source is None, it is impossible to have a working ocamlformat around. If so, should we skip dune build @fmt completely?

favonia avatar Jul 18 '20 12:07 favonia

I asked @CraigFe about this recently, and he said it was to do with wanting to lint dune files even in projects without ocamlformat. The dune docs say:

By default, formatting will be enabled for all languages and dialects present in the project that dune knows about.

Which seems a bit odd, as new ones might get added without you doing anything. I guess people should use (formatting disabled) if they don't want formatting, or enabled_for and list the formatters they want:

https://dune.readthedocs.io/en/latest/dune-files.html#formatting

talex5 avatar Jul 18 '20 17:07 talex5

Yeah, I added (formatting disabled) after studying why my package (originally) did not pass CI. How about an error message like this? I can imagine that a beginner would be confused (after ocaml-ci goes more public).

dune build @fmt failed.

It is likely that dune could not find the binary executable ocamlformat in the current environment.
Possible solutions: specify the version of OCamlFormat in .ocamlformat so that ocaml-ci will install it,
or disable formatting in dune-project. See https://dune.readthedocs.io/en/latest/dune-files.html#formatting.

Perhaps some analysis of the actual errors (before printing out the above message) would also help.

favonia avatar Jul 18 '20 18:07 favonia

I think this is a bug in dune -- a newer version of the dune client should not break older workflows without a versioning step involved. We shouldn't be working around this with complex logic in ocaml-ci, as other CIs will eventually hit it then. I've filed https://github.com/ocaml/dune/issues/3642 for downstream discussion.

avsm avatar Jul 19 '20 10:07 avsm

Visiting this as part of a general cleanup -

@emillon can I please check in on the status of the linked dune issue.

Possibly related: At the moment a missing version in .ocamlformat causes the analysis step to fail when it should probably handle it gracefully and continue to build the project while failing the linting step.

Anything that you'd like to add to help decide what action we could take on this issue please @avsm @talex5 @favonia? Thanks //cc @tmcgilchrist

novemberkilo avatar Mar 07 '23 04:03 novemberkilo

Possibly related: At the moment a missing version in .ocamlformat causes the analysis step to fail when it should probably handle it gracefully and continue to build the project while failing the linting step.

We should handle that gracefully, also reported via https://github.com/ocurrent/ocaml-ci/issues/834. Pinged the linked issue on dune which has been inactive since 2020.

tmcgilchrist avatar Sep 04 '23 06:09 tmcgilchrist

I replied over there to clarify the scope of the issue.

emillon avatar Sep 04 '23 13:09 emillon