-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.clj
116 lines (95 loc) · 3.61 KB
/
build.clj
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
(ns build
(:refer-clojure :exclude [test])
(:require
[camel-snake-kebab.core :as csk]
[clj-yaml.core :as yaml]
[clojure.java.io :as io]
[clojure.pprint :as pp]
[clojure.tools.build.api :as b] ; for b/git-count-revs
[org.corfield.build :as bb]
[clojure.tools.deps :as t]
))
(def lib 'org.scicloj/metamorph.ml)
; alternatively, use MAJOR.MINOR.COMMITS:
;; (def version (format "6.2.%s" (b/git-count-revs nil)))
(def version "0.12")
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(defn test "Run the tests." [opts]
(-> opts
(assoc :aliases [:runner])
(bb/run-tests)))
(defn- pom-template [version]
[[:description "Machine learning functions for tech.ml.dataset"]
[:url "https://github.com/scicloj/metamorph.ml"]
[:licenses
[:license
[:name "Eclipse Public License"]
[:url "http://www.eclipse.org/legal/epl-v10.html"]]]
[:developers
[:developer
[:name "Carsten Behring"]]]
[:scm
[:url "https://github.com/scicloj/metamorph.ml"]
[:connection "scm:git:https://github.com/scicloj/metamorph.ml.git"]
[:developerConnection "scm:git:https://github.com/scicloj/metamorph.ml.git"]
[:tag (str version)]]])
(defn jar [_]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:pom-data (pom-template version)
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))
(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
(-> opts
(assoc :lib lib :version version
:aliases [:runner :dev :test])
(bb/run-tests)
(bb/clean)
(jar)))
(defn install "Install the JAR locally." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/install)))
(defn deploy "Deploy the JAR to Clojars." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/deploy)))
(defn build-glance-columns [ops]
(with-open [w (io/writer "resources/columms-glance.edn")]
(-> (slurp "https://raw.githubusercontent.com/alexpghayes/modeltests/main/data-raw/columns_glance.yaml")
(yaml/parse-string
:key-fn #(-> % :key csk/->kebab-case-keyword))
(pp/pprint w))))
(defn build-tidy-columns [opts]
(with-open [w (io/writer "resources/columms-tidy.edn")]
(-> (slurp "https://raw.githubusercontent.com/alexpghayes/modeltests/main/data-raw/columns_tidy.yaml")
(yaml/parse-string
:key-fn #(-> % :key csk/->kebab-case-keyword))
(pp/pprint w))))
(defn build-augment-columns [ops]
(with-open [w (io/writer "resources/columms-augment.edn")]
(-> (slurp "https://raw.githubusercontent.com/alexpghayes/modeltests/main/data-raw/columns_augment.yaml")
(yaml/parse-string
:key-fn #(-> % :key csk/->kebab-case-keyword))
(pp/pprint w))))
(defn render-notebooks [opts]
(let [opts (update opts :aliases conj :dev)
aliases [:dev]
basis (b/create-basis opts) ; primarily using :aliases here
alias-data (t/combine-aliases basis aliases)
cmd-opts (merge {:basis basis
:main 'clojure.main
:main-args ["notebooks/render.clj"]}
opts
alias-data)
cmd (b/java-command cmd-opts)]
(when-not (zero? (:exit (b/process cmd)))
(throw (ex-info (str "run failed for " aliases) opts)))
opts))