adapt to builder 0.2.0 changes
This commit is contained in:
parent
579f9d38e6
commit
045dbcf23d
3 changed files with 39 additions and 26 deletions
|
@ -301,6 +301,7 @@ let add_routes datadir =
|
||||||
|
|
||||||
let upload_binary req =
|
let upload_binary req =
|
||||||
let job = Dream.param "job" req in
|
let job = Dream.param "job" req in
|
||||||
|
let platform = Dream.param "platform" req in
|
||||||
let binary_name =
|
let binary_name =
|
||||||
Dream.query "binary_name" req
|
Dream.query "binary_name" req
|
||||||
|> Option.map Fpath.of_string
|
|> Option.map Fpath.of_string
|
||||||
|
@ -326,7 +327,7 @@ let add_routes datadir =
|
||||||
let datadir = Dream.global datadir_global req in
|
let datadir = Dream.global datadir_global req in
|
||||||
let exec =
|
let exec =
|
||||||
let now = Ptime_clock.now () in
|
let now = Ptime_clock.now () in
|
||||||
({ Builder.name = job ; script = "" }, uuid, [], now, now, Builder.Exited 0,
|
({ Builder.name = job ; platform ; script = "" }, uuid, [], now, now, Builder.Exited 0,
|
||||||
[ (Fpath.(v "bin" // binary_name), body) ])
|
[ (Fpath.(v "bin" // binary_name), body) ])
|
||||||
in
|
in
|
||||||
(Lwt.return (Dream.local Authorization.user_info_local req |>
|
(Lwt.return (Dream.local Authorization.user_info_local req |>
|
||||||
|
@ -351,5 +352,5 @@ let add_routes datadir =
|
||||||
Dream.get "/hash" (w hash);
|
Dream.get "/hash" (w hash);
|
||||||
Dream.get "/compare/:build_left/:build_right/opam-switch" (w compare_opam);
|
Dream.get "/compare/:build_left/:build_right/opam-switch" (w compare_opam);
|
||||||
Dream.post "/upload" (Authorization.authenticate (w upload));
|
Dream.post "/upload" (Authorization.authenticate (w upload));
|
||||||
Dream.post "/job/:job/upload" (Authorization.authenticate (w upload_binary));
|
Dream.post "/job/:job/platform/:platform/upload" (Authorization.authenticate (w upload_binary));
|
||||||
]
|
]
|
||||||
|
|
58
lib/model.ml
58
lib/model.ml
|
@ -228,7 +228,7 @@ let commit_files datadir staging_dir job_name uuid =
|
||||||
Lwt.return (Bos.OS.Dir.create job_dir) >>= fun _ ->
|
Lwt.return (Bos.OS.Dir.create job_dir) >>= fun _ ->
|
||||||
Lwt.return (Bos.OS.Path.move staging_dir dest)
|
Lwt.return (Bos.OS.Path.move staging_dir dest)
|
||||||
|
|
||||||
let infer_section_and_synopsis name artifacts =
|
let infer_section_and_synopsis platform name artifacts =
|
||||||
let opam_switch =
|
let opam_switch =
|
||||||
match List.find_opt (fun (p, _) -> String.equal (Fpath.basename p) "opam-switch") artifacts with
|
match List.find_opt (fun (p, _) -> String.equal (Fpath.basename p) "opam-switch") artifacts with
|
||||||
| None -> None
|
| None -> None
|
||||||
|
@ -245,35 +245,47 @@ let infer_section_and_synopsis name artifacts =
|
||||||
| Some opam -> OpamFile.OPAM.synopsis opam, OpamFile.OPAM.descr_body opam
|
| Some opam -> OpamFile.OPAM.synopsis opam, OpamFile.OPAM.descr_body opam
|
||||||
in
|
in
|
||||||
let infer_section_from_packages switch =
|
let infer_section_from_packages switch =
|
||||||
let influx = OpamPackage.Name.of_string "metrics-influx" in
|
let root = switch.OpamFile.SwitchExport.selections.OpamTypes.sel_roots in
|
||||||
if OpamPackage.Set.exists (fun p -> OpamPackage.Name.equal p.OpamPackage.name influx)
|
if OpamPackage.Set.cardinal root <> 1 then
|
||||||
switch.OpamFile.SwitchExport.selections.OpamTypes.sel_installed
|
None
|
||||||
then
|
|
||||||
"Unikernels (with metrics reported to Influx)"
|
|
||||||
else
|
else
|
||||||
"Unikernels"
|
let root = OpamPackage.Set.choose root in
|
||||||
|
let root_pkg_name = OpamPackage.Name.to_string root.OpamPackage.name in
|
||||||
|
if Astring.String.is_prefix ~affix:"mirage-unikernel-" root_pkg_name then
|
||||||
|
let influx = OpamPackage.Name.of_string "metrics-influx" in
|
||||||
|
if OpamPackage.Set.exists (fun p -> OpamPackage.Name.equal p.OpamPackage.name influx)
|
||||||
|
switch.OpamFile.SwitchExport.selections.OpamTypes.sel_installed
|
||||||
|
then
|
||||||
|
Some "Unikernels (with metrics reported to Influx)"
|
||||||
|
else
|
||||||
|
Some "Unikernels"
|
||||||
|
else
|
||||||
|
None
|
||||||
in
|
in
|
||||||
let infer_section_from_name name =
|
let infer_section_from_platform_or_name =
|
||||||
let map = [
|
if String.equal platform "no-platform" then
|
||||||
"-freebsd", "FreeBSD" ;
|
let map = [
|
||||||
"-debian", "Debian" ;
|
"-freebsd", "FreeBSD" ;
|
||||||
"-ubuntu", "Ubuntu" ;
|
"-debian", "Debian" ;
|
||||||
] in
|
"-ubuntu", "Ubuntu" ;
|
||||||
match
|
] in
|
||||||
List.find_opt (fun (affix, _) -> Astring.String.is_infix ~affix name) map
|
match
|
||||||
with
|
List.find_opt (fun (affix, _) -> Astring.String.is_infix ~affix name) map
|
||||||
| None -> None
|
with
|
||||||
| Some (_, os) -> Some (os ^ " Packages")
|
| None -> None
|
||||||
|
| Some (_, os) -> Some (os ^ " Packages")
|
||||||
|
else
|
||||||
|
Some (platform ^ " Packages")
|
||||||
in
|
in
|
||||||
match opam_switch with
|
match opam_switch with
|
||||||
| None -> None, (None, None)
|
| None -> None, (None, None)
|
||||||
| Some opam_switch ->
|
| Some opam_switch ->
|
||||||
let section =
|
let section =
|
||||||
match infer_section_from_name name with
|
match infer_section_from_packages opam_switch with
|
||||||
| Some x -> x
|
| None -> infer_section_from_platform_or_name
|
||||||
| None -> infer_section_from_packages opam_switch
|
| Some x -> Some x
|
||||||
in
|
in
|
||||||
Some section, infer_synopsis_and_descr opam_switch
|
section, infer_synopsis_and_descr opam_switch
|
||||||
|
|
||||||
let compute_input_id artifacts =
|
let compute_input_id artifacts =
|
||||||
let get_hash filename =
|
let get_hash filename =
|
||||||
|
@ -358,7 +370,7 @@ let add_build
|
||||||
console; script;
|
console; script;
|
||||||
main_binary = None; input_id; user_id; job_id } >>= fun () ->
|
main_binary = None; input_id; user_id; job_id } >>= fun () ->
|
||||||
Db.find last_insert_rowid () >>= fun id ->
|
Db.find last_insert_rowid () >>= fun id ->
|
||||||
let sec_syn = infer_section_and_synopsis job_name raw_artifacts in
|
let sec_syn = infer_section_and_synopsis job.Builder.platform job_name raw_artifacts in
|
||||||
let add_or_update tag_id tag_value =
|
let add_or_update tag_id tag_value =
|
||||||
Db.find_opt Job_tag.get_value (tag_id, job_id) >>= function
|
Db.find_opt Job_tag.get_value (tag_id, job_id) >>= function
|
||||||
| None -> Db.exec Job_tag.add (tag_id, tag_value, job_id)
|
| None -> Db.exec Job_tag.add (tag_id, tag_value, job_id)
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
(test
|
(test
|
||||||
(name builder_db)
|
(name builder_db)
|
||||||
(libraries builder_db caqti.blocking alcotest mirage-crypto-rng.unix))
|
(libraries builder_db caqti.blocking alcotest mirage-crypto-rng.unix rresult))
|
||||||
|
|
Loading…
Reference in a new issue