diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..0baf3a8a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,55 @@ +# Clojure CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-clojure/ for more details +# +version: 2.1 + +jobs: + deploy: + docker: + - image: cimg/clojure:1.11.1 + working_directory: ~/repo + # resource_class: large + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "deps.edn" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + # - run: + # name: Run JVM tests + # command: | + # script/test + # script/run_lib_tests + - run: + name: Create uberjar + command: | + script/build/uberjar + mkdir -p /tmp/release + DIR=/tmp/release script/ci/release + - store_artifacts: + path: /tmp/release + destination: release + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "deps.edn" }} + + +workflows: + version: 2 + ci: + jobs: + # - short-if-irrelevant + # - jvm: + # requires: + # - short-if-irrelevant + - deploy + # filters: + # branches: + # only: master + # requires: + # - jvm + diff --git a/.gitignore b/.gitignore index f300754a..40609fe8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ db-test/ convex-db convex-web.sublime-workspace .clj-kondo -*.pfx \ No newline at end of file +*.pfx +build/** \ No newline at end of file diff --git a/build.clj b/build.clj new file mode 100644 index 00000000..5157afba --- /dev/null +++ b/build.clj @@ -0,0 +1,52 @@ +(ns build + (:require + [clojure.tools.build.api :as b])) + +;; More info see https://clojure.org/guides/tools_build + +;; Project settings + +(def lib 'convex/convex-web) +(def main-class 'convex-web.core) +(def src-dirs ["src/main/clojure"]) +(def resource-dirs ["src/main/resources"]) + +;; General settings + +(def version (format "0.1.%s" (b/git-count-revs nil))) + +(def build-path "build") +(def class-dir (str build-path "/classes")) + +(def basis (b/create-basis {:project "deps.edn"})) +(def dirs-to-copy (concat src-dirs resource-dirs)) + + +(defn clean [_] + (b/delete {:path build-path})) + + +(def uber-file (format "%s-%s-standalone.jar" (name lib) version)) +(def uber-full-path (str build-path "/" uber-file)) +(def build-uberjar-name-file (str build-path "/" "UBERJAR_FILENAME")) + +(defn uberjar [{:as opts}] + (clean nil) + (b/write-pom {:class-dir class-dir + :lib lib + :version version + :basis basis + :src-dirs src-dirs}) + (b/copy-dir {:src-dirs dirs-to-copy + :target-dir class-dir}) + ;; Compile not necesary, we can skip this + (b/compile-clj {:basis basis + :src-dirs src-dirs + :class-dir class-dir + :java-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory"]}) + (b/uber {:class-dir class-dir + :uber-file uber-full-path + :basis basis + :main main-class}) + ;; Write filename to specific file for CI + (spit build-uberjar-name-file uber-file)) \ No newline at end of file diff --git a/deps.edn b/deps.edn index de37a617..abdd7e30 100644 --- a/deps.edn +++ b/deps.edn @@ -147,6 +147,9 @@ :logback-prod {:jvm-opts ["-Dlogback.configurationFile=logback/logback-prod.xml"]} + ;; -- Build configuration + :build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.2" :git/sha "ba1a2bf"}} + :ns-default build} ;; -- Check outdated dependencies ;; clj -M:outdated diff --git a/script/build/uberjar b/script/build/uberjar new file mode 100755 index 00000000..d8d7ec51 --- /dev/null +++ b/script/build/uberjar @@ -0,0 +1,3 @@ +#!/bin/sh -x + +clojure -T:build uberjar \ No newline at end of file diff --git a/script/ci/release b/script/ci/release new file mode 100755 index 00000000..751eb621 --- /dev/null +++ b/script/ci/release @@ -0,0 +1,6 @@ +#!/bin/sh -x + +UBERJAR_FILENAME=$(cat build/UBERJAR_FILENAME) +RELEASE="$DIR/$UBERJAR_FILENAME" +cp build/${UBERJAR_FILENAME} $RELEASE +java -cp "$RELEASE" clojure.main -e '(println "OK")' diff --git a/src/main/clojure/convex_web/core.clj b/src/main/clojure/convex_web/core.clj index d2de0a63..ae0a384e 100644 --- a/src/main/clojure/convex_web/core.clj +++ b/src/main/clojure/convex_web/core.clj @@ -4,7 +4,8 @@ [clojure.tools.logging :as log]) (:import - (convex.core.util Shutdown))) + (convex.core.util Shutdown)) + (:gen-class)) (def system nil)