Skip to content

Commit

Permalink
PRO-557 #72 REFACTOR Update libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitz committed Dec 5, 2024
1 parent cc6d11b commit 1f9f187
Show file tree
Hide file tree
Showing 10 changed files with 573 additions and 345 deletions.
2 changes: 1 addition & 1 deletion code/.ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.26.2
version=0.27.0
profile = default
break-cases = fit-or-vertical
break-fun-decl = fit-or-vertical
Expand Down
2 changes: 1 addition & 1 deletion code/hll.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fmt = ["logs.fmt"]
ipaddr = ["ipaddr.unix"]
logs = ["logs.cli"]
mirage-crypto-rng = ["mirage-crypto-rng.unix"]
mtime = ["mtime.clock.os"]
mtime = ["mtime.clock"]
ocaml-compiler-libs = ["compiler-libs.common", "ocaml-compiler-libs.common", "ocaml-compiler-libs.shadow"]
ppx_deriving = ["ppx_deriving.show", "ppx_deriving.eq", "ppx_deriving.ord", "ppx_deriving.make"]
sedlex = ["sedlex.ppx"]
Expand Down
88 changes: 80 additions & 8 deletions code/pds.conf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@ deps = ["abb_intf", "abb_channel", "abb_future_combinators"]

[src.abb_dns]
install = true
deps = ["abb_future_combinators", "abb_intf", "abb_io", "cstruct", "dns-client", "dns-client.resolvconf", "logs", "mirage-crypto-rng.unix", "mtime", "mtime.clock.os"]
deps = [
"abb_future_combinators",
"abb_intf",
"abb_io",
"cstruct",
"dns-client",
"dns-client.resolvconf",
"logs",
"mirage-crypto-rng.unix",
"mtime",
"mtime.clock"
]

[src.abb_flow]
install = true
Expand Down Expand Up @@ -117,19 +128,54 @@ build = false

[src.abb_scheduler_kqueue.selector.freebsd]
build = true
deps = ["abb_fut", "abb_intf", "abb_thread_pool", "containers", "iter", "kqueue", "mtime.clock.os", "ppx_deriving", "ppx_deriving.ord", "unix"]
deps = [
"abb_fut",
"abb_intf",
"abb_thread_pool",
"containers",
"iter",
"kqueue",
"mtime",
"mtime.clock",
"ppx_deriving",
"ppx_deriving.ord",
"unix"
]

[src.abb_scheduler_kqueue.selector.linux]
build = true
deps = ["abb_fut", "abb_intf", "abb_thread_pool", "containers", "iter", "kqueue", "mtime.clock.os", "ppx_deriving", "ppx_deriving.ord", "unix"]
deps = [
"abb_fut",
"abb_intf",
"abb_thread_pool",
"containers",
"iter",
"kqueue",
"mtime",
"mtime.clock",
"ppx_deriving",
"ppx_deriving.ord",
"unix"
]

[src.abb_scheduler_nyi]
install = false
deps = ["abb_intf", "abb_fut"]

[src.abb_scheduler_select]
install = true
deps = ["abb_fut", "abb_intf", "abb_thread_pool", "containers", "iter", "mtime.clock.os", "ppx_deriving", "ppx_deriving.ord", "unix"]
deps = [
"abb_fut",
"abb_intf",
"abb_thread_pool",
"containers",
"iter",
"mtime",
"mtime.clock",
"ppx_deriving",
"ppx_deriving.ord",
"unix"
]

[src.abb_service_local]
install = true
Expand Down Expand Up @@ -187,7 +233,17 @@ deps = ["abb", "abb_tls"]

[src.brtl]
install = true
deps = ["abb_intf", "abbs", "cohttp_abb", "hmap", "logs", "snabela", "uri", "uuidm", "yojson"]
deps = [
"abb_intf",
"abbs",
"cohttp_abb",
"hmap",
"logs",
"ouuid",
"snabela",
"uri",
"yojson"
]

[src.brtl_ep]
install = true
Expand All @@ -200,7 +256,19 @@ deps = ["abb", "brtl", "brtl_mw_log", "containers", "logs", "logs.fmt"]

[src.brtl_js]
install = true
deps = ["abb_js", "furi", "js_of_ocaml", "js_of_ocaml-ppx", "js_of_ocaml-tyxml", "ppx_deriving", "ppx_deriving.ord", "react", "reactiveData", "uri", "uuidm"]
deps = [
"abb_js",
"furi",
"js_of_ocaml",
"js_of_ocaml-ppx",
"js_of_ocaml-tyxml",
"ouuid",
"ppx_deriving",
"ppx_deriving.ord",
"react",
"reactiveData",
"uri",
]

