|
26 | 26 | (into []
|
27 | 27 | (filter
|
28 | 28 | (fn [{:keys [name]}]
|
29 |
| - (and (str/includes? name from) |
30 |
| - (str/includes? name to)))) |
| 29 | + (let [[from-name to-name] (str/split name #"->")] |
| 30 | + (and (str/includes? from-name from) |
| 31 | + (str/includes? to-name to))))) |
31 | 32 | all-runs)))
|
32 | 33 |
|
33 | 34 | (defn- ->epoch [time-str]
|
34 | 35 | (/ (.toEpochMilli (java.time.Instant/parse time-str)) 1000))
|
35 | 36 |
|
| 37 | +(defn- print-runs-report [head-ref-name runs-for-ref url] |
| 38 | + (if (some (comp #{"failure"} :conclusion) runs-for-ref) |
| 39 | + (do (println) |
| 40 | + (ice/p [:red "====== runs for: " head-ref-name " ======"]) |
| 41 | + (pp/print-table |
| 42 | + (->> |
| 43 | + runs-for-ref |
| 44 | + (map #(dissoc % :workflowName :displayTitle :number :status)) |
| 45 | + (sort-by (comp - ->epoch :createdAt))))) |
| 46 | + (ice/p [:green [:bold "OK "] url " | " head-ref-name]))) |
| 47 | + |
| 48 | +(defn- gather-runs-for-open-prs [open-prs runs] |
| 49 | + (for [{head-ref-name :headRefName |
| 50 | + url :url} open-prs |
| 51 | + :let [local-runs (runs-for-head-ref-name head-ref-name runs)]] |
| 52 | + [head-ref-name local-runs])) |
| 53 | + |
36 | 54 | (defn -main []
|
37 | 55 | (let [_ (println "Finding open PRs with process_docs_changes.yml workflow ...")
|
38 | 56 | runs (all-runs)
|
39 | 57 | _ (println "Found" (count runs) "runs for process_docs_changes.yml workflow")
|
40 | 58 | _ (println "Finding open PRs with process_docs_changes.yml workflow ...")
|
41 |
| - open-prs (set (open-prs))] |
42 |
| - (println "Found" (count open-prs) "open PRs with process_docs_changes.yml workflow") |
43 |
| - (doseq [{head-ref-name :headRefName |
44 |
| - url :url} open-prs |
45 |
| - :let [runz (runs-for-head-ref-name head-ref-name runs)]] |
46 |
| - (if (some (comp #{"failure"} :conclusion) runz) |
47 |
| - (do (println) (println) (println) |
48 |
| - (ice/p [:red "====== runs for: " head-ref-name " ======"]) |
49 |
| - (pp/print-table |
50 |
| - (->> |
51 |
| - runz |
52 |
| - (map #(dissoc % :workflowName :displayTitle :number :status)) |
53 |
| - (sort-by (comp - ->epoch :createdAt))))) |
54 |
| - (ice/p [:green [:bold "OK "] url " | " head-ref-name]))))) |
| 59 | + open-prs (set (open-prs)) |
| 60 | + _ (println "Found" (count open-prs) "open PRs with process_docs_changes.yml workflow") |
| 61 | + local-runs (gather-runs-for-open-prs open-prs runs) |
| 62 | + sorted-runs (sort-by |
| 63 | + (fn [[_k vs]] |
| 64 | + (count (filter #{"failure"} (map :conclusion vs)))) |
| 65 | + local-runs)] |
| 66 | + (doseq [[head-ref-name runs-for-ref] sorted-runs] |
| 67 | + (print-runs-report head-ref-name runs-for-ref (:url (first runs-for-ref)))))) |
55 | 68 |
|
56 | 69 | (when (= *file* (System/getProperty "babashka.file"))
|
57 | 70 | (-main))
|
| 71 | + |
| 72 | +(comment |
| 73 | + |
| 74 | + (def runz (all-runs)) |
| 75 | + |
| 76 | + (count runz) |
| 77 | + |
| 78 | + (def open-prz (open-prs)) |
| 79 | + |
| 80 | + (update-vals (into {} (gather-runs-for-open-prs open-prz runz)) #(take 2 %)) |
| 81 | + |
| 82 | + ) |
0 commit comments