Ocamlformat#581
Conversation
There was a problem hiding this comment.
The documentation for ocamlformat recommend the ocamlformat version and a profile. Ocamlformat supports three different profiles straight out of the box. I'd suggest using default unless there is a reason not to.
| profile = default | |
| version = 0.28.1 |
There was a problem hiding this comment.
agreed. I will attend to that and add a version of ocamlformat to the switch as well (let me research how to do that!)
|
|
||
| install_deps: | ||
| opam install dune ounit qcheck fpath react ppx_deriving ppx_sexp_conv yojson ocp-indent calendar core mustache ezjsonm core_unix | ||
| opam install dune ounit qcheck fpath react ppx_deriving ppx_sexp_conv yojson ocp-indent calendar core mustache ezjsonm core_unix ocamlformat ocaml-lsp-server |
There was a problem hiding this comment.
If add a specific version of ocamlformat is added to .ocamlformat, we should install the same version of ocamlformat here.
|
with the comments above addressed, do you want:
|
Since the profile is being added in this PR, happy for it to be part of this PR.
I think I lean towards not too - sometimes I just want to focus on getting the tests working before dealing with the formatting. However, I do think we should add it to the CI. |
|
The linting checks of the CI add another minute to the actions, as they checkout the code and install dependencies separate to the Dockerfile creation. Would you be willing to have caching on the opam dependencies? Something like: - name: Cache opam
uses: actions/cache@v4
with:
path: ~/.opam
key: opam-${{ runner.os }}-${{ hashFiles('**/*.opam') }}
restore-keys: |
opam-${{ runner.os }}-This should reduce the action time for the lint. There might even be a way to do this for the Dockerfile too with |
Yes, I think that would be fine |
|
the setup-ocaml action has a built in cache flag, which has been added to the lint job now. It should cache for 7 days. |
|
caching the lint job does work, but it still adds 2m to the job. Is this worth it? It will be quite a long job after the cache invalidates. If not then I can remove it from CI and just keep it as a Makefile command. |
|
How long does it take when the cache invalidates? I think even if it takes two minutes, it is still useful for me (as reviewer) to know the formatting has been applied. |
around 6 minutes. A separate job was made so it would fail fast rather than build the docker container. It is not working how I envisaged since OCaml builds are heavy. However, it may be worth considering just making it the first script that is ran inside the main job for now. |
|
Is it worth considering using separate workflow for the formatting? The Go track does this, which allows them to run separately. |
Changes
ocamlformatandocaml-lsp-serveradded to dependenciesThe below only currently applies to the test-generator directory:
duneand*.mlfiles will auto format on savemake check-formattingwill check all files in this and its sub-directories for formatting errors - potential to add to CI pipeline in the future to fail early on errormake formatwill auto format every file in this directory and its sub-directoriesTodo - with approval
.ocamlformatfile to.metadirectories on exercise creation (and retroactively), so thatexample.mlis formatted by default.