Skip to content

Commit f14bc6f

Browse files
authored
Moved lower-bound to Vars.t and Selection.t (#60)
1 parent 4e161fc commit f14bc6f

11 files changed

Lines changed: 29 additions & 39 deletions

File tree

api/worker.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Vars = struct
1515
ocaml_package : string;
1616
ocaml_version : string;
1717
opam_version : string;
18+
lower_bound : bool;
1819
}
1920
[@@deriving yojson]
2021
end
@@ -29,6 +30,7 @@ module Selection = struct
2930
commits : (string * string) list; [@deriving yojson]
3031
(** The commits in each opam-repository to use. A pair of the repo URL
3132
and the commit hash*)
33+
lower_bound : bool; (** Is this a lower-bound selection? *)
3234
}
3335
[@@deriving yojson, ord]
3436
end
@@ -43,8 +45,6 @@ module Solve_request = struct
4345
pinned_pkgs : (string * string) list;
4446
(** Name and contents of other pinned opam files. *)
4547
platforms : (string * Vars.t) list; (** Possible build platforms, by ID. *)
46-
lower_bound : bool;
47-
(** Solve for the oldest possible versions instead of newest. *)
4848
}
4949
[@@deriving yojson]
5050
end

examples/main.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ let opam_template arch =
3636
|}
3737
arch
3838

39-
let get_vars ~ocaml_package_name ~ocaml_version ?arch () =
39+
let get_vars ~ocaml_package_name ~ocaml_version ?arch ?(lower_bound = false) ()
40+
=
4041
let+ vars =
4142
Solver_service.Process.pread
4243
("", [| "opam"; "config"; "expand"; opam_template arch |])
@@ -47,6 +48,7 @@ let get_vars ~ocaml_package_name ~ocaml_version ?arch () =
4748
`Assoc
4849
(("ocaml_package", `String ocaml_package_name)
4950
:: ("ocaml_version", `String ocaml_version)
51+
:: ("lower_bound", `Bool lower_bound)
5052
:: items)
5153
| json ->
5254
Fmt.failwith "Unexpected JSON: %a"
@@ -72,7 +74,6 @@ let run_client ~package ~version ~ocaml_version ~opam_commit service =
7274
root_pkgs = [ (pv, opam_file) ];
7375
pinned_pkgs = [];
7476
platforms = [ (platform.os, platform) ];
75-
lower_bound = false;
7677
}
7778
in
7879
Capnp_rpc_lwt.Capability.with_ref (job_log stderr) @@ fun log ->

examples/solve.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ let opam_template arch =
101101
|}
102102
arch
103103

104-
let get_vars ~ocaml_package_name ~ocaml_version ?arch () =
104+
let get_vars ~ocaml_package_name ~ocaml_version ?arch ?(lower_bound = false) ()
105+
=
105106
let+ vars =
106107
Lwt_process.pread ("", [| "opam"; "config"; "expand"; opam_template arch |])
107108
in
@@ -111,6 +112,7 @@ let get_vars ~ocaml_package_name ~ocaml_version ?arch () =
111112
`Assoc
112113
(("ocaml_package", `String ocaml_package_name)
113114
:: ("ocaml_version", `String ocaml_version)
115+
:: ("lower_bound", `Bool lower_bound)
114116
:: items)
115117
| json ->
116118
Fmt.failwith "Unexpected JSON: %a"

examples/submit.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ let pipeline ~cluster vars () =
110110
root_pkgs = opamfiles;
111111
pinned_pkgs = [];
112112
platforms = [ ("os", vars) ];
113-
lower_bound = false;
114113
}
115114
in
116115
let selection =

