ocurrent/ocaml-ci

OCaml-CI should search for `opam` file names in pin-depends or vendored git submodules

MisterDA opened this issue · 0 comments

For a package foo, Dune expects or creates a foo.opam file containing the opam package description. ocaml-ci looks for these files, and will also look for opam/foo.opam.

let read_opam_file ~job ~repo ~hash pkg =
let opam_filename = OpamPackage.name_to_string pkg ^ ".opam" in
Cmd.git_show ~job ~repo hash opam_filename >>= function
| Ok contents -> Lwt_result.return contents
| Error (`Msg msg) -> (
Cmd.git_show ~job ~repo hash ("opam/" ^ opam_filename) >>= function
| Ok contents -> Lwt_result.return contents
| Error _ ->
Lwt.return
@@ Fmt.error_msg "Can't find %s (or opam/%s): %s" opam_filename
opam_filename msg)

ocaml-ci/lib/pin_depends.ml

Lines 140 to 144 in e12b7dc

let read_opam_file ~tarball ~prefix pkg =
let opam_filename = prefix ^ "/" ^ OpamPackage.name_to_string pkg ^ ".opam" in
let opam_filename' =
prefix ^ "/opam/" ^ OpamPackage.name_to_string pkg ^ ".opam"
in

Historically, or for projects not using the Dune build system (brr, topkg, Oasis, Makefiles…), the opam file is simply named opam.
Although ocaml-ci won't work on these projects (as it calls Dune directly and not opam), it should work with these projects being pinned using opam, or vendored: the pin-depends or vendored might carry patches or features necessary for the root project.

This shouldn't be super hard and could also be a nice little case for refactoring a piece of code. I suggest making sure that ocaml-ci stops looking for opam files as soon as the first conforming file is found.