forked from babashka/nbb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
120 lines (105 loc) · 4.92 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
{:paths ["script"]
:deps
{nbb.build/nbb.build {:local/root "build"}}
:tasks
{:requires ([babashka.fs :as fs]
[nbb.build :as build]
[cheshire.core :as json]
[clojure.edn :as edn]
[clojure.pprint :as pp]
[clojure.string :as str])
:init (do
(def ^:dynamic *test* (= "true" (System/getenv "NBB_TESTS")))
(def windows? (-> (System/getProperty "os.name")
str/lower-case
(str/starts-with? "win")))
(when *test* (println "Tests are enabled.."))
(defn wrap-cmd [cmd]
(if *test*
(str (str/replace cmd
"-M" "-M:test")
" --config-merge shadow-tests.edn")
cmd))
(defn replace-version [file old-version new-version]
(spit file
(-> (slurp file)
(str/replace old-version new-version)))))
clean (do
(fs/delete-tree ".shadow-cljs")
(fs/delete-tree "lib"))
compile (build/build (wrap-cmd "-M -m shadow.cljs.devtools.cli --force-spawn compile modules")
*command-line-args*)
dev {:doc "Run shadow in watch mode with tests enabled."
:task
(binding [*test* true]
(println "Starting shadow-cljs in watch mode.")
(println "Run node lib/nbb_main.js to test nbb")
(println "Run bb run-tests to run the tests")
(build/build (wrap-cmd "-M -m shadow.cljs.devtools.cli --force-spawn watch modules")
*command-line-args*))}
run-tests (shell "node lib/nbb_tests.js")
npm-install (shell "npm install")
release {:depends [clean npm-install]
:doc "Compiles release build."
:task (build/release *command-line-args* {:wrap-cmd-fn wrap-cmd})}
run-integration-tests nbb-tests/main
publish {:doc "Bumps version, pushes tag and lets CI publish to npm."
:task
(let [old-version (:version (json/parse-string (slurp "package.json") true))
[major minor release] (str/split old-version (re-pattern "\\."))
new-version (str major "." minor "." (inc (parse-long release)))
_ (replace-version "package.json" old-version new-version)
_ (replace-version "ext/nbb-prismatic-schema/package.json"
old-version new-version)
_ (replace-version "ext/nbb-metosin-malli/package.json"
old-version new-version)]
(shell "git add .")
(shell "git commit -m " new-version)
(shell (str "git tag v" new-version))
(shell "git push --atomic origin main"
(str "v" new-version)))
}
current-tag (->> (shell {:out :string} "git tag --points-at HEAD")
:out
str/trim
not-empty)
current-branch (->> (shell {:out :string} "git rev-parse --abbrev-ref HEAD")
:out
str/trim)
nrepl-tests nbb-nrepl-tests/-main
ci:is-release {:depends [current-tag current-branch]
:task (do
(prn :debug current-tag current-branch)
(and current-tag (= "main" current-branch)))}
ci:test {:doc "Runs all tests in CI."
:task (binding [*test* true]
(println "Testing optimizations :advanced")
(run 'clean)
(run 'release)
(run 'run-tests)
(run 'run-integration-tests)
(run 'nrepl-tests))}
ci:test-build {:doc "Runs tests for build library"
:requires ([nbb-build-tests]
[babashka.deps :as deps])
:task (let [deps '{datascript/deps
{:git/url "https://github.com/babashka/nbb-features"
:git/sha "8938ef11926f660684a2d410d800cf9e12cf52a3"
:deps/root "features/datascript"}}]
(run 'clean)
(deps/add-deps {:deps deps})
(run 'release)
(nbb-build-tests/main))}
ci:publish {:doc "Publishes release build to npm"
:depends [ci:is-release]
:task
(if ci:is-release
(do (println "Releasing")
(binding [*test* false]
(run 'clean)
(run 'release)
#_(shell {:dir "ext/nbb-metosin-malli"} "npm publish --access public")
#_(shell "npm publish --access public")
#_(shell {:dir "ext/nbb-prismatic-schema"} "npm publish --access public")
(shell "npm publish --access public")))
(println "Skipping release."))}}}