ocurrent / ocaml-ci

A CI for OCaml projects
https://ocaml.ci.dev
MIT License
111 stars 74 forks source link

Test opam constraints of multi-package repositories separately #257

Open craigfe opened 4 years ago

craigfe commented 4 years ago

OCaml-CI's current strategy for running tests of multi-package repositories is to first pin all of the packages and then install them all in the same switch and run dune runtest. This approach has two undesirable consequences:

It would be nice to have some CI solution that still tests that the opam metadata corresponds to the true project dependencies, as otherwise this becomes an issue that is only discovered at the point of release (see https://github.com/mirage/repr/pull/12). This is the major reason that we still have Travis CI running (very slowly) on certain mirage/ repositories.

CC @avsm.

talex5 commented 4 years ago

I think the solution to this is:

  1. Use dune to generate the opam files.
  2. Make sure dune generates them correctly.

Dune knows which libraries go in each package, and which other libraries they depend on. It also knows which opam package those libraries are from. It should therefore be able to warn you if you fail to declare a dependency on an internal or external library.

(dune already added a check for the related problem of depending on another package using its internal name: https://github.com/ocaml/dune/issues/3727)

craigfe commented 4 years ago

For dune to solve this issue completely, it would need to also consider the cases of cyclic dependencies (annotated with post) and the distinction between test dependencies and normal dependencies. It seems to me that these are ultimately Opam's problem.

Also note that Dune's support for opam file generation is quite limited at the moment, often requiring us to use the .template fallback. These limitations would need to be lifted in order for Dune to become the real solution here. (c.f. https://github.com/ocaml/dune/issues/3770, https://github.com/ocaml/dune/issues/3653, https://github.com/ocaml/dune/issues/3497.)

talex5 commented 3 years ago

I've made a separate linter that should help with this: https://github.com/talex5/dune-opam-lint/ It's currently enabled for testing (in #285).

It works by checking that every entry in your dune file has the corresponding opam package listed in the package's opam file. It's not quite the same as installing each package separately, but it will catch some cases that doesn't (e.g. a transitive dependency that works today but may disappear later).

It doesn't check internal dependencies at the moment, but dune can do that itself if generating the opam files (strict_package_deps).