Skip to content

Commit 4a9fff6

Browse files
committed
Setup integration tests
1 parent e86eda7 commit 4a9fff6

File tree

6 files changed

+133
-11
lines changed

6 files changed

+133
-11
lines changed

.github/workflows/test.yml

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,106 @@ jobs:
4343
- name: Install Clojure
4444
uses: DeLaGuardo/setup-clojure@master
4545
with:
46-
cli: '1.12.0.1495'
47-
bb: '0.9.161'
46+
cli: '1.12.0.1530'
47+
bb: '1.12.200'
4848

4949
- name: Run tests
5050
run: bb test
51+
jvm-integration-test:
52+
runs-on: ${{matrix.os}}
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
os: [ubuntu-22.04]
57+
jdk: [17]
58+
include:
59+
- os: windows-latest
60+
jdk: 17
61+
- os: macos-latest
62+
jdk: 17
63+
steps:
64+
- uses: actions/checkout@v4
65+
with:
66+
fetch-depth: 0
67+
68+
- name: Set up JDK ${{ matrix.jdk }}
69+
uses: actions/setup-java@v3
70+
with:
71+
distribution: 'adopt'
72+
java-version: ${{ matrix.jdk }}
73+
74+
- name: Install clojure build tools
75+
uses: DeLaGuardo/setup-clojure@master
76+
with:
77+
cli: '1.12.0.1530'
78+
bb: '1.12.200'
79+
80+
- name: Generate embedded binary
81+
run: bb prod-cli
82+
83+
- name: Run integration tests
84+
run: bb integration-test
85+
86+
graalvm-build:
87+
runs-on: ubuntu-22.04
88+
strategy:
89+
fail-fast: false
90+
steps:
91+
- uses: actions/checkout@v4
92+
- name: Install Clojure
93+
uses: DeLaGuardo/setup-clojure@master
94+
with:
95+
cli: '1.12.0.1530'
96+
bb: '1.12.200'
97+
98+
- uses: graalvm/setup-graalvm@v1
99+
with:
100+
java-version: '21'
101+
distribution: 'graalvm'
102+
native-image-musl: 'true'
103+
github-token: ${{ secrets.GITHUB_TOKEN }}
104+
105+
- name: Build static Linux native image
106+
env:
107+
ECA_JAR: "eca.jar"
108+
ECA_XMX: "-J-Xmx6g"
109+
ECA_STATIC: true
110+
ECA_MUSL: true
111+
run: |
112+
bb native-cli
113+
114+
- name: Compress binary
115+
uses: svenstaro/upx-action@v2
116+
with:
117+
file: eca
118+
119+
- name: Upload
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: eca-native
123+
path: eca
124+
125+
graalvm-integration-test:
126+
needs: graalvm-build
127+
runs-on: ubuntu-22.04
128+
strategy:
129+
fail-fast: false
130+
steps:
131+
- uses: actions/checkout@v4
132+
133+
- name: Install clojure build tools
134+
uses: DeLaGuardo/setup-clojure@master
135+
with:
136+
cli: '1.12.0.1530'
137+
bb: '1.12.200'
138+
139+
- uses: actions/download-artifact@v4
140+
name: eca-native
141+
142+
- name: Setup binary
143+
run: |
144+
cp -rf eca-native/eca eca
145+
chmod +x eca
146+
147+
- name: Run integration tests
148+
run: bb integration-test

bb.edn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
:tasks {debug-cli make/debug-cli
88
debug-graal make/debug-graal
99
prod-jar make/prod-jar
10+
prod-cli make/prod-cli
1011
native-cli make/native-cli
1112

1213
test make/unit-test
1314

1415
tag make/tag
1516
get-last-changelog-entry make/get-last-changelog-entry
16-
integration-test entrypoint/run-all}}
17+
integration-test make/integration-test}}

build.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
(defn prod-jar [opts]
6666
(aot-jar (merge opts {:extra-aliases [:native]})))
6767

68+
(defn prod-cli [opts]
69+
(aot-jar opts)
70+
(bin {}))
71+
6872
(defn native-cli [opts]
6973
(println "Building native image...")
7074
(if-let [graal-home (System/getenv "GRAALVM_HOME")]

integration-test/entrypoint.clj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns entrypoint
22
(:require
3-
[clojure.test :as t]))
3+
[clojure.test :as t]
4+
[integration.eca :as eca]))
45

56
(def namespaces
67
'[integration.initialize-test])
@@ -27,11 +28,8 @@
2728
~@body))
2829

2930
#_{:clojure-lsp/ignore [:clojure-lsp/unused-public-var]}
30-
(defn run-all [& args]
31-
(when-not (first args)
32-
(println "First arg must be path to eca binary")
33-
(System/exit 0))
34-
31+
(defn run-all [binary]
32+
(alter-var-root #'eca/*eca-binary-path* (constantly binary))
3533
(apply require namespaces)
3634

3735
(let [timeout-minutes (if (re-find #"(?i)win|mac" (System/getProperty "os.name"))

integration-test/integration/eca.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[clojure.test :refer [use-fixtures]]
77
[integration.client :as client]))
88

9+
(def ^:dynamic *eca-binary-path* nil)
910
(def ^:dynamic *eca-process* nil)
1011
(def ^:dynamic *mock-client* nil)
1112

@@ -17,7 +18,7 @@
1718
{:dir "integration-test/sample-test/"})))
1819

1920
(defn start-process! []
20-
(let [server (start-server (first *command-line-args*))
21+
(let [server (start-server *eca-binary-path*)
2122
client (client/client (:in server) (:out server))]
2223
(client/start client nil)
2324
(async/go-loop []

scripts/make.clj

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[babashka.fs :as fs]
55
[babashka.process :as p]
66
[babashka.tasks :refer [shell]]
7-
[clojure.string :as string]))
7+
[clojure.string :as string]
8+
[entrypoint]))
89

910
(def windows? (#'fs/windows?))
1011

@@ -59,6 +60,10 @@
5960
(build "prod-jar")
6061
(mv-here "target/eca.jar"))
6162

63+
(defn prod-cli []
64+
(build "prod-cli")
65+
(mv-here (fs/path (eca-bin-filename :script))))
66+
6267
(defn native-cli
6368
"Build the native `eca[.exe]` cli executable with `graalvm`."
6469
[]
@@ -86,3 +91,18 @@
8691
(println :running-unit-tests...)
8792
(clj! ["-M:test"])
8893
(println))
94+
95+
(defn integration-test
96+
"Run the integration tests in 'test/integration-test/' using `./eca[.bat|.exe]`.
97+
98+
There should only be one eca executable found, throws error
99+
otherwise."
100+
[]
101+
(let [eca-bins (->> [:native :script] (map eca-bin-filename) distinct)
102+
eca-bins-found (->> eca-bins (filter fs/exists?) (into #{}))]
103+
104+
(case (count eca-bins-found)
105+
0 (throw (ex-info "No eca executables found." {:searched-for eca-bins}))
106+
1 (entrypoint/run-all (str (first eca-bins-found)))
107+
(throw (ex-info "More than one eca executables found. Can only work with one."
108+
{:bin-found eca-bins-found})))))

0 commit comments

Comments
 (0)