Skip to content

better grouping #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 41 additions & 16 deletions script/_test/find_broken_workflows.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,57 @@
(into []
(filter
(fn [{:keys [name]}]
(and (str/includes? name from)
(str/includes? name to))))
(let [[from-name to-name] (str/split name #"->")]
(and (str/includes? from-name from)
(str/includes? to-name to)))))
all-runs)))

(defn- ->epoch [time-str]
(/ (.toEpochMilli (java.time.Instant/parse time-str)) 1000))

(defn- print-runs-report [head-ref-name runs-for-ref url]
(if (some (comp #{"failure"} :conclusion) runs-for-ref)
(do (println)
(ice/p [:red "====== runs for: " head-ref-name " ======"])
(pp/print-table
(->>
runs-for-ref
(map #(dissoc % :workflowName :displayTitle :number :status))
(sort-by (comp - ->epoch :createdAt)))))
(ice/p [:green [:bold "OK "] url " | " head-ref-name])))

(defn- gather-runs-for-open-prs [open-prs runs]
(for [{head-ref-name :headRefName
url :url} open-prs
:let [local-runs (runs-for-head-ref-name head-ref-name runs)]]
[head-ref-name local-runs]))

(defn -main []
(let [_ (println "Finding open PRs with process_docs_changes.yml workflow ...")
runs (all-runs)
_ (println "Found" (count runs) "runs for process_docs_changes.yml workflow")
_ (println "Finding open PRs with process_docs_changes.yml workflow ...")
open-prs (set (open-prs))]
(println "Found" (count open-prs) "open PRs with process_docs_changes.yml workflow")
(doseq [{head-ref-name :headRefName
url :url} open-prs
:let [runz (runs-for-head-ref-name head-ref-name runs)]]
(if (some (comp #{"failure"} :conclusion) runz)
(do (println) (println) (println)
(ice/p [:red "====== runs for: " head-ref-name " ======"])
(pp/print-table
(->>
runz
(map #(dissoc % :workflowName :displayTitle :number :status))
(sort-by (comp - ->epoch :createdAt)))))
(ice/p [:green [:bold "OK "] url " | " head-ref-name])))))
open-prs (set (open-prs))
_ (println "Found" (count open-prs) "open PRs with process_docs_changes.yml workflow")
local-runs (gather-runs-for-open-prs open-prs runs)
sorted-runs (sort-by
(fn [[_k vs]]
(count (filter #{"failure"} (map :conclusion vs))))
local-runs)]
(doseq [[head-ref-name runs-for-ref] sorted-runs]
(print-runs-report head-ref-name runs-for-ref (:url (first runs-for-ref))))))

(when (= *file* (System/getProperty "babashka.file"))
(-main))

(comment

(def runz (all-runs))

(count runz)

(def open-prz (open-prs))

(update-vals (into {} (gather-runs-for-open-prs open-prz runz)) #(take 2 %))

)
4 changes: 3 additions & 1 deletion script/merge.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
:require true}
:source-branch {:ref "<source-branch>"
:desc "The source branch of the triggering PR."
:alias :r}
:alias :r
:require true}
:dry-run {:desc "If set, will not execute the command, just print it out."
:coerce :boolean
:default false}}
Expand Down Expand Up @@ -97,6 +98,7 @@
(let [{:keys [source-branch target-branch]
dry-run? :dry-run
:as opts} (cli/parse-opts args cli-spec)
[source-branch target-branch] (mapv str/trim [source-branch target-branch])
pr-number (source+target-branch->pr-number source-branch target-branch)]
(when-not pr-number
(throw (ex-info (ice/p-str [:red "No PR found for source branch "] [:bold source-branch] " and target branch " [:bold target-branch] ".")
Expand Down