-
Notifications
You must be signed in to change notification settings - Fork 77
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
Build system rehaul, use of Docker for CI & artifact generation on Github #299
Conversation
f8abb1c
to
2b9ea0d
Compare
Wouahou ! So how does this work ? Will the generated files be updated nightly by a bot ? Or appear in a source code release attached to the GitHub page ? I put those generated assets under Git because I wanted for somebody that wanted to just use Catala to be able to use the assets directly without having to install the compiler to generate them. |
Aah I didn't know! But indeed, providing them as artifacts would be pretty easy: they are already generated by the CI so extracting them from the Docker image and feeding them to Github artifacts / release assets should be fairly straightforward. Is there already a list of artifacts that we should extract in that way ? |
So for me, ideally:
A push-button release process would be amazing, I would release more often that today with that. |
Ok I'll handle that |
See #219 where I talked a bit about this |
The files where manually generated through Makefile rules, and versionned (with an outdated version). The issue was that we had: - `dune` building Catala - Makefiles calling `catala` to build and copy the `french_law/ocaml/law_source` files - then `dune` again to build `french_law` The result was that `dune build` (without running `make` first) would return a weird error. The proposed solution adds ad-hoc dune rules to call the catala binary, so that it can handle the whole pipeline correctly. If OCaml is purely a backend, though, a simpler solution that makes us less dependent on dune would be to handle the compilation of `french_law` manually. The dune rules are set to 'promote' the files so that it preserves the fact that they are versionned (but with no confusion of the build system about where they should come from anymore)
(plus other small Makefile improvements)
Dune has 2 default build profiles: `dev` and `release`, which change things like warnings-as-errors, and debug in jsoo build mode. We need to be in release mode when we generate the javascript artifacts (e.g. `make website-assets`), so the master `Makefile` had `--profile=release` for the `dune` commands building them. However, that rebuilds _the whole tree of dependencies_ in release mode, which means `make all` might rebuild everything several times, as the `release` flag is turned off and on. I had conflicting plugins that weren't rebuilt with the correct flag. And let's not imagine the `make -j` case… This is the best solution I can think of for the time being: - set the Makefile to use dune's `release` profile by default - this ensure consistency and avoids surprises with e.g. bad (slower) artifacts generated for the website - devs can use `dune` directly when working, or set `DUNE_PROFILE` manually if they need it I am not sure yet about CI, though, since we want warnings-as-errors but also useful artifacts. Might best to build twice…
(they're no longer reformatted, at the moment, though)
We have an obvious limitation: static builds won't support plugins. We could resort to the classic method and do normal builds but on an old distrib to dodge compatibility issues. That would still be compatible with statically linking the more specific libs, like e.g. z3.
a852317
to
e56a4b4
Compare
Should now be OK; generation of the artifacts is only activated on the master branch but I tested it here. (I removed node's Compared to the first version, I leveraged dune's "promotion" feature which means I was able to keep the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks awesome, a well-deserved overhaul of the build system. I raised a few nitpicks, you can merge after dealing with them.
@@ -16,9 +16,20 @@ | |||
ANSITerminal) | |||
(modules clerk_driver)) | |||
|
|||
(rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's that for ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid a failure when the custom_linking.sexp
file doesn't exist (we default it to a file containing just ()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(we could also statically add the file to the source tree; the upside of that would be that it is harder to get confused because you had a stale file sitting there; but it's not very pretty)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok and the custom_linking.sexp
is produced by the build_release.sh
script. Maybe that would be worth a comment in the dune file. I'm in favor of not adding custom_linking.sexp
to the build tree.
@@ -0,0 +1 @@ | |||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did that to speed up the build, because we don't need to format generated files ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah indeed that's something I wanted to discuss with you!
It feels a bit strange to me to reformat just-generated files; that also adds a run-time dependency to ocamlformat
for running these rules. And it complicated things (we don't want ocamlformat and dune to compete on the resulting file).
No big speedup here (but in the case of the Python files, autopep8
is very slow)
But I guess there were reasons to do this in the first place so I am open to finding a workaround if needed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason for running ocamlformat
is code readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to at least read the input type declarations to know what to feed your program. And since the pretty-printing in the backends is not ideal we run ocamlformat afterwards. @EmileRolley even calls directly ocamlformat in his new api_web
backend plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed! Just discussed the matter quickly with @EmileRolley and we agreed to disable it and focus on improving our pretty-printer on cases where readability is bad (from a quick check, it seems o.k. on type definitions). Otherwise, our pretty-printer will be completely untested: if we don't want to bother, and use OCamlformat, I'd say go all the way, simplify our pretty-printer into a bare-printer and call ocamlformat
as a lib.
What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with relying on our pretty-printer and improving it as needed, dropping ocamlformat
altogether. Using ocamlformat
as a lib is tempting but would introduce a lot of complexity as we use only a small portion of the OCaml AST. A textual pretty-printer would be simpler for maintainers to come and just change a tidbit while not having to understand everything. Plus that way we don't have to keep in sync with ocamlformat
's AST changes, while OCaml textual syntax is somewhat backwards-compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 that was our conclusion with @EmileRolley as well, even though printing and re-parsing is not very intellectually satisfying, generating an OCaml AST is totally impractical. My proposition on this point was meant as "use ocamlformat
as a lib, but still going to/from string" — which isn't really an improvement, only a workaround for the potential dependency problem.
1bfbf3e
to
d4d7491
Compare
No description provided.