-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbb.edn
132 lines (101 loc) · 5.63 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{:min-bb-version
"0.6.8"
:tasks
{:requires ([babashka.fs :as fs]
[babashka.process :as process]
[clojure.string :as str]
[clojure.pprint :as pprint])
:init (do
(defn get-env [s]
(System/getenv s))
(defn get-property [s]
(System/getProperty s))
(defn pretty-print [x]
(binding [pprint/*print-right-margin* 130]
(pprint/pprint x)))
(defn execute [command]
(-> command (process/tokenize) (process/process) :out slurp str/trim-newline))
(def -zone-id (java.time.ZoneId/of "UTC"))
(def -datetime-formatter java.time.format.DateTimeFormatter/ISO_OFFSET_DATE_TIME)
(def -current-timestamp (java.time.ZonedDateTime/now -zone-id))
(def -build-timestamp (str (.format -current-timestamp -datetime-formatter)))
(def -build-number (execute "git rev-list HEAD --count"))
(def -git-url (execute "git config --get remote.origin.url"))
(def -git-branch (execute "git rev-parse --abbrev-ref HEAD"))
(def -git-sha (execute "git rev-parse --short HEAD"))
(def -release? (= "master" -git-branch))
(def -snapshot? (not -release?))
(def -deployable? (contains? #{"master" "develop"} -git-branch))
(def -version-template (execute "cat version.tmpl"))
(def -version (cond-> (str/replace -version-template "{{build-number}}" -build-number)
-snapshot? (str "-SNAPSHOT")))
(def -config
{:version -version
:build-number -build-number
:build-timestamp -build-timestamp
:git-url -git-url
:git-branch -git-branch
:git-sha -git-sha})
(def extra-env
{})
(defn as-params [params]
(->> params
(seq)
(flatten)
(map (fn [x]
(str/replace (pr-str x) (java.util.regex.Pattern/compile "(\".+\")") "'$1'")))
(str/join \space)))
(defn with-params [command]
(->> -config
(as-params)
(str command " "))))
:enter (let [{:keys [doc print-doc?]
:or {print-doc? true}} (current-task)]
(when (and print-doc? doc)
(println (str "▸ " doc))))
;;;;
;; Tasks
;;;;
version {:doc "[xtdb-tarantool] Show version"
:print-doc? false
:task (print -version)}
config {:doc "[xtdb-tarantool] Show config"
:print-doc? false
:task (pretty-print -config)}
outdated {:doc "[xtdb-tarantool] Check for outdated dependencies"
:task (clojure (with-params "-T:build outdated"))}
outdated:upgrade {:doc "[xtdb-tarantool] Upgrade outdated dependencies"
:task (clojure (with-params "-T:build outdated:upgrade"))}
clean {:doc "[xtdb-tarantool] Cleanup"
:task (clojure (with-params "-T:build clean"))}
lint {:doc "[xtdb-tarantool] Run linters"
:task (do
(shell "cljstyle check src")
(shell "clj-kondo --lint src"))}
lint:fix {:doc "[xtdb-tarantool] Run linters & fix"
:task (shell "cljstyle fix src")}
repl {:doc "[xtdb-tarantool] Run REPL"
:depends [clean]
:task (shell {:extra-env extra-env} (with-params "clojure -T:build repl"))}
test {:doc "[xtdb-tarantool] Run tests"
:depends [clean]
:task (shell {:extra-env extra-env} (with-params "clojure -T:build test"))}
test:unit {:doc "[xtdb-tarantool] Run unit tests"
:depends [clean]
:task (shell {:extra-env extra-env} (with-params "clojure -T:build test:unit"))}
test:integration {:doc "[xtdb-tarantool] Run integration tests"
:depends [clean]
:task (shell {:extra-env extra-env} (with-params "clojure -T:build test:integration"))}
jar {:doc "[xtdb-tarantool] Run build jar"
:depends [clean]
:task (clojure (with-params "-T:build jar"))}
install {:doc "[xtdb-tarantool] Install the jar locally"
:task (clojure (with-params "-T:build install"))}
deploy {:doc "[xtdb-tarantool] Deploy the jar to clojars"
:task (if -deployable?
(clojure (with-params "-T:build deploy"))
(println "Skip deploy..."))}
up {:doc "[xtdb-tarantool] Start development environment"
:task (shell {:extra-env extra-env} "docker-compose up -d")}
down {:doc "[xtdb-tarantool] Shutdown development environment"
:task (shell {:extra-env extra-env} "docker-compose down")}}}