-
Notifications
You must be signed in to change notification settings - Fork 78
/
bb.edn
152 lines (124 loc) · 7.05 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{:min-bb-version "0.9.159"
:paths ["bb"]
:deps {io.github.nextjournal/dejavu {:git/sha "4980e0cc18c9b09fb220874ace94ba6b57a749ca"}
io.github.nextjournal/cas-client {:git/sha "d9f838937ebc8b645fe5764949e72a6df8e344de"}
mvxcvi/multiformats {:git/url "https://github.com/greglook/clj-multiformats"
:git/sha "1189f1fb26db180cd8dcfd50518cdf553c0ff9e1"}}
:tasks
{:requires
([tasks :as t]
[clojure.string :as str]
[babashka.process :as p]
[babashka.fs :as fs]
[babashka.cli :as cli]
[cheshire.core :as json])
yarn-install {:doc "Installs and updates npm dependencies"
:task (shell "yarn install")}
watch:cljs {:doc "Starts shadow-cljs & clerk"
:task (apply clojure "-X:build:test:sci:demo:dev" *command-line-args*)
:depends [yarn-install]}
build:js {:doc "Builds JS"
:depends [yarn-install]
:task (clojure "-M:sci:demo:dev release viewer")}
build+upload-viewer-resources {:doc "Refreshes assets stored on CDN (google storage)"
:extra-paths ["src"]
:task nextjournal.clerk.render.hashing/build+upload-viewer-resources}
lint {:doc "Lints project using clj-kondo"
:task (apply shell "clj-kondo --lint src test" *command-line-args*)}
lint:copy-configs {:doc "Copies clj-kondo configs from deps"
:task (println "clj-kondo --lint"
(-> (shell {:out :string} "clojure -Spath") :out str/trim)
"--dependencies --copy-configs --skip-lint")}
build:static-app {:doc "Builds a static app with default notebooks"
:task (apply clojure "-X:demo:nextjournal/clerk" *command-line-args*)}
build:static-app-test-release
{:doc "Builds static app which uses output of build:js.
Run with additional --paths notebooks/cherry.clj to test single notebook."
:task (apply clojure "-M:demo:nextjournal/clerk:test-release-js" *command-line-args*)}
-check {:depends [lint test:clj]}
check {:doc "Check to run before pushing"
:task (run '-check {:parallel true})}
test:clj {:doc "Run clojure tests"
:task (apply clojure "-X:test" *command-line-args*)}
playwright:version {:doc "Print used playwright version from ui_tests/yarn.json"
:task (print (->> (babashka.process/shell {:out :string} "grep -E 'playwright-core \"(.*)\"' ui_tests/yarn.lock")
:out
str/trim
(re-find (re-pattern "playwright-core \"(.*)\""))
second))}
playwright:install {:task (shell {:dir "ui_tests"} "yarn playwright install --with-deps chromium")}
test:static-app {:doc "Run UI tests for current SHA. Provide SHA as command line arg."
:task (do (shell {:dir "ui_tests"} "yarn install")
(let [args (not-empty (cli/parse-opts *command-line-args*))]
(if-not (:skip-install args)
(run 'playwright:install)
(println "Skipping playwright install"))
(shell {:dir "ui_tests"} "yarn nbb -m playwright-tests"
(or (when args
(cond-> args
(contains? args :file)
(assoc :url (str "file://" (fs/cwd) fs/file-separator (:file args)))))
{:sha (-> (shell {:out :string} "git rev-parse HEAD")
:out
str/trim)}))))}
update-meta {:doc "Updates meta.edn with current version (based on commit count currently)."
:task (t/update-meta)}
update-changelog
{:doc "Updates CHANGELOG.md with "
:task
(t/update-changelog)}
link-changelog {:doc "Turns the issue references in the changelog into links"
:task (do (defn tag->issue-link [s]
(clojure.string/replace s (re-pattern "(?<!\\[)#([0-9]+)") "[#$1](https://github.com/nextjournal/clerk/issues/$1)"))
(let [f "CHANGELOG.md"]
(spit f (tag->issue-link (slurp f)))))}
jar {:doc "Build jar"
:task (do
(println "Building jar")
(clojure "-T:build jar"))}
install-jar {:doc "Installs jar for local testing"
:task (clojure "-T:build install")}
tag {:doc "Tags release and pushes tag to Github."
:task (t/tag)}
clerk-version {:doc "Prints current version"
:task (println (t/version))}
publish {:doc "Prepares repo for publishing via CI"
:task (t/publish)}
-current-tag (->> (shell {:out :string} "git tag --points-at HEAD")
:out
str/trim
not-empty)
-current-branch (->> (shell {:out :string} "git branch --show-current")
:out
str/trim)
test-jar {:doc "Tests current jar"
:task (do
(println (str "Testing jar: 'clerk-" (t/version) ".jar'"))
(clojure (str "-Sforce -Srepro -Sdeps '"
(pr-str {:aliases {:test-jar {:jvm-opts ["-Dclojure.main.report=stdout"]
:deps {'io.github.nextjournal/clerk {:local/root (str "./target/clerk-" (t/version) ".jar")}}
:exec-fn 'nextjournal.clerk/build!
:exec-args {:paths ["notebooks/hello.clj"]}}}})
"' -T:test-jar")))}
ci:publish {:doc "Publish task which will be run on CI"
:depends [-current-tag -current-branch]
:task (do
(prn :current-tag -current-tag)
(prn :current-branch -current-branch)
(if (and -current-tag (= "main" -current-branch))
(do
(println "Building jar")
(clojure "-T:build jar")
(run 'test-jar)
(println "Deploying to clojars")
(clojure "-T:build deploy"))
;; still build jar with updated commit count for artifact upload
(do
(run 'update-meta)
(run 'jar)
(run 'test-jar))))}
uninstall-git-hooks {:doc "Uninstall git hooks we installed previously and no longer need"
:task (fs/delete-if-exists ".git/hooks/pre-commit")}
-dev {:depends [uninstall-git-hooks watch:cljs]}
dev {:doc "Start app in dev mode, compiles cljs and css"
:task (run '-dev {:parallel true})}}}