Skip to content

Commit f601155

Browse files
authored
ci: release libdatahike artifacts (#749)
* fix: libdatahike build * test: testing libdatahike compiled binary * fix: persisting to workspace * ci: graalvm home set * fixup! ci: graalvm home set * fixup! ci: graalvm home set * fixup! ci: graalvm home set * fixup! ci: graalvm home set * fixup! ci: graalvm home set * fixup! ci: graalvm home set
1 parent 6149e16 commit f601155

File tree

14 files changed

+107
-45
lines changed

14 files changed

+107
-45
lines changed

.circleci/config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ jobs:
190190
at: /home/circleci
191191
- run:
192192
name: Release pod on pod registry
193-
command: bb release pod
194-
193+
command: |
194+
if ["$CIRCLE_ORGANIZATION_ID" = "replikativ"]; then
195+
bb release pod
196+
fi
195197
196198
workflows:
197199
build-test-and-deploy:

.circleci/scripts/gen_ci.clj

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[clojure.string :as str]
66
[flatland.ordered.map :refer [ordered-map]]))
77

8-
(def graalvm-version "24.0.1")
8+
(def graalvm-version "24.0.2")
99

1010
(defn run
1111
([cmd-name cmd]
@@ -39,6 +39,7 @@
3939
:resource_class resource-class}
4040
:working_directory "/home/circleci/replikativ"
4141
:environment {:GRAALVM_VERSION graalvm-version
42+
:GRAALVM_HOME "/home/circleci/graalvm"
4243
:DTHK_PLATFORM "linux"
4344
:DTHK_ARCH arch
4445
:PATH "/bin:/home/circleci/graalvm/bin:/home/circleci/clojure/bin:/home/circleci/bin"
@@ -69,17 +70,26 @@ sudo update-alternatives --set javac /home/circleci/graalvm/bin/javac"
6970
(run "Build native image"
7071
"cd /home/circleci/replikativ
7172
bb ni-cli")
73+
(run "Build libdatahike"
74+
"cd /home/circleci/replikativ
75+
bb ni-compile")
7276
(run "Test native image"
7377
"cd /home/circleci/replikativ
7478
bb test native-image")
79+
(run "Test babashka pod"
80+
"cd /home/circleci/replikativ
81+
bb test bb-pod")
82+
(run "Test libdatahike"
83+
"cd /home/circleci/replikativ
84+
bb test libdatahike")
7585
{:persist_to_workspace
7686
{:root "/home/circleci/"
77-
:paths ["replikativ/dthk"]}}
87+
:paths ["replikativ/dthk" "replikativ/libdatahike/target"]}}
7888
{:save_cache
7989
{:paths ["~/.m2" "~/graalvm"]
8090
:key cache-key}}])))
8191

82-
(defn release-native-image
92+
(defn release-artifacts
8393
[arch]
8494
(let [cache-key (str arch "-deps-linux-{{ checksum \"deps.edn\" }}")]
8595
(ordered-map
@@ -94,6 +104,9 @@ bb test native-image")
94104
(run "Release native image"
95105
"cd /home/circleci/replikativ
96106
bb release native-image")
107+
(run "Release libdatahike"
108+
"cd /home/circleci/replikativ
109+
bb release libdatahike")
97110
{:persist_to_workspace
98111
{:root "/home/circleci/"
99112
:paths ["replikativ/dthk"]}}
@@ -116,8 +129,8 @@ bb release native-image")
116129
:jobs (ordered-map
117130
:build-linux-amd64 (build-native-image "amd64" "large")
118131
:build-linux-aarch64 (build-native-image "aarch64" "arm.large")
119-
:release-linux-amd64 (release-native-image "amd64")
120-
:release-linux-aarch64 (release-native-image "aarch64"))
132+
:release-linux-amd64 (release-artifacts "amd64")
133+
:release-linux-aarch64 (release-artifacts "aarch64"))
121134
:workflows (ordered-map
122135
:version 2
123136
:native-images

.cirrus.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ build-task:
99
DTHK_PLATFORM: macos
1010
DTHK_ARCH: aarch64
1111
INSTALL_DIR: ${HOME}
12-
GRAALVM_VERSION: 22.0.2
13-
GRAALVM_SLUG: 9.1
12+
GRAALVM_VERSION: 24.0.2
13+
GRAALVM_SLUG: 11.1
1414
GRAALVM_HOME: ${HOME}/graalvm-community-openjdk-${GRAALVM_VERSION}+${GRAALVM_SLUG}/Contents/Home/
1515
GITHUB_TOKEN: ENCRYPTED[!86a3791406be6ffc9490f464846ec5385908ae8d3d2a9eeb1457d529060816e14e9d7b88ecd190970add6a5d5d4e7b59!]
1616
script: |
@@ -43,15 +43,18 @@ build-task:
4343
echo $PATH
4444
native-image --version
4545
46-
# compile
46+
# compile native artifacts
4747
bb ni-cli
48+
bb ni-compile
4849
49-
# test
50+
# test native artifacts
5051
bb test native-image
5152
bb test bb-pod
53+
bb test libdatahike
5254
53-
# upload artifact
55+
# release native artifacts
5456
bb release native-image
57+
bb release libdatahike
5558
5659
binaries_artifacts:
5760
path: "dist/*"

.github/workflows/native-image.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ${{ matrix.os }}
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
GRAALVM_VERSION: 24.0.1
27+
GRAALVM_VERSION: 24.0.2
2828
DTHK_PLATFORM: macos
2929
DTHK_ARCH: amd64
3030
steps:
@@ -45,7 +45,7 @@ jobs:
4545
uses: graalvm/setup-graalvm@v1
4646
with:
4747
java-version: '24'
48-
distribution: 'graalvm'
48+
distribution: 'graalvm-community'
4949
github-token: ${{ secrets.GITHUB_TOKEN }}
5050

5151
- name: Install clojure tools
@@ -57,14 +57,24 @@ jobs:
5757
- name: Build native image
5858
run: bb ni-cli
5959

60+
- name: Build libdatahike
61+
run: bb ni-compile
62+
6063
- name: Test native image
61-
run: |
62-
bb test native-image
63-
bb test bb-pod
64+
run: bb test native-image
65+
66+
- name: Test babashka pod
67+
run: bb test bb-pod
68+
69+
- name: Test libdatahike
70+
run: bb test libdatahike
6471

6572
- name: Release native-image
6673
run: bb release native-image
6774

75+
- name: Release libdatahike
76+
run: bb release libdatahike
77+
6878
- name: Save cache
6979
uses: actions/cache/save@v4
7080
id: save-cache

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ out/
3232
/datahike
3333
tests.user.edn
3434
libdatahike.zip
35-
dhi
36-
dhi.build_artifacts.txt
35+
dthk
36+
libdatahike*.zip
3737
trace.edn
3838
tmp.edn
39-
.shadow-cljs
39+
.shadow-cljs
40+
.claude
41+
repl-mcp.log

bb.edn

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
:depends [http-server-clean]
8989
:task (build/compile-java (-> config :build :http-server-clj))}
9090

91-
http-server-ccompile {:doc "Compile clojure namespaces"
91+
http-server-ccompile {:doc "Compile clojure namespaces for http-server"
9292
:task (build/compile-clojure (-> config :build :http-server-clj))}
9393

9494
http-server-pom {:doc "Create pom file"
@@ -119,7 +119,7 @@
119119
:depends [jcompile ni-check]
120120
:task (clojure "-M:native-cli")}
121121

122-
ni-ccompile {:doc "Create native cpp library"
122+
ni-ccompile {:doc "Compile clojure namespaces for native-image"
123123
:task (build/compile-clojure (-> config :build :native))}
124124

125125
ni-uber {:doc "Build native image uber jar"
@@ -128,11 +128,4 @@
128128

129129
ni-compile {:doc "Create native cpp library"
130130
:depends [ni-uber]
131-
:task (build/native-compile config (-> config :build :native))}
132-
133-
ni-release {:doc "Build and release native assets to GitHub"
134-
:depends [ni-compile]
135-
:task (let [{:keys [artifact target-dir]} (-> config :build :native)]
136-
(fs/zip artifact [target-dir])
137-
(release/gh-release artifact config)
138-
(fs/delete artifact))}}}
131+
:task (build/native-compile config (-> config :build :native))}}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
set -o nounset
6+
7+
export LD_LIBRARY_PATH=./libdatahike/target
8+
9+
rm -rf "/tmp/libdatahike-test"
10+
./libdatahike/target/test_cpp "{:store {:backend :file :path \"/tmp/libdatahike-test\"} :schema-flexibility :read}" "[{:name \"Alice\"}]" "[:find ?e ?v :where [?e :name ?v]]"

bb/src/tools/build.clj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
:repo repo-config
5555
:version-str (version/string repo-config)})))
5656

57+
(defn lib-path [repo-config {:keys [target-dir jar-pattern] :as project-config}]
58+
(str target-dir "/" (render jar-pattern {:project project-config
59+
:repo repo-config
60+
:version-str (version/string repo-config)})))
61+
5762
(defn jar
5863
"Builds jar file"
5964
[repo-config {:keys [class-dir target-dir src-dirs resource-dir] :as project-config}]
@@ -89,6 +94,7 @@
8994
(str "-o " project-name)
9095
"--shared"
9196
"-H:+ReportExceptionStackTraces"
97+
"-H:+GenerateBuildArtifactsFile"
9298
"-J-Dclojure.spec.skip-macros=true"
9399
"-J-Dclojure.compiler.direct-linking=true"
94100
(str "-H:IncludeResources=" (version/string repo-config))
@@ -101,8 +107,9 @@
101107
(fs/delete-tree project-target-dir)
102108
(fs/create-dir project-target-dir)
103109
(run! #(fs/move % project-target-dir)
104-
(concat ["graal_isolate.h" "graal_isolate_dynamic.h"]
110+
(concat ["graal_isolate.h" "graal_isolate_dynamic.h" "build-artifacts.json"]
105111
(map (fn [ext] (str project-name ext))
106-
[".so" ".h" "_dynamic.h" ".build_artifacts.txt"]))))
112+
[".so" ".h" "_dynamic.h"]))))
107113
(do (println "GRAALVM_HOME not set!")
108-
(println "Please set GRAALVM_HOME to the root of the graalvm directory on your system."))))
114+
(println "Please set GRAALVM_HOME to the root of the graalvm directory on your system.")
115+
(System/exit 1))))