service/service.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ module Make (Opam_repo : Opam_repository_intf.S) = struct
159159
platforms;
160160
root_pkgs;
161161
pinned_pkgs;
162-
lower_bound = _;
163162
} =
164163
request
165164
in
@@ -213,7 +212,15 @@ module Make (Opam_repo : Opam_repository_intf.S) = struct
213212
~from:opam_repository_commits )
214213
>|= fun commits ->
215214
let compat_pkgs = List.map fst compatible_root_pkgs in
216-
(id, Ok { Worker.Selection.id; compat_pkgs; packages; commits }))
215+
( id,
216+
Ok
217+
{
218+
Worker.Selection.id;
219+
compat_pkgs;
220+
packages;
221+
commits;
222+
lower_bound = vars.lower_bound;
223+
} ))
217224
>|= List.filter_map (fun (id, result) ->
218225
Log.info log "= %s =" id;
219226
match result with

service/solver.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let parse_opam (name, contents) =
1212
let opam = OpamFile.OPAM.read_from_string contents in
1313
(OpamPackage.name pkg, (OpamPackage.version pkg, opam))
1414

15-
let solve ~packages ~pins ~root_pkgs ~lower_bound (vars : Worker.Vars.t) =
15+
let solve ~packages ~pins ~root_pkgs (vars : Worker.Vars.t) =
1616
let ocaml_package = OpamPackage.Name.of_string vars.ocaml_package in
1717
let ocaml_version = OpamPackage.Version.of_string vars.ocaml_version in
1818
let context =
@@ -22,7 +22,7 @@ let solve ~packages ~pins ~root_pkgs ~lower_bound (vars : Worker.Vars.t) =
2222
~test:(OpamPackage.Name.Set.of_list root_pkgs)
2323
~with_beta_remote:
2424
Ocaml_version.(Releases.is_dev (of_string_exn vars.ocaml_version))
25-
~lower_bound
25+
~lower_bound:vars.lower_bound
2626
in
2727
let t0 = Unix.gettimeofday () in
2828
let r = Solver.solve context (ocaml_package :: root_pkgs) in
@@ -64,7 +64,6 @@ let main commits =
6464
root_pkgs;
6565
pinned_pkgs;
6666
platforms;
67-
lower_bound;
6867
} =
6968
request
7069
in
@@ -79,9 +78,7 @@ let main commits =
7978
platforms
8079
|> List.iter (fun (_id, platform) ->
8180
let msg =
82-
match
83-
solve ~packages ~pins ~root_pkgs ~lower_bound platform
84-
with
81+
match solve ~packages ~pins ~root_pkgs platform with
8582
| Ok packages -> "+" ^ String.concat " " packages
8683
| Error msg -> "-" ^ msg
8784
in

stress/stress.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ let package_to_custom vars package =
2929
root_pkgs = [ (package, opamfile) ];
3030
pinned_pkgs = [];
3131
platforms = [ ("macOS", vars); ("linux", vars); ("windows", vars) ];
32-
lower_bound = false;
3332
}
3433

3534
let requests log solver =

stress/stress_submit.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ let make_requests limit =
5151
pinned_pkgs = [];
5252
platforms =
5353
[ ("macOS", vars); ("linux", vars); ("windows", vars) ];
54-
lower_bound = false;
5554
}
5655
in
5756
(request :: requests, nth + 1))

stress/utils.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ let opam_template arch =
1515
|}
1616
arch
1717

18-
let get_vars ~ocaml_package_name ~ocaml_version ?arch () =
18+
let get_vars ~ocaml_package_name ~ocaml_version ?arch ?(lower_bound = false) ()
19+
=
1920
let+ vars =
2021
Solver_service.Process.pread
2122
("", [| "opam"; "config"; "expand"; opam_template arch |])
@@ -26,6 +27,7 @@ let get_vars ~ocaml_package_name ~ocaml_version ?arch () =
2627
`Assoc
2728
(("ocaml_package", `String ocaml_package_name)
2829
:: ("ocaml_version", `String ocaml_version)
30+
:: ("lower_bound", `Bool lower_bound)
2931
:: items)
3032
| json ->
3133
Fmt.failwith "Unexpected JSON: %a"

test/test_service.ml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ let test_good_packages _sw () =
5656
root_pkgs = [];
5757
pinned_pkgs = [];
5858
platforms = [];
59-
lower_bound = false;
6059
}
6160
in
6261
let+ process =
@@ -83,7 +82,6 @@ let test_error _sw () =
8382
root_pkgs = [];
8483
pinned_pkgs = [];
8584
platforms = [];
86-
lower_bound = false;
8785
}
8886
in
8987
let+ process =
@@ -114,17 +112,12 @@ let test_e2e _sw () =
114112
root_pkgs = [ ("yaml.3.0.0", "") ];
115113
pinned_pkgs = [];
116114
platforms = [ (os_id, vars) ];
117-
lower_bound = false;
118115
}
119116
in
120117
let* service = Service.v ~n_workers:1 ~create_worker in
121-
let* response =
118+
let+ response =
122119
Solver_service_api.Solver.solve ~log:(job_log log) service req
123120
in
124-
let req_lower_bound = { req with lower_bound = true } in
125-
let+ response_lower_bound =
126-
Solver_service_api.Solver.solve ~log:(job_log log) service req_lower_bound
127-
in
128121
Alcotest.(check solver_response)
129122
"Same solve response"
130123
(Ok
@@ -134,21 +127,10 @@ let test_e2e _sw () =
134127
packages = [ "lwt.5.5.0"; "yaml.3.0.0" ];
135128
compat_pkgs = [ "yaml.3.0.0" ];
136129
commits;
130+
lower_bound = false;
137131
};
138132
])
139-
response;
140-
Alcotest.(check solver_response)
141-
"Same solve response lower bound"
142-
(Ok
143-
[
144-
{
145-
id = os_id;
146-
packages = [ "lwt.5.5.0"; "yaml.3.0.0" ];
147-
compat_pkgs = [ "yaml.3.0.0" ];
148-
commits;
149-
};
150-
])
151-
response_lower_bound
133+
response
152134

153135
let tests =
154136
Alcotest_lwt.

0 commit comments

Comments
 (0)