2020-12-02 13:33:15 +00:00
|
|
|
open Tyxml.Html
|
|
|
|
|
2020-12-07 09:17:49 +00:00
|
|
|
let txtf fmt = Fmt.kstrf txt fmt
|
2020-12-07 15:45:19 +00:00
|
|
|
let a_titlef fmt = Fmt.kstrf a_title fmt
|
2020-12-07 09:17:49 +00:00
|
|
|
|
2020-12-07 15:45:19 +00:00
|
|
|
let check_icon result =
|
|
|
|
match result with
|
|
|
|
| Builder.Exited 0 ->
|
|
|
|
span ~a:[
|
2020-12-07 20:34:10 +00:00
|
|
|
a_style "color: green; cursor: pointer;";
|
2020-12-07 15:45:19 +00:00
|
|
|
a_titlef "%a" Builder.pp_execution_result result;
|
|
|
|
]
|
2020-12-07 15:33:19 +00:00
|
|
|
[txt "☑"]
|
2020-12-07 15:45:19 +00:00
|
|
|
| _ ->
|
|
|
|
span ~a:[
|
2020-12-07 20:34:10 +00:00
|
|
|
a_style "color: red; cursor: pointer;";
|
2020-12-07 15:45:19 +00:00
|
|
|
a_titlef "%a" Builder.pp_execution_result result;
|
|
|
|
]
|
2020-12-07 15:33:19 +00:00
|
|
|
[txt "☒"]
|
|
|
|
|
2020-12-02 13:33:15 +00:00
|
|
|
let layout ~title:title_ body_ =
|
|
|
|
html
|
|
|
|
(head (title (txt title_))
|
2020-12-07 16:22:32 +00:00
|
|
|
[style ~a:[a_mime_type "text/css"]
|
|
|
|
[
|
2020-12-09 12:45:09 +00:00
|
|
|
txt "body {\
|
|
|
|
margin: 40px auto;\
|
|
|
|
line-height: 1.6;\
|
|
|
|
color: #444;\
|
|
|
|
padding: 0 10px;\
|
|
|
|
}";
|
|
|
|
txt "h1,h2,h3{line-height:1.2}";
|
2020-12-09 10:39:39 +00:00
|
|
|
txt ".output-ts {\
|
|
|
|
white-space: nowrap;\
|
|
|
|
cursor: pointer;\
|
|
|
|
user-select: none;\
|
|
|
|
}";
|
2020-12-09 12:45:09 +00:00
|
|
|
txt ".output-ts a {text-decoration: none;}";
|
|
|
|
txt ".output-ts a:hover {text-decoration: underline;}";
|
|
|
|
txt ".output-code {\
|
|
|
|
overflow: visible;\
|
|
|
|
white-space: pre;\
|
|
|
|
}";
|
2020-12-21 10:22:35 +00:00
|
|
|
txt ".toggleable {\
|
|
|
|
display: none;\
|
|
|
|
}";
|
|
|
|
txt ".toggleable-descr {\
|
|
|
|
cursor: pointer;\
|
|
|
|
text-decoration: underline;\
|
|
|
|
user-select: none;\
|
|
|
|
}";
|
|
|
|
txt ":checked + .toggleable {\
|
|
|
|
display: block;\
|
|
|
|
}";
|
2020-12-07 16:22:32 +00:00
|
|
|
]])
|
2020-12-02 13:33:15 +00:00
|
|
|
(body body_)
|
|
|
|
|
2020-12-21 10:22:35 +00:00
|
|
|
let toggleable ?(hidden=true) id description content =
|
|
|
|
let checked = if hidden then [] else [a_checked ()] in
|
|
|
|
div [
|
|
|
|
label
|
|
|
|
~a:[
|
|
|
|
a_label_for id;
|
|
|
|
a_class ["toggleable-descr"];
|
|
|
|
]
|
|
|
|
[txt description];
|
|
|
|
input
|
|
|
|
~a:(checked @ [
|
|
|
|
a_input_type `Checkbox;
|
|
|
|
a_id id;
|
|
|
|
a_style "display: none;";
|
|
|
|
]) ();
|
|
|
|
div
|
|
|
|
~a:[
|
|
|
|
a_class ["toggleable"]
|
|
|
|
]
|
|
|
|
content;
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-12-02 13:33:15 +00:00
|
|
|
let builder jobs =
|
|
|
|
layout ~title:"Builder Web"
|
|
|
|
[ h1 [txt "Builder web"];
|
2021-02-02 16:23:57 +00:00
|
|
|
form ~a:[a_action "/hash"; a_method `Get]
|
|
|
|
[
|
|
|
|
label [
|
|
|
|
txt "Search artifact by SHA256";
|
|
|
|
br ();
|
|
|
|
input ~a:[
|
|
|
|
a_input_type `Search;
|
|
|
|
a_id "sha256";
|
|
|
|
a_name "sha256";
|
|
|
|
] ();
|
|
|
|
];
|
|
|
|
input ~a:[
|
|
|
|
a_input_type `Submit;
|
|
|
|
a_value "Search";
|
|
|
|
] ();
|
|
|
|
];
|
2020-12-02 13:33:15 +00:00
|
|
|
p [
|
2020-12-07 09:17:49 +00:00
|
|
|
txtf "We have currently %d jobs."
|
|
|
|
(List.length jobs);
|
2020-12-02 13:33:15 +00:00
|
|
|
];
|
2021-01-29 13:34:56 +00:00
|
|
|
ul (List.map (fun (job_name, latest_build, latest_artifact) ->
|
|
|
|
li ([
|
|
|
|
a ~a:[a_href ("job/" ^ job_name ^ "/")]
|
|
|
|
[txt job_name];
|
|
|
|
txt " ";
|
|
|
|
check_icon latest_build.Builder_db.Build.Meta.result;
|
|
|
|
br ();
|
|
|
|
a ~a:[a_href (Fmt.strf "job/%s/build/%a/" job_name Uuidm.pp
|
|
|
|
latest_build.Builder_db.Build.Meta.uuid)]
|
|
|
|
[txtf "%a" (Ptime.pp_human ()) latest_build.Builder_db.Build.Meta.start];
|
|
|
|
txt " ";
|
|
|
|
] @ match latest_artifact with
|
|
|
|
| Some main_binary ->
|
|
|
|
[
|
|
|
|
a ~a:[a_href (Fmt.strf
|
|
|
|
"job/%s/build/%a/f/%a"
|
|
|
|
job_name
|
|
|
|
Uuidm.pp latest_build.Builder_db.Build.Meta.uuid
|
|
|
|
Fpath.pp main_binary.Builder_db.filepath)]
|
|
|
|
[txtf "%s" (Fpath.basename main_binary.Builder_db.filepath)];
|
|
|
|
txt " ";
|
|
|
|
code [txtf "SHA256:%a" Hex.pp (Hex.of_cstruct main_binary.Builder_db.sha256)];
|
|
|
|
]
|
|
|
|
| None ->
|
|
|
|
[
|
|
|
|
txtf "Build failed";
|
|
|
|
]))
|
|
|
|
jobs);
|
2020-12-02 13:33:15 +00:00
|
|
|
]
|
2020-12-07 09:17:49 +00:00
|
|
|
|
2021-01-08 12:47:17 +00:00
|
|
|
let job name builds =
|
2020-12-07 09:17:49 +00:00
|
|
|
layout ~title:(Printf.sprintf "Job %s" name)
|
|
|
|
[ h1 [txtf "Job %s" name];
|
|
|
|
p [
|
2020-12-07 20:40:57 +00:00
|
|
|
txtf "Currently %d builds."
|
2021-01-08 12:47:17 +00:00
|
|
|
(List.length builds)
|
2020-12-07 09:17:49 +00:00
|
|
|
];
|
2021-01-28 11:17:06 +00:00
|
|
|
ul (List.map (fun (build, main_binary) ->
|
|
|
|
li ([
|
|
|
|
a ~a:[a_href Fpath.(to_string (v "build" / Uuidm.to_string build.Builder_db.Build.Meta.uuid / ""))]
|
|
|
|
[
|
|
|
|
txtf "%a" (Ptime.pp_human ()) build.Builder_db.Build.Meta.start;
|
|
|
|
];
|
|
|
|
txt " ";
|
|
|
|
check_icon build.result;
|
|
|
|
br ();
|
|
|
|
] @ match main_binary with
|
|
|
|
| Some main_binary ->
|
2020-12-07 15:33:19 +00:00
|
|
|
[
|
2021-01-28 11:17:06 +00:00
|
|
|
a ~a:[a_href Fpath.(to_string (v "build" / Uuidm.to_string build.Builder_db.Build.Meta.uuid
|
|
|
|
/ "f" // main_binary.Builder_db.filepath))]
|
|
|
|
[txtf "%s" (Fpath.basename main_binary.Builder_db.filepath)];
|
|
|
|
txt " ";
|
|
|
|
code [txtf "SHA256:%a" Hex.pp (Hex.of_cstruct main_binary.Builder_db.sha256)];
|
|
|
|
]
|
|
|
|
| None ->
|
|
|
|
[
|
|
|
|
txtf "Build failed";
|
|
|
|
]))
|
2021-01-08 12:47:17 +00:00
|
|
|
builds);
|
2020-12-07 09:17:49 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2021-01-08 12:47:17 +00:00
|
|
|
let job_build
|
|
|
|
name
|
2021-01-27 20:25:51 +00:00
|
|
|
{ Builder_db.Build.uuid = _; start; finish; result; console; script; main_binary = _; job_id = _ }
|
2021-01-08 12:47:17 +00:00
|
|
|
artifacts
|
2020-12-07 14:43:54 +00:00
|
|
|
=
|
2020-12-07 15:33:19 +00:00
|
|
|
let ptime_pp = Ptime.pp_human () in
|
|
|
|
let delta = Ptime.diff finish start in
|
2020-12-07 20:40:57 +00:00
|
|
|
layout ~title:(Fmt.strf "Job build %s %a" name ptime_pp start)
|
|
|
|
[ h1 [txtf "Job build %s %a" name ptime_pp start];
|
|
|
|
p [txtf "Build took %a." Ptime.Span.pp delta ];
|
|
|
|
p [txtf "Execution result: %a." Builder.pp_execution_result result];
|
2020-12-14 07:18:13 +00:00
|
|
|
h3 [txt "Digests of build artifacts"];
|
|
|
|
dl (List.concat_map
|
2021-02-23 14:37:30 +00:00
|
|
|
(fun { Builder_db.filepath; localpath=_; sha256; size=_ } ->
|
2021-01-06 10:48:24 +00:00
|
|
|
let (`Hex sha256_hex) = Hex.of_cstruct sha256 in
|
|
|
|
[
|
2020-12-21 10:22:35 +00:00
|
|
|
dt [a
|
2021-01-08 12:47:17 +00:00
|
|
|
~a:[Fmt.kstr a_href "f/%a" Fpath.pp filepath]
|
|
|
|
[code [txtf "%a" Fpath.pp filepath]];
|
2020-12-14 07:18:13 +00:00
|
|
|
txt "(SHA256)"];
|
2021-01-06 10:48:24 +00:00
|
|
|
dd [code [txt sha256_hex]];
|
2020-12-14 07:18:13 +00:00
|
|
|
])
|
2021-01-08 12:47:17 +00:00
|
|
|
artifacts);
|
2020-12-21 10:22:35 +00:00
|
|
|
h3 [txt "Job script"];
|
|
|
|
toggleable "job-script" "Show/hide"
|
|
|
|
[ pre [txt script] ];
|
2020-12-14 07:18:13 +00:00
|
|
|
h3 [txt "Build log"];
|
2020-12-21 10:22:35 +00:00
|
|
|
toggleable ~hidden:false "build-log" "Show/hide build log"
|
|
|
|
[
|
|
|
|
table
|
|
|
|
(List.mapi (fun idx (ts, line) ->
|
|
|
|
let ts_id = "L" ^ string_of_int idx in
|
|
|
|
tr [
|
|
|
|
td ~a:[
|
|
|
|
a_class ["output-ts"];
|
|
|
|
a_id ts_id;
|
|
|
|
]
|
|
|
|
[a ~a:[a_href ("#"^ts_id); a_class ["output-ts-anchor"]]
|
|
|
|
[code [txtf "%#d ms" (Duration.to_ms (Int64.of_int ts))]]];
|
|
|
|
td ~a:[a_class ["output-code"]]
|
|
|
|
[code [txt line]];
|
|
|
|
])
|
2021-01-08 12:47:17 +00:00
|
|
|
(List.rev console));
|
2020-12-21 10:22:35 +00:00
|
|
|
];
|
2020-12-07 09:17:49 +00:00
|
|
|
]
|