bb/src/tools/release.clj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(:require
33
[babashka.fs :as fs]
44
[babashka.http-client :as http]
5-
[babashka.process :as p]
65
[borkdude.gh-release-artifact :as gh]
76
[cheshire.core :as json]
87
[clojure.java.io :as io]
@@ -108,6 +107,16 @@
108107
:lib lib
109108
:version version})))))
110109

110+
(defn zip-lib [config project]
111+
(let [{:keys [target-dir zip-pattern]} (-> config :release project) lib "libdatahike"
112+
version (version/string config)]
113+
(if-not (fs/exists? target-dir)
114+
(do (println (str "ERROR: " target-dir " path not found, please compile first."))
115+
(System/exit 1))
116+
(let [zip-name (zip-path lib version "." zip-pattern)]
117+
(fs/zip zip-name [target-dir])
118+
zip-name))))
119+
111120
(defn zip-cli [config project]
112121
(let [{:keys [target-dir binary-name zip-pattern]} (-> config :release project)
113122
lib (:lib config)
@@ -117,15 +126,18 @@
117126
(do (println (str "ERROR: " binary-path " executable not found, please compile first."))
118127
(System/exit 1))
119128
(let [zip-name (zip-path lib version target-dir zip-pattern)]
120-
(p/shell "zip" zip-name binary-name)
129+
(fs/zip zip-name [binary-name])
121130
zip-name))))
122131

