Skip to content

Commit

Permalink
PRO-621 REFACTOR Reduce spurious error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitz committed Nov 25, 2024
1 parent 01150d0 commit 582aea3
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 62 deletions.
124 changes: 69 additions & 55 deletions code/src/terrat/terrat_evaluator3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,7 @@ module Make (S : S) = struct
(fun () ->
query_work_manifest state.State.request_id ctx.Ctx.storage work_manifest_id
>>= function
| Some ({ Wm.state = Wm.State.(Queued | Running); _ } as work_manifest) -> (
| Some ({ Wm.state = Wm.State.(Queued | Running | Aborted); _ } as work_manifest) -> (
let open Abb.Future.Infix_monad in
result ctx state req work_manifest
>>= function
Expand Down Expand Up @@ -3030,7 +3030,7 @@ module Make (S : S) = struct
work_manifest_id);
Abb.Future.return (Error `Failure))
~finally:(fun () -> Abb.Future.Promise.set p (Ok ()))
| _, Some (I.Work_manifest_failure { p }), Some work_manifest_id ->
| st, Some (I.Work_manifest_failure { p }), Some work_manifest_id ->
Logs.info (fun m ->
m
"EVALUATOR : %s : WORK_MANIFEST_ITER : %s : WORK_MANIFEST_FAILURE : id=%a"
Expand All @@ -3042,15 +3042,23 @@ module Make (S : S) = struct
(fun () ->
query_work_manifest state.State.request_id ctx.Ctx.storage work_manifest_id
>>= function
| Some ({ Wm.state = Wm.State.(Queued | Running); _ } as work_manifest) ->
| Some ({ Wm.state = Wm.State.(Queued | Running); _ } as work_manifest) -> (
update_work_manifest_state
state.State.request_id
ctx.Ctx.storage
work_manifest_id
Wm.State.Aborted
>>= fun () ->
run_failure ctx state `Error work_manifest
>>= fun () -> Abb.Future.return (Error (`Noop state))
>>= fun () ->
(* If we're waiting for the result, then yield, we want to
store the result when we (hopefully) receive it. *)
match st with
| St.Waiting_for_work_manifest_result -> Abb.Future.return (Error (`Yield state))
| _ -> Abb.Future.return (Error (`Noop state)))
| Some { Wm.state = Wm.State.Aborted; _ }
when st = St.Waiting_for_work_manifest_result ->
Abb.Future.return (Error (`Yield state))
| Some _ -> Abb.Future.return (Error (`Noop state))
| None ->
Logs.err (fun m ->
Expand Down Expand Up @@ -4085,32 +4093,36 @@ module Make (S : S) = struct
work_manifest.Wm.id
result
>>= fun () ->
run_interactive ctx state (fun () ->
Dv.pull_request ctx state
>>= fun pull_request ->
create_op_commit_checks_of_result
state.State.request_id
ctx.Ctx.config
client
work_manifest.Wm.account
(S.Pull_request.repo pull_request)
(S.Pull_request.branch_ref pull_request)
work_manifest
work_manifest_result
>>= fun () ->
publish_msg
state.State.request_id
client
(Event.user state.State.event)
pull_request
(Msg.Tf_op_result2
{
config = ctx.Ctx.config;
is_layered_run = CCList.length matches.Dv.Matches.all_matches > 1;
remaining_layers = matches.Dv.Matches.all_unapplied_matches;
result;
work_manifest;
}))
(if work_manifest.Wm.state <> Wm.State.Aborted then
(* In the case of an abort, we do not report back to the user, we
just want to store the results. *)
run_interactive ctx state (fun () ->
Dv.pull_request ctx state
>>= fun pull_request ->
create_op_commit_checks_of_result
state.State.request_id
ctx.Ctx.config
client
work_manifest.Wm.account
(S.Pull_request.repo pull_request)
(S.Pull_request.branch_ref pull_request)
work_manifest
work_manifest_result
>>= fun () ->
publish_msg
state.State.request_id
client
(Event.user state.State.event)
pull_request
(Msg.Tf_op_result2
{
config = ctx.Ctx.config;
is_layered_run = CCList.length matches.Dv.Matches.all_matches > 1;
remaining_layers = matches.Dv.Matches.all_unapplied_matches;
result;
work_manifest;
}))
else Abb.Future.return (Ok ()))
>>= fun () ->
if not work_manifest_result.Work_manifest_result.overall_success then
(* If the run failed, then we're done. *)
Expand All @@ -4128,31 +4140,33 @@ module Make (S : S) = struct
work_manifest.Wm.id
result
>>= fun () ->
run_interactive ctx state (fun () ->
Dv.pull_request ctx state
>>= fun pull_request ->
create_op_commit_checks_of_result
state.State.request_id
ctx.Ctx.config
client
work_manifest.Wm.account
(S.Pull_request.repo pull_request)
(S.Pull_request.branch_ref pull_request)
work_manifest
work_manifest_result
>>= fun () ->
publish_msg
state.State.request_id
client
(Event.user state.State.event)
pull_request
(Msg.Tf_op_result
{
is_layered_run = CCList.length matches.Dv.Matches.all_matches > 1;
remaining_layers = matches.Dv.Matches.all_unapplied_matches;
result;
work_manifest;
}))
(if work_manifest.Wm.state <> Wm.State.Aborted then
run_interactive ctx state (fun () ->
Dv.pull_request ctx state
>>= fun pull_request ->
create_op_commit_checks_of_result
state.State.request_id
ctx.Ctx.config
client
work_manifest.Wm.account
(S.Pull_request.repo pull_request)
(S.Pull_request.branch_ref pull_request)
work_manifest
work_manifest_result
>>= fun () ->
publish_msg
state.State.request_id
client
(Event.user state.State.event)
pull_request
(Msg.Tf_op_result
{
is_layered_run = CCList.length matches.Dv.Matches.all_matches > 1;
remaining_layers = matches.Dv.Matches.all_unapplied_matches;
result;
work_manifest;
}))
else Abb.Future.return (Ok ()))
>>= fun () ->
if not work_manifest_result.Work_manifest_result.overall_success then
(* If the run failed, then we're done. *)
Expand Down
18 changes: 11 additions & 7 deletions code/src/terrat_ui_js/terrat_ui_js_comp_runs_detail.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module Output_treeview = Brtl_js2_treeview.Make (struct
let class' = "treeview"

let fetch_outputs client installation_id work_manifest_id query =
let module O = Terrat_api_components.Installation_workflow_step_output in
let open Abb_js_future_combinators.Infix_result_monad in
Terrat_ui_js_client.work_manifest_outputs
~limit:100
Expand Down Expand Up @@ -402,13 +403,16 @@ module Output_treeview = Brtl_js2_treeview.Make (struct
Ok Brtl_js2.Brr.El.[ div ~at:At.[ class' (Jstr.v "text") ] [ pre [ txt' text ] ] ]

let render_payload_any payload =
let code_el = Brtl_js2.Brr.El.code [] in
let code_el_js = Brtl_js2.Brr.El.to_jv code_el in
let code =
Hljs.highlight (Hljs.Opts.make ~language:"json" ()) (Yojson.Safe.pretty_to_string payload)
in
Jv.set code_el_js "innerHTML" (Jv.of_string code);
Brtl_js2.Brr.El.[ pre [ code_el ] ]
match payload with
| `Assoc [] -> Brtl_js2.Brr.El.[]
| payload ->
let code_el = Brtl_js2.Brr.El.code [] in
let code_el_js = Brtl_js2.Brr.El.to_jv code_el in
let code =
Hljs.highlight (Hljs.Opts.make ~language:"json" ()) (Yojson.Safe.pretty_to_string payload)
in
Jv.set code_el_js "innerHTML" (Jv.of_string code);
Brtl_js2.Brr.El.[ pre [ code_el ] ]

let render_payload step payload =
let run =
Expand Down

0 comments on commit 582aea3

Please sign in to comment.