-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
100 lines (89 loc) · 3.03 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{:min-bb-version "1.3.184"
:deps {io.github.borkdude/gh-release-artifact {:git/sha "4a9a74f0e50e897c45df8cc70684360eb30fce80"}}
:paths ["src"]
:tasks
{:requires ([clojure.string :as str]
[babashka.fs :as fs]
[babashka.process :as p]
[borkdude.gh-release-artifact :as ghr])
:init
(do
(defn print-public-task [k]
(let [{:keys [:private :name]} (current-task)]
(when-not private
(println (case k :enter "☐" "✓") name))))
(defn touch
[path]
(if (fs/exists? path)
(fs/set-last-modified-time path (System/currentTimeMillis))
(fs/create-file path))))
:enter (print-public-task :enter)
:leave (print-public-task :leave)
-lint-setup
{:doc "Setup linter"
:task
(let [mark-path ".clj-kondo/.cache/mark-lint-deps"]
(when (seq (fs/modified-since mark-path "deps.edn"))
(shell "bin/clj-kondo-classpath")
(touch mark-path)))}
lint
{:doc "Run clj-kondo"
:depends [-lint-setup]
:task
(shell "clj-kondo --lint . deps.edn")}
ci
{:doc "Test and lint"
:depends [lint test]}
upgrade
{:doc "Upgrade dependencies"
:task (clojure "-M:outdated --upgrade")}
test
{:doc "Run tests"
:task
(clojure "-M:kaocha")}
build
{:doc "Build standalone script and jar"
:task
(clojure "-T:build uberall")}
-smoketest-version
{:doc "Test that --version works"
:depends []
:task
(doseq [cmd [["java" "-jar" "./prune-backups.jar"]
["./prune-backups"]]]
(let [version (slurp "./target/VERSION")
cmd (into cmd ["--version"])
version-script (->> (p/process cmd {:out :string :dir "./target"})
p/check
:out)]
(println cmd \newline " --> " (pr-str version-script))
(when-not (= version (str/trim version-script))
(throw (ex-info "smoketest: wrong version" {:version-script version-script :version version})))))}
smoketest
{:doc "Test standalone script and jar"
:depends [build]
:task
(run '-smoketest-version)}
release
{:doc "Upload release"
:depends [build smoketest]
:task
(let [version (slurp "target/VERSION")
upload (fn [path content-type]
(println "Uploading" path)
(ghr/release-artifact {:org "schmir"
:repo "prune-backups"
:tag version
:draft true
;; :commit "8a026a65f2c9f2e3b5413173b9debd075eed7fbb"
:file path
:content-type content-type
:sha256 false
:overwrite true}))]
(upload "target/prune-backups.jar" nil)
(upload "target/prune-backups" "text/plain"))}
clean
{:doc "Cleanup"
:task (doseq [dir [".cpcache" ".clj-kondo/.cache" "target"]]
(fs/delete-tree dir))}
}}