123132
(defn -main [config args]
124133
(let [cmd (first args)]
125134
(case cmd
126-
"jar" (gh-release config (build/jar-path config (-> config :build :clj)))
135+
"jar" (->> (build/jar-path config (-> config :build :clj))
136+
(gh-release config))
127137
"native-image" (->> (zip-cli config :native-cli)
128138
(gh-release config))
129139
"pod" (pod-release config)
140+
"libdatahike" (->> (zip-lib config :libdatahike)
141+
(gh-release config))
130142
(do (println "ERROR: Command not found: " cmd)
131143
(System/exit 1)))))

bb/src/tools/test.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
(p/shell "./bb/resources/native-image-tests/run-native-image-tests")
5050
(println "Native image cli missing. Please run 'bb ni-cli' and try again.")))
5151

52+
(defn libdatahike []
53+
(if (fs/exists? "./libdatahike/target")
54+
(do (p/shell "./libdatahike/compile-cpp")
55+
(p/shell "./bb/resources/native-image-tests/run-libdatahike-tests"))
56+
(println "libdatahike binaries missing. Please run 'bb ni-compile' and try again.")))
57+
5258
(defn bb-pod []
5359
(if (fs/exists? "./dthk")
5460
(p/shell "./bb/resources/native-image-tests/run-bb-pod-tests.clj")
@@ -67,13 +73,15 @@
6773
(specs)
6874
(back-compat config)
6975
(native-image)
76+
(libdatahike)
7077
(bb-pod)
7178
(cljs-compile-test))
7279

7380
(defn -main [config & args]
7481
(if (seq args)
7582
(case (first args)
7683
"native-image" (native-image)
84+
"libdatahike" (libdatahike)
7785
"bb-pod" (bb-pod)
7886
"back-compat" (back-compat config)
7987
"specs" (specs)

0 commit comments

Comments
 (0)