ocaml-sf / learn-ocaml

A Web Application for Learning OCaml
https://ocaml-sf.org/learn-ocaml/
MIT License
304 stars 66 forks source link

Add option `learn-ocaml build serve --serve-during-build` and fix related minor issues #597

Closed erikmd closed 6 months ago

erikmd commented 7 months ago

Description

Good news, @AltGr @yurug !

I was able (with Louis' advice from last week) to implement #594.

Regarding the naming of the CLI command, I now propose --serve-during-build (better than my initial try, --fork-replace)

Each commit comes with a detailed description (or motivation), in particular note that:

I thoroughly tested the new option as summarized in the message of the main commit https://github.com/ocaml-sf/learn-ocaml/commit/f0108a34ae70ab45d22c21252b51e1bfb8a6c5ca but as suggested by @AltGr, I didn't turn the option on by default in the Dockerfile.

Regarding performance, I ran an experiment on learn-ocaml-corpus endowed with the following docker-compose.yml:

docker-compose.yml ```yaml services: lo-test: image: learn-ocaml # build using ( sudo make docker-images ) volumes: - ../learn-ocaml-corpus:/repository - lo-test-serve-during-build-sync:/sync ports: - '8080:8080' restart: unless-stopped environment: - 'LEARNOCAML_SERVE_DURING_BUILD=true' volumes: lo-test-serve-during-build-sync: driver: local ```

along with the following script:

shell session ``` $ sudo make docker-images $ sudo docker compose up -d $ sudo docker compose logs -t lo-test $ sudo docker compose stop $ touch ../learn-ocaml-corpus/exercises/fpottier/*/test.ml # touch 26 exercises $ sudo docker compose restart $ sudo docker compose logs -t lo-test ```

And I got:

So I believe the effort was worth it for this quite standard use case :)

Now, let's wait for the CI ! and let me know if you have review comments.

And last hint: we shouldn't squash-merge this PR but rather do a regular merge (to preserve the atomic commits).

Checklist

Note to maintainers

erikmd commented 7 months ago

Hi @AltGr @yurug, I believe I addressed all your suggestions.

erikmd commented 6 months ago

@AltGr

while I agree that code-wise they are pretty different, from a user-perspective, they're both options concerning the server though (as the name implies!) -- and with similar use-cases so it would be best to have them closer to each other.

We could cheat by keeping this organisation in the code, but hardcoding ~docs to still put it in the SERVER section of the manpage (COMMON OPTIONS implicitely means the union of the commands, here we're dealing with the intersection :) )

Very good point, thanks! I fixed it as suggested.

Thanks again for your advice and help!

erikmd commented 6 months ago

With this last tweak (and rebase), CI is green.

@AltGr @yurug If you don't object, I will merge the PR today at 16:00 or so.