-
Notifications
You must be signed in to change notification settings - Fork 7
/
bb.edn
86 lines (76 loc) · 4.04 KB
/
bb.edn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{:paths ["script"]
:deps {lread/status-line {:git/url "https://github.com/lread/status-line.git"
:sha "cf44c15f30ea3867227fa61ceb823e5e942c707f"}}
:tasks {;; setup
:requires ([babashka.fs :as fs]
[clojure.java.io :as io]
[clojure.string :as string]
[lread.status-line :as status]
[release])
:enter (let [{:keys [name]} (current-task)] (status/line :head "TASK %s %s" name (string/join " " *command-line-args*)))
:leave (let [{:keys [name]} (current-task)] (status/line :detail "\nTASK %s done." name))
;; commands
lint
{:doc "lint source code using clj-kondo"
:task (do
(when (not (fs/exists? ".clj-kondo/.cache"))
(status/line :head "Building clj-kondo cache")
(let [cp (-> (shell {:out :string} "clojure -Spath -M:test")
:out)]
(shell "clojure -M:clj-kondo --skip-lint --dependencies --copy-configs --lint" cp)))
(status/line :head "Linting")
(let [config {:output {:exclude-files ["/inlined/"]}}
{:keys [exit]}
(shell {:continue true}
"clojure -M:clj-kondo --lint src test bb.edn deps.edn"
"modules/metagetta/src"
"modules/metagetta/test"
"modules/metagetta/deps.edn"
"--config" (str config))]
(cond
(= 2 exit) (status/die exit "clj-kondo found one or more lint errors")
(= 3 exit) (status/die exit "clj-kondo found one or more lint warnings")
(> exit 0) (status/die exit "clj-kondo returned unexpected exit code"))))}
eastwood
{:doc "Lint source code using eastwood"
:task (clojure "-M:eastwood")}
test-metagetta
{:doc "metagetta unit tests"
:task (shell {:dir "modules/metagetta"}
"bb test")}
test-cljdoc-analyzer-integration
{:doc "cljdoc-analyzier integration tests"
:task (shell "clojure -M:test"
"--reporter" "documentation"
"--plugin" "kaocha.plugin/profiling"
"--plugin" "kaocha.plugin/junit-xml"
"--junit-xml-file" "target/test-results/cljdoc-analyzer-integration/results.xml"
"--no-capture-output"
"integration")}
test
{:doc "Run all tests"
:depends [test-metagetta test-cljdoc-analyzer-integration]}
change-log-check
{:doc "Checks that change log is ready for a release"
:task (release/change-log-check)}
release-checks
{:doc "Performs all release checks"
:task (release/release-checks)}
release
{:depends [release-checks test]
:doc "Cut a new release"
:task (release/release)}
pretty-expected-edn
{:doc "Format expected edn for tests with jet to make diff comparisons more grokable and files more readable"
:task (->> (fs/glob "." "test-resources/**/cljdoc-analysis.edn")
(mapv (fn [in-file]
(let [out-file (fs/create-temp-file {:prefix "cljdoc-pretty" :suffix "edn"})]
(println "prettying " (str in-file))
(with-open [in (io/input-stream (fs/file in-file))]
(shell {:in in :out (str out-file)} "jet --colors false"))
(fs/move out-file in-file {:replace-existing true})))))}
outdated
{:doc "report on outdated dependencies"
:task (do
(status/line :head "Checking Clojure deps")
(shell {:continue true} "clojure -M:outdated" "--directory=.:modules/metagetta"))}}}