Skip to content

Commit 37bd8a0

Browse files
Run tests on CI
1 parent 44177d6 commit 37bd8a0

File tree

5 files changed

+60
-14
lines changed

5 files changed

+60
-14
lines changed

.github/workflows/images.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@ env:
1313

1414
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
1515
jobs:
16+
tests:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-java@v4
22+
with:
23+
java-version: '23'
24+
25+
- uses: DeLaGuardo/[email protected]
26+
with:
27+
cli: latest
28+
29+
- name: Cache Clojure dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: |
33+
~/.m2/repository
34+
~/.gitlibs
35+
~/.deps.clj
36+
key: cljdeps-${{ hashFiles('deps.edn') }}
37+
restore-keys: cljdeps-
38+
39+
- name: Run tests
40+
run: clojure -X:test
41+
42+
1643
build-and-push-image:
1744
runs-on: ubuntu-latest
1845
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.

deps.edn

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@
2020
com.grammarly/omniconf {:mvn/version "0.5.2"}
2121
com.taoensso/nippy {:mvn/version "3.4.2"}
2222
functionalbytes/mount-lite {:mvn/version "2.3.1"}
23-
nrepl/nrepl {:mvn/version "1.3.0"}}
23+
nrepl/nrepl {:mvn/version "1.3.0"}
24+
25+
org.clj-commons/hickory {:mvn/version "0.7.5"}
26+
nubank/matcher-combinators {:mvn/version "3.9.1"}}
2427

2528
:aliases
2629
{:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.0"}}
27-
:ns-default build}}}
30+
:ns-default build}
31+
32+
:test {:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1"
33+
:git/sha "dfb30dd"}}
34+
:exec-fn flamebin.test-runner/test
35+
:jvm-opts ["-Djdk.attach.allowAttachSelf"]}}}
2836

2937
#_(find-dep metosin/reitit-core)
30-
#_(deps functionalbytes/mount-lite "2.3.1")
38+
#_(deps nubank/matcher-combinators {:mvn/version "3.9.1"})

src/flamebin/config.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(:require [clojure.java.io :as io]
33
[clojure.string :as str]
44
[mount.lite :as mount]
5+
[mount.extensions.autostart :as mount.auto]
56
[omniconf.core :as cfg]
67
[taoensso.timbre :as log]
78
[taoensso.timbre.tools.logging]))
@@ -79,13 +80,14 @@
7980
:port {:type :number
8081
:required #(cfg/get :repl :enabled)}}}})
8182

83+
(def ^:dynamic *silent* false)
84+
8285
(defn init-config []
8386
(cfg/populate-from-env)
84-
(cfg/verify))
87+
(cfg/verify :silent *silent*))
8588

8689
(mount/defstate config
87-
:start (do (init-config) (fn config-getter [& path] (apply cfg/get path))))
88-
90+
:start (do (init-config) cfg/get))
8991
#_(mount/start #'config)
9092

9193
;;;; Misc initialization

src/flamebin/infra/metrics.clj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
(:import (io.micrometer.core.instrument DistributionSummary Metrics Timer)
44
(io.micrometer.prometheusmetrics PrometheusConfig PrometheusMeterRegistry)))
55

6-
(mount/defstate registry
7-
:start (let [reg (PrometheusMeterRegistry. PrometheusConfig/DEFAULT)]
8-
(.bindTo (io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics.) reg)
9-
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics.) reg)
10-
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.) reg)
11-
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.) reg)
12-
(.add (Metrics/globalRegistry) reg)
13-
reg))
6+
(defonce registry
7+
(delay
8+
(let [reg (PrometheusMeterRegistry. PrometheusConfig/DEFAULT)]
9+
(.bindTo (io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics.) reg)
10+
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics.) reg)
11+
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.) reg)
12+
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.) reg)
13+
(.add (Metrics/globalRegistry) reg)
14+
reg)))
1415

1516
(defn scrape []
1617
(.scrape @registry))

test/flamebin/test_runner.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(ns flamebin.test-runner
2+
(:require cognitect.test-runner.api
3+
mount.lite))
4+
5+
(defn test [opts]
6+
(cognitect.test-runner.api/test opts)
7+
(mount.lite/stop)
8+
(shutdown-agents))

0 commit comments

Comments
 (0)