diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 6e67a5f..50a8520 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -45,27 +45,23 @@ jobs: - uses: DeLaGuardo/setup-clojure@master with: - lein: '2.11.2' + cli: 1.11.3.1463 - name: Show versions run: | java -version - lein version - name: Cache dependencies uses: actions/cache@v4 with: path: | ~/.m2 - ~/.lein - key: clj-cache-test-${{ hashFiles('project.clj') }} + key: clj-cache-test-${{ hashFiles('deps.edn') }} restore-keys: | clj-cache-test- - name: Run tests - run: lein test-integration + run: make test - - name: Run cloverage - run: | - lein cloverage --codecov - bash <(curl -s https://codecov.io/bash) + - name: Upload reports + uses: codecov/codecov-action@v4 diff --git a/Makefile b/Makefile index 66404d6..cdfa38a 100644 --- a/Makefile +++ b/Makefile @@ -11,23 +11,29 @@ lint: .PHONY: install install: - lein install + clojure -T:build install .PHONY: test test: - lein test-all + clojure -M:dev:1.9:test + clojure -M:dev:1.10:test + clojure -M:dev:test + +.PHONY: test-unit +test-unit: + clojure -M:dev:1.9:test unit + clojure -M:dev:1.10:test unit + clojure -M:dev:test unit .PHONY: test-integration test-integration: - lein test-integration + clojure -M:dev:1.9:test it + clojure -M:dev:1.10:test it + clojure -M:dev:test it .PHONY: outdated outdated: - lein antq - -.PHONY: coverage -coverage: - lein cloverage + clojure -Tantq outdated .PHONY: benchmark benchmark: @@ -36,8 +42,8 @@ benchmark: .PHONY: deploy deploy: - lein deploy clojars + clojure -T:build deploy .PHONY: clean clean: - lein clean + rm -rf target .cpcache diff --git a/README.adoc b/README.adoc index b849e3b..add74fd 100644 --- a/README.adoc +++ b/README.adoc @@ -216,7 +216,7 @@ Example using https://github.com/bguthrie/shrubbery[shrubbery]. == License -Copyright 2020-2023 Toyokumo,Inc. +Copyright 2020-2024 Toyokumo,Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/build.clj b/build.clj new file mode 100644 index 0000000..20e2aaf --- /dev/null +++ b/build.clj @@ -0,0 +1,33 @@ +(ns build + (:require + [build-edn.main] + [clojure.string :as str])) + +(def ^:private config + {:lib 'toyokumo/tarayo + :version (str/trim (slurp "resources/VERSION")) + :description "SMTP client library for Clojure. That’s it." + :url "https://github.com/toyokumo/tarayo" + :licenses [{:name "Apache, Version 2.0" + :url "http://www.apache.org/licenses/LICENSE-2.0"}]}) + +(defmacro defwrapper + [fn] + `(defn ~fn [m#] + (~(symbol (str "build-edn.main/" fn)) (merge config m#)))) + +(defwrapper pom) +(defwrapper jar) +(defwrapper java-compile) +(defwrapper uberjar) +(defwrapper install) +(defwrapper deploy) +(defwrapper update-documents) +(defwrapper lint) +(defwrapper bump-patch-version) +(defwrapper bump-minor-version) +(defwrapper bump-major-version) +(defwrapper add-snapshot) +(defwrapper remove-snapshot) +(defwrapper execute) +(defwrapper help) diff --git a/deps.edn b/deps.edn new file mode 100644 index 0000000..56d70e8 --- /dev/null +++ b/deps.edn @@ -0,0 +1,31 @@ +{:paths ["src" "resources"] + + :deps + {org.clojure/clojure {:mvn/version "1.11.1"} + camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"} + org.eclipse.angus/angus-mail {:mvn/version "2.0.3"} + commons-codec/commons-codec {:mvn/version "1.16.1"} + jakarta.mail/jakarta.mail-api {:mvn/version "2.1.3"} + nano-id/nano-id {:mvn/version "1.1.0"} + org.apache.tika/tika-core {:mvn/version "2.9.1"}} + + :aliases + {:1.9 {:override-deps {org.clojure/clojure {:mvn/version "1.9.0"}}} + :1.10 {:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}} + + :dev {:extra-deps {com.github.kirviq/dumbster {:mvn/version "1.7.1"} + testdoc/testdoc {:mvn/version "1.4.1"} + ;; for stubbing + com.gearswithingears/shrubbery {:mvn/version "0.4.1"} + lambdaisland/kaocha {:mvn/version "1.91.1392"} + lambdaisland/kaocha-cloverage {:mvn/version "1.1.89"} + lambdaisland/deep-diff2 {:mvn/version "2.11.216"} + ;; for integration test + org.clojure/data.json {:mvn/version "2.5.0"} + http-kit/http-kit {:mvn/version "2.7.0"}} + :extra-paths ["test" "dev/src" "dev/resources"]} + + :test {:main-opts ["-m" "kaocha.runner"]} + + :build {:deps {com.github.liquidz/build.edn {:mvn/version "0.11.266"}} + :ns-default build}}} diff --git a/dev/src/user.clj b/dev/src/user.clj new file mode 100644 index 0000000..0a6f5aa --- /dev/null +++ b/dev/src/user.clj @@ -0,0 +1,3 @@ +(ns user) + +(alter-var-root #'*warn-on-reflection* (constantly true)) diff --git a/integration/test/tarayo/integration/send_test.clj b/integration/test/tarayo/integration/send_test.clj index 96b1aac..ff433b8 100644 --- a/integration/test/tarayo/integration/send_test.clj +++ b/integration/test/tarayo/integration/send_test.clj @@ -85,7 +85,7 @@ (with-open [conn (core/connect mailhog-server)] (core/send! conn {:from from :to "alice@example.com" :subject "hello" :body [{:content-type "text/plain" :content "world"} - {:content (io/file "project.clj")}]})) + {:content (io/file "build.clj")}]})) (let [resp (find-mail-by-from from) item (get-in resp [:items 0]) mime-parts (->> (get-in item [:mime :parts]) @@ -104,7 +104,7 @@ (let [{:keys [headers body]} (second mime-parts)] (t/is (= ["text/x-clojure"] (:content-type headers))) - (t/is (= ["attachment; filename=project.clj"] (:content-disposition headers))) + (t/is (= ["attachment; filename=build.clj"] (:content-disposition headers))) (t/is (and (string? body) (not (str/blank? body)))))))) (t/deftest send-multipart-alternative-mail-test diff --git a/project.clj b/project.clj deleted file mode 100644 index ea020d7..0000000 --- a/project.clj +++ /dev/null @@ -1,43 +0,0 @@ -(defproject toyokumo/tarayo - #=(clojure.string/trim #=(slurp "resources/VERSION")) - :description "SMTP client library for Clojure. That’s it." - :url "https://github.com/toyokumo/tarayo" - :license {:name "Apache, Version 2.0" - :url "http://www.apache.org/licenses/LICENSE-2.0"} - - :repositories [["clojars" {:url "https://clojars.org/repo" - :sign-releases false}]] - - :dependencies [[camel-snake-kebab "0.4.3"] - [org.eclipse.angus/angus-mail "2.0.3"] - [commons-codec "1.16.1"] - [jakarta.mail/jakarta.mail-api "2.1.3"] - [nano-id "1.1.0"] - [org.apache.tika/tika-core "2.9.1"]] - - :profiles - {:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]} - :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]} - :1.10 {:dependencies [[org.clojure/clojure "1.10.3"]]} - - :dev {:dependencies [[org.clojure/clojure "1.11.1"] - [com.github.kirviq/dumbster "1.7.1"] - [testdoc "1.4.1"] - ;; for stubbing - [com.gearswithingears/shrubbery "0.4.1"]] - :source-paths ["dev/src" "src"] - :resource-paths ["dev/resources"] - :global-vars {*warn-on-reflection* true}} - - :it {:dependencies [[org.clojure/data.json "2.5.0"] - [http-kit "2.7.0"]] - :test-paths ["integration/test"]} - - :antq {:dependencies [[com.github.liquidz/antq "RELEASE"]]}} - :aliases - {"test-all" ["with-profile" "1.8,dev:1.9,dev:1.10,dev:dev" "test"] - "test-integration" ["with-profile" "1.9,dev,it:1.10,dev,it" "test"] - "antq" ["with-profile" "+antq" "run" "-m" "antq.core"]} - - :plugins [[lein-cloverage "1.2.4"]] - :cloverage {:ns-exclude-regex [#"benchmark"]}) diff --git a/resources/VERSION b/resources/VERSION index b003284..a45be46 100644 --- a/resources/VERSION +++ b/resources/VERSION @@ -1 +1 @@ -0.2.7 +0.2.8 diff --git a/test/tarayo/mail/mime/multipart/body_test.clj b/test/tarayo/mail/mime/multipart/body_test.clj index 2348d86..429920e 100644 --- a/test/tarayo/mail/mime/multipart/body_test.clj +++ b/test/tarayo/mail/mime/multipart/body_test.clj @@ -27,15 +27,15 @@ (t/deftest make-bodypart-test (t/testing "inline" - (let [part {:content (io/file "project.clj") :id (str (gensym))} + (let [part {:content (io/file "build.clj") :id (str (gensym))} bp (sut/make-bodypart part "UTF-8")] (t/is (instance? MimeBodyPart bp)) (t/is (= ["text/x-clojure"] (seq (.getHeader bp "Content-Type")))) - (t/is (= "project.clj" (.getFileName bp))) + (t/is (= "build.clj" (.getFileName bp))) (t/is (= "inline" (.getDisposition bp))))) (t/testing "specify content-type" - (let [part {:content (io/file "project.clj") + (let [part {:content (io/file "build.clj") :content-type "text/plain"} bp (sut/make-bodypart part "UTF-8")] (t/is (instance? MimeBodyPart bp)) @@ -43,23 +43,23 @@ (seq (.getHeader bp "Content-Type")))))) (t/testing "attachment" - (let [part {:content (io/file "project.clj")} + (let [part {:content (io/file "build.clj")} bp (sut/make-bodypart part "UTF-8")] (t/is (instance? MimeBodyPart bp)) (t/is (= ["text/x-clojure"] (seq (.getHeader bp "Content-Type")))) - (t/is (= "project.clj" (.getFileName bp))) + (t/is (= "build.clj" (.getFileName bp))) (t/is (= "attachment" (.getDisposition bp))))) (t/testing "attachment by path string" - (let [part {:content (io/file "project.clj")} + (let [part {:content (io/file "build.clj")} bp (sut/make-bodypart part "UTF-8")] (t/is (instance? MimeBodyPart bp)) (t/is (= ["text/x-clojure"] (seq (.getHeader bp "Content-Type")))) - (t/is (= "project.clj" (.getFileName bp))) + (t/is (= "build.clj" (.getFileName bp))) (t/is (= "attachment" (.getDisposition bp))))) (t/testing "overwriting attachment filename" - (let [part {:content (io/file "project.clj") + (let [part {:content (io/file "build.clj") :filename "overwrite.clj"} bp (sut/make-bodypart part "UTF-8")] (t/is (instance? MimeBodyPart bp)) @@ -68,7 +68,7 @@ (t/is (= "attachment" (.getDisposition bp)))))) (t/deftest make-bodypart-with-content-id-test - (let [part {:content (io/file "project.clj") :id "foo-id"} + (let [part {:content (io/file "build.clj") :id "foo-id"} bp (sut/make-bodypart part "UTF-8")] (t/is (instance? MimeBodyPart bp)) (t/is (= "" (.getContentID bp))))) @@ -82,7 +82,7 @@ (.getFileName bp))))) (t/deftest make-bodypart-with-content-encoding-test - (let [part {:content (io/file "project.clj") + (let [part {:content (io/file "build.clj") :content-encoding "base64"} bp (sut/make-bodypart part "UTF-8")] (t/is (instance? MimeBodyPart bp)) @@ -90,7 +90,7 @@ (t/deftest make-bodypart-with-bytes-attachment-test (t/testing "positive" - (let [file (io/file "project.clj") + (let [file (io/file "build.clj") part {:content (Files/readAllBytes (.toPath file)) :content-type "text/x-clojure" :filename "foo.clj"} diff --git a/test/tarayo/mail/mime/multipart_test.clj b/test/tarayo/mail/mime/multipart_test.clj index cf0e2a6..94f1845 100644 --- a/test/tarayo/mail/mime/multipart_test.clj +++ b/test/tarayo/mail/mime/multipart_test.clj @@ -13,7 +13,7 @@ (t/deftest make-multipart-test (let [mp (sut/make-multipart "mixed" [{:content-type "text/html" :content "foo"} - {:content (io/file "project.clj")}] + {:content (io/file "build.clj")}] "UTF-8")] (t/is (instance? MimeMultipart mp)) (t/is (= 2 (.getCount mp))) @@ -28,7 +28,7 @@ (t/is (= "foo" (.getContent html))) (t/is (= "text/html; charset=UTF-8" (.getContentType html))) - (t/is (= "project.clj" (.getFileName attach))) + (t/is (= "build.clj" (.getFileName attach))) (t/is (= "text/x-clojure" (.getContentType attach)))))) (t/deftest make-multipart-alternative-test diff --git a/tests.edn b/tests.edn new file mode 100644 index 0000000..da0fd73 --- /dev/null +++ b/tests.edn @@ -0,0 +1,14 @@ +#kaocha/v1 +{:tests [{:id :unit + :test-paths ["test"]} + {:id :it + :test-paths ["integration/test"]}] + :fail-fast? true + :color? true + :reporter [kaocha.report/documentation] + :plugins [:kaocha.plugin/profiling + :kaocha.plugin/print-invocations + :kaocha.plugin/cloverage] + + :cloverage/opts {:src-ns-path ["src"] + :test-ns-path ["test"]}}