Skip to content

Commit

Permalink
Run tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Nov 23, 2024
1 parent 44177d6 commit 37bd8a0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 14 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ env:

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
java-version: '23'

- uses: DeLaGuardo/[email protected]
with:
cli: latest

- name: Cache Clojure dependencies
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.gitlibs
~/.deps.clj
key: cljdeps-${{ hashFiles('deps.edn') }}
restore-keys: cljdeps-

- name: Run tests
run: clojure -X:test


build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
Expand Down
14 changes: 11 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@
com.grammarly/omniconf {:mvn/version "0.5.2"}
com.taoensso/nippy {:mvn/version "3.4.2"}
functionalbytes/mount-lite {:mvn/version "2.3.1"}
nrepl/nrepl {:mvn/version "1.3.0"}}
nrepl/nrepl {:mvn/version "1.3.0"}

org.clj-commons/hickory {:mvn/version "0.7.5"}
nubank/matcher-combinators {:mvn/version "3.9.1"}}

:aliases
{:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.0"}}
:ns-default build}}}
:ns-default build}

:test {:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1"
:git/sha "dfb30dd"}}
:exec-fn flamebin.test-runner/test
:jvm-opts ["-Djdk.attach.allowAttachSelf"]}}}

#_(find-dep metosin/reitit-core)
#_(deps functionalbytes/mount-lite "2.3.1")
#_(deps nubank/matcher-combinators {:mvn/version "3.9.1"})
8 changes: 5 additions & 3 deletions src/flamebin/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require [clojure.java.io :as io]
[clojure.string :as str]
[mount.lite :as mount]
[mount.extensions.autostart :as mount.auto]
[omniconf.core :as cfg]
[taoensso.timbre :as log]
[taoensso.timbre.tools.logging]))
Expand Down Expand Up @@ -79,13 +80,14 @@
:port {:type :number
:required #(cfg/get :repl :enabled)}}}})

(def ^:dynamic *silent* false)

(defn init-config []
(cfg/populate-from-env)
(cfg/verify))
(cfg/verify :silent *silent*))

(mount/defstate config
:start (do (init-config) (fn config-getter [& path] (apply cfg/get path))))

:start (do (init-config) cfg/get))
#_(mount/start #'config)

;;;; Misc initialization
Expand Down
17 changes: 9 additions & 8 deletions src/flamebin/infra/metrics.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
(:import (io.micrometer.core.instrument DistributionSummary Metrics Timer)
(io.micrometer.prometheusmetrics PrometheusConfig PrometheusMeterRegistry)))

(mount/defstate registry
:start (let [reg (PrometheusMeterRegistry. PrometheusConfig/DEFAULT)]
(.bindTo (io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics.) reg)
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics.) reg)
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.) reg)
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.) reg)
(.add (Metrics/globalRegistry) reg)
reg))
(defonce registry
(delay
(let [reg (PrometheusMeterRegistry. PrometheusConfig/DEFAULT)]
(.bindTo (io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics.) reg)
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics.) reg)
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.) reg)
(.bindTo (io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.) reg)
(.add (Metrics/globalRegistry) reg)
reg)))

(defn scrape []
(.scrape @registry))
Expand Down
8 changes: 8 additions & 0 deletions test/flamebin/test_runner.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns flamebin.test-runner
(:require cognitect.test-runner.api
mount.lite))

(defn test [opts]
(cognitect.test-runner.api/test opts)
(mount.lite/stop)
(shutdown-agents))

0 comments on commit 37bd8a0

Please sign in to comment.