-
Notifications
You must be signed in to change notification settings - Fork 2
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
10 changed files
with
176 additions
and
7 deletions.
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,47 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
tools: replikativ/clj-tools@0 | ||
|
||
workflows: | ||
build_test_and_deploy: | ||
jobs: | ||
- tools/setup: | ||
context: dockerhub-deploy | ||
- tools/unittest: | ||
context: dockerhub-deploy | ||
requires: | ||
- tools/setup | ||
#- tools/cljstest: | ||
# context: docker-deploy | ||
# requires: | ||
# - tools/build | ||
#- tools/format: | ||
# context: dockerhub-deploy | ||
# requires: | ||
# - tools/setup | ||
- tools/build: | ||
context: dockerhub-deploy | ||
requires: | ||
- tools/setup | ||
- tools/deploy: | ||
context: | ||
- dockerhub-deploy | ||
- clojars-deploy | ||
filters: | ||
branches: | ||
only: main | ||
requires: | ||
- tools/unittest | ||
# - tools/cljstest | ||
# - tools/format | ||
- tools/build | ||
- tools/release: | ||
context: | ||
- dockerhub-deploy | ||
- github-token | ||
filters: | ||
branches: | ||
only: main | ||
requires: | ||
- tools/deploy |
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 @@ | ||
{:linters {:clojure-lsp/unused-public-var {:exclude [build]}}} |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
clojure -M:test "$@" |
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,9 @@ | ||
set -o errexit | ||
set -o pipefail | ||
|
||
echo "Running tests for node" | ||
[ -d "node_modules/ws" ] || npm install ws | ||
clojure -M:test --focus unit-node | ||
|
||
echo "Running tests for browser" | ||
clojure -M:test --focus unit-browser |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
clojure -M:test --focus unit "$@" |
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,76 @@ | ||
(ns build | ||
(:refer-clojure :exclude [test compile]) | ||
(:require [clojure.tools.build.api :as b] | ||
[borkdude.gh-release-artifact :as gh] | ||
[org.corfield.build :as bb]) | ||
(:import (clojure.lang ExceptionInfo))) | ||
|
||
(def lib 'io.replikativ/zufall) | ||
(def version (format "0.2.%s" (b/git-count-revs nil))) | ||
(def current-commit (gh/current-commit)) | ||
(def class-dir "target/classes") | ||
(def basis (b/create-basis {:project "deps.edn"})) | ||
(def jar-file (format "target/%s-%s.jar" (name lib) version)) | ||
|
||
(defn clean | ||
[_] | ||
(b/delete {:path "target"})) | ||
|
||
(defn jar | ||
[opts] | ||
(-> opts | ||
(assoc :class-dir class-dir | ||
:src-pom "./template/pom.xml" | ||
:lib lib | ||
:version version | ||
:basis basis | ||
:jar-file jar-file | ||
:src-dirs ["src"]) | ||
bb/jar)) | ||
|
||
(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts] | ||
(-> opts | ||
(assoc :lib lib :version version) | ||
(bb/clean) | ||
(bb/jar))) | ||
|
||
(defn install "Install the JAR locally." [opts] | ||
(-> opts | ||
jar | ||
bb/install)) | ||
|
||
(defn deploy "Deploy the JAR to Clojars." [opts] | ||
(-> opts | ||
(assoc :lib lib :version version) | ||
(bb/deploy))) | ||
|
||
(defn fib [a b] | ||
(lazy-seq (cons a (fib b (+ a b))))) | ||
|
||
(defn retry-with-fib-backoff [retries exec-fn test-fn] | ||
(loop [idle-times (take retries (fib 1 2))] | ||
(let [result (exec-fn)] | ||
(if (test-fn result) | ||
(when-let [sleep-ms (first idle-times)] | ||
(println "Returned: " result) | ||
(println "Retrying with remaining back-off times (in s): " idle-times) | ||
(Thread/sleep (* 1000 sleep-ms)) | ||
(recur (rest idle-times))) | ||
result)))) | ||
|
||
(defn try-release [] | ||
(try (gh/overwrite-asset {:org "replikativ" | ||
:repo (name lib) | ||
:tag version | ||
:commit current-commit | ||
:file jar-file | ||
:content-type "application/java-archive"}) | ||
(catch ExceptionInfo e | ||
(assoc (ex-data e) :failure? true)))) | ||
|
||
(defn release | ||
[_] | ||
(-> (retry-with-fib-backoff 10 try-release :failure?) | ||
:url | ||
println)) | ||
|
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,19 @@ | ||
{:deps {org.clojure/clojure {:mvn/version "1.11.1"}} | ||
:aliases {:test {:main-opts ["-m" "kaocha.runner"] | ||
:extra-deps {org.clojure/clojurescript {:mvn/version "1.11.60"} | ||
lambdaisland/kaocha {:mvn/version "1.71.1119"} | ||
lambdaisland/kaocha-cljs {:mvn/version "1.4.130"}} | ||
:extra-paths ["test"]} | ||
:format {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}} | ||
:main-opts ["-m" "cljfmt.main" "check"]} | ||
:build {:deps {io.github.seancorfield/build-clj {:git/tag "v0.8.2" | ||
:git/sha "0ffdb4c"} | ||
borkdude/gh-release-artifact {:git/url "https://github.com/borkdude/gh-release-artifact" | ||
:sha "a83ee8da47d56a80b6380cbb6b4b9274048067bd"} | ||
babashka/babashka.curl {:mvn/version "0.1.1"} | ||
babashka/fs {:mvn/version "0.1.2"} | ||
cheshire/cheshire {:mvn/version "5.10.2"}} | ||
:ns-default build} | ||
:ffix {:extra-deps {cljfmt/cljfmt {:mvn/version "0.9.0"}} | ||
:main-opts ["-m" "cljfmt.main" "fix"]}} | ||
:paths ["src"]} |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
#kaocha/v1 {:tests [{:id :unit} | ||
{:id :unit-node ;; Throws known kaocha error | ||
:type :kaocha.type/cljs | ||
:cljs/repl-env cljs.repl.node/repl-env | ||
:timeout 30000} | ||
{:id :unit-browser | ||
:type :kaocha.type/cljs | ||
:cljs/repl-env cljs.repl.browser/repl-env | ||
:timeout 30000}] | ||
:bindings {kaocha.type.cljs/*debug* true} | ||
:reporter kaocha.report/documentation} |