[src.brtl_js2]
install = true
Expand Down Expand Up @@ -419,6 +487,10 @@ install = false
type = "exec"
deps = ["ctypes", "ctypes.foreign", "ctypes.stubs", "otls_bindings"]

[src.ouuid]
install = false
deps = ["uuidm"]

[src.pds_excise]
type = "exec"
project_type = "third-party"
Expand Down Expand Up @@ -523,6 +595,7 @@ deps = [
"lua_pattern",
"mirage-crypto-pk",
"mirage-crypto-rng.unix",
"ouuid",
"path_glob",
"pgsql_pagination",
"pgsql_pool",
Expand Down Expand Up @@ -553,7 +626,6 @@ deps = [
"terrat_work_manifest3",
"terratc_intf",
"tsort",
"uuidm",
"x509",
]

Expand Down Expand Up @@ -796,7 +868,7 @@ deps = ["oth", "abb_fut", "abb_channel", "abb_service_local"]
deps = ["unix", "oth", "abb_thread_pool"]

[tests.abb_time]
deps = ["unix", "mtime.clock.os", "oth", "abb_time"]
deps = ["unix", "mtime", "mtime.clock", "oth", "abb_time"]

[tests.abb_tls]
deps = ["containers", "uri", "abb_scheduler_select", "abb_tls", "cohttp_abb"]
Expand Down
2 changes: 1 addition & 1 deletion code/src/brtl/brtl_ctx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let create remote_addr request =
body = ();
response = ();
remote_addr;
token = Uuidm.(to_string ~upper:false (v `V4));
token = Ouuid.(to_string ~upper:false (v4 ()));
}

let uri t =
Expand Down
2 changes: 1 addition & 1 deletion code/src/brtl_js/brtl_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module Router_output = struct
| Some mtch ->
let with_cleanup = ref None in
let prev_match = ref mtch in
let id = Uuidm.to_string (Uuidm.v `V4) in
let id = Ouuid.to_string (Ouuid.v4 ()) in
let iter =
React.S.fmap
(fun uri ->
Expand Down
3 changes: 3 additions & 0 deletions code/src/ouuid/ouuid.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let v4 = Uuidm.v4_gen (Random.State.make_self_init ())
let to_string = Uuidm.to_string
let of_string = Uuidm.of_string
3 changes: 3 additions & 0 deletions code/src/ouuid/ouuid.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
val v4 : unit -> Uuidm.t
val to_string : ?upper:bool -> Uuidm.t -> string
val of_string : ?pos:int -> string -> Uuidm.t option
67 changes: 36 additions & 31 deletions code/src/terrat/terrat_evaluator3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1760,8 +1760,8 @@ module Make (S : S) = struct
let deny =
CCList.filter
(fun Terrat_access_control.R.Deny.
{ change_match = { Terrat_change_match3.Dirspace_config.dirspace; _ }; _ } ->
not (Dirspace_map.mem dirspace superapproved))
{ change_match = { Terrat_change_match3.Dirspace_config.dirspace; _ }; _ }
-> not (Dirspace_map.mem dirspace superapproved))
deny
in
Abb.Future.return (Ok Terrat_access_control.R.{ pass; deny })
Expand Down Expand Up @@ -2424,7 +2424,8 @@ module Make (S : S) = struct
_;
};
_;
} ->
}
->
autoplan
&& ((not (S.Pull_request.is_draft_pr pull_request)) || autoplan_draft_pr))
working_set_matches
Expand All @@ -2440,7 +2441,8 @@ module Make (S : S) = struct
Terrat_change_match3.Dirspace_config.when_modified =
{ Terrat_base_repo_config_v1.When_modified.autoapply; _ };
_;
} -> autoapply)
}
-> autoapply)
working_set_matches
in
Abb.Future.return
Expand Down Expand Up @@ -2596,7 +2598,8 @@ module Make (S : S) = struct
Abb.Future.return
(Ok
(CCList.map
(fun Terrat_change.{ Dirspaceflow.dirspace = Dirspace.{ dir; workspace }; workflow } ->
(fun Terrat_change.{ Dirspaceflow.dirspace = Dirspace.{ dir; workspace }; workflow }
->
Terrat_api_components.Work_manifest_dir.
{
path = dir;
Expand Down Expand Up @@ -2807,12 +2810,12 @@ module Make (S : S) = struct
Abb.Future.return
(Error
(`Clone
( {
state with
State.st = St.Waiting_for_work_manifest_run;
work_manifest_id = Some self.Wm.id;
},
states_of_work_manifests work_manifests ))))
( {
state with
State.st = St.Waiting_for_work_manifest_run;
work_manifest_id = Some self.Wm.id;
},
states_of_work_manifests work_manifests ))))
| St.Initial, None, Some work_manifest_id -> (
Logs.info (fun m ->
m
Expand Down Expand Up @@ -2852,8 +2855,8 @@ module Make (S : S) = struct
Abb.Future.return
(Error
(`Clone
( { state with State.st = St.Waiting_for_work_manifest_initiate },
states )))
( { state with State.st = St.Waiting_for_work_manifest_initiate },
states )))
| _ :: _, _ -> assert false))
| Some { Wm.id; state = state'; _ } ->
Logs.err (fun m ->
Expand Down Expand Up @@ -2898,7 +2901,7 @@ module Make (S : S) = struct
Abb.Future.return
(Error
(`Yield
{ state with State.st = St.Waiting_for_work_manifest_initiate; input = None }))
{ state with State.st = St.Waiting_for_work_manifest_initiate; input = None }))
| Some { Wm.id; state = state'; _ } ->
Logs.err (fun m ->
m
Expand Down Expand Up @@ -2951,11 +2954,11 @@ module Make (S : S) = struct
| ( St.Waiting_for_work_manifest_initiate,
Some
(I.Work_manifest_initiate
{
encryption_key;
initiate = { Terrat_api_components.Work_manifest_initiate.run_id; sha };
p;
}),
{
encryption_key;
initiate = { Terrat_api_components.Work_manifest_initiate.run_id; sha };
p;
}),
Some work_manifest_id ) -> (
Logs.info (fun m ->
m
Expand All @@ -2978,12 +2981,12 @@ module Make (S : S) = struct
Abb.Future.return
(Error
(`Yield
{
state with
State.st = St.Waiting_for_work_manifest_result;
output = None;
input = None;
}))
{
state with
State.st = St.Waiting_for_work_manifest_result;
output = None;
input = None;
}))
| None -> Abb.Future.return (Error (`Noop state)))
| Some { Wm.id; state = Wm.State.Aborted; _ } ->
Logs.info (fun m ->
Expand Down Expand Up @@ -3243,7 +3246,7 @@ module Make (S : S) = struct
(Cstruct.to_string
(Mirage_crypto.Hash.SHA256.hmac
~key:encryption_key
(Cstruct.of_string (Uuidm.to_string id))))
(Cstruct.of_string (Ouuid.to_string id))))

let generate_index_work_manifest_initiate ctx state encryption_key run_id sha work_manifest =
let module Wm = Terrat_work_manifest3 in
Expand Down Expand Up @@ -3618,7 +3621,8 @@ module Make (S : S) = struct
branch_ref,
working_branch_ref,
matches,
access_control_results ) ->
access_control_results )
->
let { Terrat_access_control.R.pass = passed_dirspaces; deny = denied_dirspaces } =
access_control_results
in
Expand Down Expand Up @@ -3732,7 +3736,8 @@ module Make (S : S) = struct
branch_ref,
working_branch_ref,
matches,
access_control_results ) ->
access_control_results )
->
let { Terrat_access_control.R.pass = passed_dirspaces; deny = denied_dirspaces } =
access_control_results
in
Expand Down Expand Up @@ -5498,7 +5503,7 @@ module Make (S : S) = struct
| [] -> Abb.Future.return (Error (`Noop state))
| self :: needed_runs ->
let f (account, repo) =
let request_id = Uuidm.to_string (Uuidm.v `V4) in
let request_id = Ouuid.to_string (Ouuid.v4 ()) in
Logs.info (fun m ->
m
"EVALUATOR : %s : DRIFT : request_id=%s : account=%s : repo=%s"
Expand Down Expand Up @@ -6250,7 +6255,7 @@ module Make (S : S) = struct
example when emitting a value or running a work manifest. So we always
create a new request ID before resuming a run, ensuring it gets a
unique value. *)
let request_id' = Uuidm.to_string (Uuidm.v `V4) in
let request_id' = Ouuid.to_string (Ouuid.v4 ()) in
Abbs_future_combinators.with_finally
(fun () ->
Logs.info (fun m ->
Expand Down Expand Up @@ -6283,7 +6288,7 @@ module Make (S : S) = struct
immediately resumed from where they left off. *)
Abbs_future_combinators.List.iter
~f:(fun state ->
let request_id = Uuidm.to_string (Uuidm.v `V4) in
let request_id = Ouuid.to_string (Ouuid.v4 ()) in
Logs.info (fun m ->
m "EVALUATOR : %s : CLONE : request_id=%s" state.State.request_id request_id);
let state = { state with State.request_id; input = None; output = None } in
Expand Down
Loading

0 comments on commit 1f9f187

Please sign in to comment.