-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: graal-test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
|
||
clojure: | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macOS-latest, windows-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# It is important to install java before installing clojure tools which needs java | ||
# exclusions: babashka, clj-kondo and cljstyle | ||
- uses: graalvm/setup-graalvm@v1 | ||
with: | ||
version: 'latest' | ||
java-version: '17' | ||
components: 'native-image' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install clojure tools | ||
uses: DeLaGuardo/setup-clojure@10.0 | ||
with: | ||
lein: 2.9.1 # Leiningen | ||
bb: latest # Babashka | ||
|
||
# Optional step: | ||
- name: Cache clojure dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.m2/repository | ||
~/.gitlibs | ||
~/.deps.clj | ||
# List all files containing dependencies: | ||
key: cljdeps-${{ hashFiles('deps.edn') }} | ||
# key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }} | ||
# key: cljdeps-${{ hashFiles('project.clj') }} | ||
# key: cljdeps-${{ hashFiles('build.boot') }} | ||
restore-keys: cljdeps- | ||
|
||
- name: Execute graal-test | ||
run: bb test:graal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ pom.xml* | |
/doc/ | ||
.idea/ | ||
*.iml | ||
graal_test | ||
graal_test.build_artifacts.txt | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{:paths ["bb"] | ||
:tasks {:requires ([graal-test]) | ||
test:graal {:doc "Run native-image tests" | ||
:task (do (graal-test/uberjar) | ||
(graal-test/native-image) | ||
(graal-test/test-native-image))}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bb | ||
|
||
(ns graal-test | ||
(:require | ||
[babashka.fs :as fs] | ||
[babashka.process :refer [shell]] | ||
[clojure.string :as str])) | ||
|
||
(defn uberjar [] | ||
(let [command "lein with-profiles +graal-test uberjar" | ||
command (if (fs/windows?) | ||
(if (fs/which "lein") | ||
command | ||
;; assume powershell module | ||
(str "powershell.exe -command " (pr-str command))) | ||
command)] | ||
(shell command))) | ||
|
||
(defn executable [dir name] | ||
(-> (fs/glob dir (if (fs/windows?) | ||
(str name ".{exe,bat,cmd}") | ||
name)) | ||
first | ||
fs/canonicalize | ||
str)) | ||
|
||
(defn native-image [] | ||
(let [graalvm-home (System/getenv "GRAALVM_HOME") | ||
bin-dir (str (fs/file graalvm-home "bin"))] | ||
(shell (executable bin-dir "gu") "install" "native-image") | ||
(shell (executable bin-dir "native-image") "-jar" "target/graal.jar" "--no-fallback" "graal_test"))) | ||
|
||
(defn test-native-image [] | ||
(let [{:keys [out]} | ||
(shell {:out :string} (executable "." "graal_test") "1" "2" "3")] | ||
(assert (str/includes? out (str '("1" "2" "3"))) out) | ||
(println "Native image works!"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns taoensso.timbre.graal-test | ||
(:require [taoensso.timbre :refer [info]]) | ||
(:gen-class)) | ||
|
||
(defn -main [& args] | ||
(info args)) |