Skip to content

Commit

Permalink
ci: retry release with backoff (#518)
Browse files Browse the repository at this point in the history
- This should resolve the problem with releasing on CircleCI
- Added an exponential backoff to the release function
  • Loading branch information
TimoKramer authored Apr 26, 2022
1 parent 9f4004c commit 181e423
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,33 @@
(dd/deploy {:installer :remote :artifact jar-file
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}))

(defn fib [a b]
(lazy-seq (cons a (fib b (+ a b)))))

(defn fib-backoff [exec-fn test-fn]
(loop [retries (take 10 (fib 1 2))]
(let [result (exec-fn)]
(if (test-fn result)
result
(when-let [sleep-ms (first retries)]
(println "Retrying with remaining retries: " retries)
(println "Request returned: " result)
(Thread/sleep (* 1000 sleep-ms))
(recur (rest retries)))))))

(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 clojure.lang.ExceptionInfo e
(:status (ex-data e)))))

(defn release
[_]
(Thread/sleep 1000)
(-> (gh/overwrite-asset {:org "replikativ"
:repo (name lib)
:tag version
:commit current-commit
:file jar-file
:content-type "application/java-archive"})
(-> (fib-backoff try-release #(>= 400 %))
:url
println))

Expand Down

0 comments on commit 181e423

Please sign in to comment.