Classify a build as monitoring build if mirage-monitoring is in the dependency cone

This commit is contained in:
Hannes Mehnert 2022-11-04 14:51:58 +01:00
parent 041f1d2640
commit 3914e718c3

View file

@ -248,12 +248,25 @@ let infer_section_and_synopsis 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 switch root = let infer_section switch root =
let root_pkg_name = OpamPackage.Name.to_string root.OpamPackage.name in let root_pkg = root.OpamPackage.name in
let root_pkg_name = OpamPackage.Name.to_string root_pkg in
if Astring.String.is_prefix ~affix:"mirage-unikernel-" root_pkg_name then if Astring.String.is_prefix ~affix:"mirage-unikernel-" root_pkg_name then
let influx = OpamPackage.Name.of_string "metrics-influx" in let metrics_influx =
if OpamPackage.Set.exists (fun p -> OpamPackage.Name.equal p.OpamPackage.name influx) let influx = OpamPackage.Name.of_string "metrics-influx" in
switch.OpamFile.SwitchExport.selections.OpamTypes.sel_installed OpamPackage.Set.exists (fun p -> OpamPackage.Name.equal p.OpamPackage.name influx)
then switch.OpamFile.SwitchExport.selections.OpamTypes.sel_installed
in
let mirage_monitoring =
let monitoring = OpamPackage.Name.of_string "mirage-monitoring" in
match OpamPackage.Name.Map.find_opt root_pkg switch.OpamFile.SwitchExport.overlays with
| None -> false
| Some opam ->
let depends = OpamFile.OPAM.depends opam in
OpamFormula.fold_left (fun acc (n', _) ->
acc || OpamPackage.Name.equal n' monitoring)
false depends
in
if metrics_influx || mirage_monitoring then
"Unikernels (with metrics reported to Influx)" "Unikernels (with metrics reported to Influx)"
else else
"Unikernels" "Unikernels"