Skip to content

Commit

Permalink
fix: corrected the message indentation on slack
Browse files Browse the repository at this point in the history
- added the fib-backoff-functionality for releases
- added build step to README
- moved release-functionality to orb
  • Loading branch information
TimoKramer committed Oct 7, 2022
1 parent ee6151d commit 66f8d6e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 39 deletions.
15 changes: 3 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
at: /home/circleci
- run:
name: Build
command: clojure -Sthreads 1 -T:build uber
command: clojure -T:build uber
no_output_timeout: 5m
- persist_to_workspace:
root: /home/circleci/
Expand All @@ -25,19 +25,10 @@ jobs:
- run:
name: Deploy to Docker Hub
command: |
clojure -Sthreads 1 \
-T:build deploy-image \
clojure -T:build deploy-image \
:docker-login ${DOCKER_LOGIN} \
:docker-password ${DOCKER_PASSWORD} \
no_output_timeout: 5m
release:
executor: tools/clojurecli
steps:
- attach_workspace:
at: /home/circleci
- run:
name: Release
command: clojure -Sthreads 1 -T:build release

workflows:
build-and-deploy:
Expand All @@ -63,7 +54,7 @@ workflows:
- tools/setup
- tools/format
- build
- release:
- tools/release:
context:
- dockerhub-deploy
- github-token
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.cpcache/
target/
.nrepl-port
.lsp/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Environment variables:
- `TWITTER_ACCESS_TOKEN`
- `TWITTER_ACCESS_TOKEN_SECRET`

## Building

After running `clj -T:build uber` you can find the jar in the target-folder.

## Running

Either via container: https://hub.docker.com/r/replikativ/souffleuse
Expand Down
52 changes: 32 additions & 20 deletions build.clj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
(ns build
(:require
[borkdude.gh-release-artifact :as gh]
[clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd])
[clojure.tools.build.api :as b])
(:import
[clojure.lang ExceptionInfo]
[java.nio.file Paths]
[com.google.cloud.tools.jib.api Jib Containerizer RegistryImage TarImage]
[com.google.cloud.tools.jib.api Jib Containerizer RegistryImage]
[com.google.cloud.tools.jib.api.buildplan AbsoluteUnixPath Port]))

(def lib 'io.replikativ/souffleuse)
(def version (format "0.1.%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-path (format "target/%s-%s.jar" (name lib) version))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def uber-file (format "%s-%s-standalone.jar" (name lib) version))
(def uber-path (format "target/%s" uber-file))
(def image (format "docker.io/replikativ/souffleuse:%s" version))
Expand All @@ -37,7 +37,7 @@
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-path}))
:jar-file jar-file}))

(defn uber
[_]
Expand All @@ -52,22 +52,35 @@
:basis basis
:main 'souffleuse.core}))

(defn deploy
"Don't forget to set CLOJARS_USERNAME and CLOJARS_PASSWORD env vars."
[_]
(dd/deploy {:installer :remote :artifact jar-path
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}))
(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)
(if-let [sleep-ms (first idle-times)]
(do (println "Returned: " result)
(println "Retrying with remaining back-off times (in s): " idle-times)
(Thread/sleep (* 1000 sleep-ms))
(recur (rest idle-times)))
(do (println "Failed deploying artifact.")
(System/exit 1)))
(println "Successfully created release-draft")))))

(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
[_]
(-> (gh/overwrite-asset {:org "replikativ"
:repo (name lib)
:tag version
:commit current-commit
:file uber-path
:content-type "application/java-archive"})
:url
println))
(retry-with-fib-backoff 10 try-release :failure?))

(defn install
[_]
Expand All @@ -76,7 +89,7 @@
(b/install {:basis (b/create-basis {})
:lib lib
:version version
:jar-file jar-path
:jar-file jar-file
:class-dir class-dir}))

(defn deploy-image
Expand Down Expand Up @@ -104,6 +117,5 @@
(uber nil)
(deploy-image {:docker-login docker-login
:docker-password docker-password})
(deploy nil)
(release nil)
(install nil))
9 changes: 4 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
:main-opts ["-m" "cljfmt.main" "fix"]}

:build {:deps {io.github.clojure/tools.build {:git/tag "v0.7.5" :git/sha "2526f58"}
slipset/deps-deploy {:mvn/version "0.2.0"}
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"}
:sha "b3f5b4ddfa7600191da176a752f161a91f0b8f9c"}
babashka/babashka.curl {:mvn/version "0.1.2"}
babashka/fs {:mvn/version "0.1.11"}
com.google.cloud.tools/jib-core {:mvn/version "0.20.0"}
cheshire/cheshire {:mvn/version "5.10.2"}}
cheshire/cheshire {:mvn/version "5.11.0"}}
:ns-default build}}}
4 changes: 2 additions & 2 deletions resources/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
:channel "#datahike"}
:github {:token #env GITHUB_TOKEN}
:scheduler {:announcement "In a quarter hour we will have our weekly open-source meeting
where we are talking about the latest progress on Datahike and
other replikativ libraries. Please join on <https://meet.jit.si/DatahikeWeekly|Jitsi>"
where we are talking about the latest progress on Datahike and
other replikativ libraries. Please join on <https://meet.jit.si/DatahikeWeekly|Jitsi>"
:hour 15
:minute 45}
:twitter {:announcement "Version %s of %s was just released. Take a look at the changelog over on GitHub: %s"
Expand Down

0 comments on commit 66f8d6e

Please sign in to comment.