Views: Builds: Separated html-generation out into named functions for ease of reading

This commit is contained in:
rand00 2022-02-03 13:50:32 +01:00
parent b631b05de2
commit 87442c4a09

View file

@ -187,9 +187,8 @@ let artifact
module Builds = struct
let make section_job_map =
layout ~title:"Reproducible OPAM builds"
([
let make_header =
[
H.h1 [ H.txt "Reproducible OPAM builds" ];
H.p [ H.txt "This website offers binary MirageOS unikernels and \
supplementary OS packages." ];
@ -225,18 +224,9 @@ module Builds = struct
a_value "Search";
] ();
];
] @
Utils.String_map.fold (fun section jobs acc ->
acc @ [
H.h2 [ H.txt section ];
H.ul (List.map (fun (job_name, synopsis, platform_builds) ->
H.li ([
H.a ~a:H.[a_href ("job/" ^ job_name ^ "/")]
[H.txt job_name];
H.br ();
H.txt (Option.value ~default:"" synopsis);
H.br ()
] @ List.concat_map (fun (platform, latest_build, latest_artifact) ->
]
let make_platform_builds ~job_name (platform, latest_build, latest_artifact) =
[
check_icon latest_build.Builder_db.Build.result;
H.txt " ";
@ -263,13 +253,33 @@ module Builds = struct
[ txtf "Build failure: %a" Builder.pp_execution_result
latest_build.Builder_db.Build.result ]
) @ [ H.br () ]
let make_jobs jobs =
jobs |> List.map (fun (job_name, synopsis, platform_builds) ->
H.li ([
H.a ~a:H.[a_href ("job/" ^ job_name ^ "/")]
[H.txt job_name];
H.br ();
H.txt (Option.value ~default:"" synopsis);
H.br ()
]
@ List.concat_map (make_platform_builds ~job_name) platform_builds)
)
platform_builds)
)
jobs)
])
section_job_map
[] @
let make_body section_job_map =
let aux section jobs acc =
acc @ [
H.h2 [ H.txt section ];
H.ul (make_jobs jobs)
]
in
Utils.String_map.fold aux section_job_map []
let make section_job_map =
layout ~title:"Reproducible OPAM builds"
(make_header
@ make_body section_job_map
@
[ H.p [
H.txt "View the latest failed builds ";
H.a ~a:H.[a_href "/failed-builds/"]