Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate: leiningen -> tools.deps, build.edn, kaocha #20

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
6 changes: 1 addition & 5 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,22 @@ jobs:
architecture: x64

- uses: DeLaGuardo/setup-clojure@master
with:
lein: '2.11.2'

- 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') }}
conao3 marked this conversation as resolved.
Show resolved Hide resolved
restore-keys: |
clj-cache-test-

- name: Run tests
run: lein test-integration
run: make test-integration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run also make test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved at 82597bb


- name: Run cloverage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow uses lein command yet.
Could you delete or fix like below?
https://github.com/liquidz/antq/blob/main/.github/workflows/coverage.yml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved at 82597bb

run: |
Expand Down
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ lint:

.PHONY: install
install:
lein install
clojure -T:build install

.PHONY: test
test:
lein test-all
clojure -M:dev:test unit
clojure -M:dev:1.9:test unit
clojure -M:dev:1.10:test unit

.PHONY: test-integration
test-integration:
lein test-integration
clojure -M:dev:test it
clojure -M:dev:1.9:test it
clojure -M:dev:1.10:test it

.PHONY: outdated
outdated:
lein antq

.PHONY: coverage
coverage:
lein cloverage
clojure -Tantq outdated

.PHONY: benchmark
benchmark:
Expand All @@ -36,8 +36,8 @@ benchmark:

.PHONY: deploy
deploy:
lein deploy clojars
clojure -T:build deploy

.PHONY: clean
clean:
lein clean
rm -rf target
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete also .cpcache directory.

Copy link
Member Author

@conao3 conao3 Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved at 08a7e2d

2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(ns build
(:require
[clojure.string :as str]
[build-edn.main]))

(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)
32 changes: 32 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{: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"]
:global-vars {*warn-on-reflection* true}}

:test {:main-opts ["-m" "kaocha.runner"]}

:build {:deps {com.github.liquidz/build.edn {:mvn/version "0.11.266"}}
:ns-default build}}}
4 changes: 2 additions & 2 deletions integration/test/tarayo/integration/send_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
(with-open [conn (core/connect mailhog-server)]
(core/send! conn {:from from :to "[email protected]" :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])
Expand All @@ -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
Expand Down
43 changes: 0 additions & 43 deletions project.clj

This file was deleted.

2 changes: 1 addition & 1 deletion resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.7
0.2.8
22 changes: 11 additions & 11 deletions test/tarayo/mail/mime/multipart/body_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@

(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))
(t/is (= ["text/plain"]
(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))
Expand All @@ -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 (= "<foo-id>" (.getContentID bp)))))
Expand All @@ -82,15 +82,15 @@
(.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))
(t/is (= ["base64"] (seq (.getHeader bp "Content-Transfer-Encoding"))))))

(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"}
Expand Down
4 changes: 2 additions & 2 deletions test/tarayo/mail/mime/multipart_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests.edn
Original file line number Diff line number Diff line change
@@ -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"]}}