Unverified Commit 4bce8549 authored by zapashcanon's avatar zapashcanon
Browse files

only cache status so one can still override parameters

parent a6d1d436
Pipeline #15910 passed with stages
in 8 minutes and 4 seconds
......@@ -80,7 +80,7 @@ let badge_github_workflow_status =
(Dream.param "repo" request)
(Dream.param "workflow" request)
in
let badge, invalid =
let status, invalid =
match Hashtbl.find_opt tbl url with
| Some (badge, timestamp) ->
let curr_timestamp = Unix.time () in
......@@ -88,9 +88,9 @@ let badge_github_workflow_status =
(badge, invalid)
| None -> ("", true)
in
let badge =
let status =
if not invalid then
Ok badge
Ok status
else
match Ezcurl.get ~url () with
| Error (_code, msg) ->
......@@ -112,29 +112,29 @@ let badge_github_workflow_status =
match latest_run with
| None -> Error "Invalid JSON answer"
| Some x ->
let s = x |> Util.member "conclusion" |> Util.to_string in
let open Ocb in
let status, color =
match s with
| "success" -> ("Success", Color.Green)
| "failure" -> ("Failure", Color.Red)
| "neutral" -> ("Neutral", Color.Grey)
| "cancelled" -> ("Cancelled", Color.Red)
| "skipped" -> ("Skipped", Color.Red)
| "timed_out" -> ("Timed out", Color.Red)
| unknown -> (unknown, Color.Grey)
in
let badge =
mk_badge ~label:"Build" ~color ~style:Style.Flat
~label_color:Color.Black ~status ~scale:1. request
in
Hashtbl.add tbl url (badge, Unix.time ());
Ok badge )
let status = x |> Util.member "conclusion" |> Util.to_string in
Hashtbl.add tbl url (status, Unix.time ());
Ok status )
in
match badge with
| Ok badge ->
Dream.respond ~headers:[ ("Content-Type", "image/svg+xml") ] badge
match status with
| Error e -> Dream.respond e
| Ok status ->
let open Ocb in
let status, color =
match status with
| "success" -> ("Success", Color.Green)
| "failure" -> ("Failure", Color.Red)
| "neutral" -> ("Neutral", Color.Grey)
| "cancelled" -> ("Cancelled", Color.Red)
| "skipped" -> ("Skipped", Color.Red)
| "timed_out" -> ("Timed out", Color.Red)
| unknown -> (unknown, Color.Grey)
in
let badge =
mk_badge ~label:"Build" ~color ~style:Style.Flat
~label_color:Color.Black ~status ~scale:1. request
in
Dream.respond ~headers:[ ("Content-Type", "image/svg+xml") ] badge
let () =
Dream.run ~interface:"0.0.0.0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment