Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/analyse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ let make_placeholder_selections ~platforms ~opam_repository_commits =
{
Selection.variant = fst platform;
packages = [];
only_packages = [];
commits =
List.map
(fun y ->
Expand Down Expand Up @@ -196,12 +197,11 @@ module Analysis = struct
None

(** If the opam file for the given root_pkgs includes a build command, use
that instead of the default (dune build @install @runtests). This is
put into Selection.command to be picked up by the build phase.
that instead of the default (dune build \@install \@runtests). This is put
into Selection.command to be picked up by the build phase.

This is only implemented if root_pkgs is a singleton, otherwise we
fall back to the default build command.
*)
This is only implemented if root_pkgs is a singleton, otherwise we fall
back to the default build command. *)
let maybe_add_build_command ~root_pkgs selection =
match root_pkgs with
| [ (pkg_name, opam_str) ] ->
Expand All @@ -211,6 +211,7 @@ module Analysis = struct
{
Selection.variant = selection.Selection.variant;
packages = selection.packages;
only_packages = selection.only_packages;
commits = selection.commits;
command;
}
Expand Down Expand Up @@ -283,7 +284,9 @@ module Analysis = struct
Capnp_rpc_lwt.Capability.with_ref (job_log job) @@ fun log ->
Backend_solver.solve solver job request ~log >|= function
| Ok [] -> Fmt.error_msg "No solution found for any supported platform"
| Ok x -> Ok (List.map Selection.of_worker x)
| Ok x ->
let root_pkgs = List.map fst root_pkgs in
Ok (List.map (Selection.of_worker ~root_pkgs) x)
| Error (`Msg msg) -> Fmt.error_msg "Error from solver: %s" msg

let find_opam_files ~job ~dir =
Expand Down
8 changes: 7 additions & 1 deletion lib/opam_build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,16 @@ let spec_script ~repo ~base ~opam_files ~compiler_commit ~selection ~cmds =
~cmds:(run_all_opam_exec cmds)

let spec_dune ~repo ~base ~opam_files ~compiler_commit ~selection =
let only_packages =
let to_name x = OpamPackage.of_string x |> OpamPackage.name_to_string in
match selection.Selection.only_packages with
| [] -> ""
| pkgs -> " --only-packages=" ^ String.concat "," (List.map to_name pkgs)
in
let cmd =
match selection.Selection.command with
| Some c -> c
| None -> "dune build @install @runtest"
| None -> Printf.sprintf "dune build%s @install @runtest" only_packages
in
let cmds = [ "opam install dune"; cmd ^ " && rm -rf _build" ] in
spec_script ~repo ~base ~opam_files ~compiler_commit ~selection ~cmds
Expand Down
12 changes: 8 additions & 4 deletions lib/selection.ml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
type t = {
variant : Variant.t; (** The variant image to build on. *)
packages : string list; (** The selected packages ("name.version"). *)
only_packages : string list; [@default []]
(** Local root packages to include (empty to include all). *)
commits : (string * string) list;
(** The list of (repo_url,commit) opam-repositories from the analysis, and
they're all usefull during the build.*)
command : string option;
(** The build command to use (will default to dune build @install @runtest if not specified) *)
(** The build command to use (will default to dune build \@install
\@runtest if not specified) *)
}
[@@deriving yojson, ord]
(** A set of packages for a single build. *)

let of_worker w =
let of_worker ~root_pkgs w =
let module W = Ocaml_multicore_ci_api.Worker.Selection in
let { W.id; packages; commits; _ } = w in
let { W.id; packages; commits; compat_pkgs } = w in
let variant = Variant.of_string id in
let only_packages = if root_pkgs = compat_pkgs then [] else compat_pkgs in
let commits = commits in
{ variant; packages; commits; command = None }
{ variant; packages; only_packages; commits; command = None }

let remove_package t ~package =
{
Expand Down
9 changes: 7 additions & 2 deletions lib/selection.mli
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
type t = {
variant : Variant.t; (** The variant image to build on. *)
packages : string list; (** The selected packages ("name.version"). *)
only_packages : string list; [@default []]
(** Local root packages to include (empty to include all). *)
commits : (string * string) list;
(** The list of (repo_url,commit) opam-repositories from the analysis, and
they're all usefull during the build.*)
command : string option;
(** The build command to use (will default to dune build @install @runtest if not specified) *)
(** The build command to use (will default to dune build \@install
\@runtest if not specified) *)
}
[@@deriving yojson, ord]
(** A set of packages for a single build. *)

val of_worker : Ocaml_multicore_ci_api.Worker.Selection.t -> t
val of_worker :
root_pkgs:string list -> Ocaml_multicore_ci_api.Worker.Selection.t -> t

val remove_package : t -> package:string -> t