From cca68eaec8df33988f7e26080c219448acf46c4c Mon Sep 17 00:00:00 2001 From: eltrac Date: Thu, 24 Sep 2026 14:08:42 +0800 Subject: README: tidy up badges and add pipeline for updating coverage - put badges in a paragraph - add clojure version badge - add link to woodpecker ci - babashka script for automatically extracting and replacing coverage rate - pipeline for running cloverage --- scripts/ci/coverage_badge.clj | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 scripts/ci/coverage_badge.clj (limited to 'scripts/ci') diff --git a/scripts/ci/coverage_badge.clj b/scripts/ci/coverage_badge.clj new file mode 100644 index 0000000..a8a0948 --- /dev/null +++ b/scripts/ci/coverage_badge.clj @@ -0,0 +1,37 @@ +(ns ci.coverage-badge + (:require [hickory.core :as h] + [clojure.string :as string])) + +(def readme-path "README.md") +(def regex #"(?s)(?<=).*?(?=)") + +(def cloverage-output "target/coverage/index.html") +(def coverage (let [rows (-> cloverage-output + slurp + h/parse + h/as-hickory + :content first ;; get + :content (nth 3) ;; get + :content second ;; get + :content last ;; get + :content) + total-row (->> rows + (map :content) + (filter sequential?) + (filter #(= "Totals:" (get-in % [0 :content 0]))) + first + (filter map?))] + (-> total-row + (nth 2) + :content + first + (string/replace " " "")))) +;; "25" will make "%25" which decoded to "%", removing it will result in a Bad Request +(def badge-url (str "https://img.shields.io/badge/coverage-" coverage "25-green")) +(def badge-html + (str "\"test")) + +(defn -main [& _] + (let [readme-old (slurp readme-path) + readme-new (string/replace readme-old regex badge-html)] + (spit readme-path readme-new))) -- cgit v1.2.3