• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MinaProtocol / mina / 2903

15 Nov 2024 01:59PM UTC coverage: 36.723% (-25.0%) from 61.682%
2903

Pull #16342

buildkite

dkijania
Merge branch 'dkijania/remove_publish_job_from_pr_comp' into dkijania/remove_publish_job_from_pr_dev
Pull Request #16342: [DEV] Publish debians only on nightly and stable

15 of 40 new or added lines in 14 files covered. (37.5%)

15175 existing lines in 340 files now uncovered.

24554 of 66863 relevant lines covered (36.72%)

20704.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/src/lib/logproc_lib/interpolator.ml
1
open Core_kernel
90✔
2

3
type mode = Hidden | Inline | After
4

5
type config =
6
  { mode : mode; max_interpolation_length : int; pretty_print : bool }
7

8
let rec result_fold_left ls ~init ~f =
9
  match ls with
264✔
10
  | [] ->
128✔
11
      Ok init
12
  | h :: t -> (
136✔
13
      match f init h with
14
      | Ok init' ->
136✔
15
          result_fold_left t ~init:init' ~f
16
      | Error err ->
×
17
          Error err )
18

19
let parser =
20
  let open Angstrom in
21
  let not_f f x = not (f x) in
666,544✔
22
  let or_f f g x = f x || g x in
37,600✔
23
  let is_alpha = function
UNCOV
24
    | 'a' .. 'z' | 'A' .. 'Z' | '_' ->
×
25
        true
26
    | _ ->
3,198✔
27
        false
28
  in
29
  let is_numeric = function '0' .. '9' -> true | _ -> false in
×
30
  let interpolation =
31
    lift2
32
      (fun c s -> String.of_char c ^ s)
4,277✔
33
      (char '$' *> commit *> satisfy is_alpha)
90✔
34
      (take_while (or_f is_alpha is_numeric))
90✔
35
  in
36
  let message =
90✔
37
    many1
38
      (choice
90✔
39
         [ (take_while1 (not_f (Char.equal '$')) >>| fun x -> `Raw x)
90✔
40
         ; (interpolation >>| fun x -> `Interpolate x)
90✔
41
         ] )
42
  in
43
  message <* end_of_input
90✔
44

45
let parse = Angstrom.parse_string ~consume:All parser
90✔
46

47
(* map and concat vs. fold: which is better for strings? *)
48
let render ~max_interpolation_length ~format_json metadata items =
49
  let open Result.Let_syntax in
128✔
50
  let%map msg, extra =
51
    result_fold_left items ~init:("", []) ~f:(fun (msg_acc, extra_acc) el ->
128✔
52
        match el with
136✔
53
        | `Raw str ->
132✔
54
            Ok (msg_acc ^ str, extra_acc)
55
        | `Interpolate id ->
4✔
56
            let%map json =
57
              String.Map.find metadata id
4✔
58
              |> Result.of_option ~error:(sprintf "bad interpolation for %s" id)
4✔
59
            in
60
            let str = format_json json in
4✔
61
            if String.length str > max_interpolation_length then
4✔
62
              (msg_acc ^ "$" ^ id, (id, str) :: extra_acc)
×
63
            else (msg_acc ^ str, extra_acc) )
4✔
64
  in
65
  (msg, List.rev extra)
128✔
66

67
let interpolate { mode; max_interpolation_length; pretty_print } msg metadata =
68
  let open Result.Let_syntax in
128✔
69
  let format_json =
70
    if pretty_print then Yojson.Safe.pretty_to_string
128✔
71
    else Yojson.Safe.to_string ?buf:None ?len:None
×
72
  in
73
  match mode with
74
  | Hidden ->
×
75
      Ok (msg, [])
76
  | Inline ->
128✔
77
      let%bind items = parse msg in
128✔
78
      render ~max_interpolation_length ~format_json metadata items
128✔
79
  | After ->
×
80
      Ok
81
        ( msg
82
        , List.map (String.Map.to_alist metadata) ~f:(fun (k, v) ->
×
83
              (k, format_json v) ) )
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc