Skip to content
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

Test opam constraints of multi-package repositories separately #257

Open
craigfe opened this issue Oct 14, 2020 · 3 comments
Open

Test opam constraints of multi-package repositories separately #257

craigfe opened this issue Oct 14, 2020 · 3 comments

Comments

@craigfe
Copy link
Member

craigfe commented Oct 14, 2020

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:

  • missing external dependencies may be ignored by OCaml-CI, if those dependencies are introduced by another package in the same repository (e.g. irmin-pack and irmin-git both depend on alcotest, but this dependency is missing from irmin-git.opam);

  • missing internal dependencies will always be ignored by OCaml-CI, since those dependencies are always available in the test switch by default.

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 mirage/repr#12). This is the major reason that we still have Travis CI running (very slowly) on certain mirage/ repositories.

CC @avsm.

@craigfe craigfe changed the title Test opam constraints separately Test opam constraints of multi-package repositories separately Oct 14, 2020
@talex5
Copy link
Contributor

talex5 commented Oct 14, 2020

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: ocaml/dune#3727)

@craigfe
Copy link
Member Author

craigfe commented Oct 14, 2020

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. ocaml/dune#3770, ocaml/dune#3653, ocaml/dune#3497.)

@talex5
Copy link
Contributor

talex5 commented Dec 15, 2020

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants