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

feat: rm leiningen #164

Merged
merged 35 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6d773c0
feat: rm leiningen
erdos Jul 18, 2024
0ae3ed7
wip: test on pr flow
erdos Jul 18, 2024
5d66cdf
make codecov work on pr flow
erdos Jul 18, 2024
5bcfd2e
wip: pr flow
erdos Jul 18, 2024
dada3ed
wip: pr flow
erdos Jul 18, 2024
150e3f5
wip: pr flow
erdos Jul 18, 2024
3e199cb
fix test
erdos Jul 18, 2024
1ac9a11
wip
erdos Jul 19, 2024
b2494ca
running java tests works
erdos Jul 20, 2024
65926af
junit tests
erdos Jul 20, 2024
da43990
ignore unused test cases
erdos Jul 20, 2024
b36a1db
fix: use clojure instead of clj in CI scripts
erdos Jul 20, 2024
f947852
kaocha publishes xml report
erdos Jul 20, 2024
26eadc6
work on visual test
erdos Jul 20, 2024
d2885dc
wip
erdos Jul 20, 2024
c39a153
Merge remote-tracking branch 'origin/master' into rm-lein
erdos Jul 20, 2024
0e04ca1
fix: visual test report path
erdos Jul 20, 2024
bf81dd9
feat: instrument specs ns when running tests
erdos Jul 20, 2024
d8cb6c0
feat: auto instrument for tests and coverage checks also
erdos Jul 20, 2024
f834763
feat: javadoc command
erdos Jul 21, 2024
1bf2edc
jar and uberjar works
erdos Jul 21, 2024
e3c83d3
feat: install command
erdos Jul 21, 2024
f388206
version is stored in deps.edn
erdos Jul 21, 2024
824fb10
fix: clojars publishing
erdos Jul 21, 2024
72c2669
introduce makefile
erdos Jul 21, 2024
967c01f
use more of makefile
erdos Jul 21, 2024
3680a2f
fix
erdos Jul 21, 2024
c633913
docs and javadocs
erdos Jul 21, 2024
bf44e14
wil
erdos Jul 21, 2024
a1eb644
fix: instrument
erdos Jul 22, 2024
8f8a944
exclude spec from codecov
erdos Jul 22, 2024
8470ba4
more requires
erdos Jul 22, 2024
9c338c3
more requires in codecov step also
erdos Jul 22, 2024
6af455e
fix: exclude spec ns from codecov report
erdos Jul 22, 2024
496693a
fix: codecov setup
erdos Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions .github/workflows/flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Clojure tools
uses: DeLaGuardo/[email protected]
with:
cli: latest
- name: Install dependencies
run: lein deps
run: make prepare
- name: Run Clojure Tests
run: lein test
run: make clj-test
- name: Run Java Tests
run: lein pom && mvn test --batch-mode --fail-at-end
run: make java-test
coverage:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Clojure tools
uses: DeLaGuardo/[email protected]
with:
cli: latest
- name: Coverage
run: lein coverage
run: make coverage
- name: Codecov
uses: codecov/codecov-action@v2
with:
Expand All @@ -33,13 +41,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: lein deps
- name: Install Clojure tools
uses: DeLaGuardo/[email protected]
with:
cli: latest
- name: Create jar and pom files
run: /
make prepare jar
cp ./target/classes/META-INF/maven/io.github.erdos/stencil-core/pom.xml ./pom.xml
cp ./target/stencil-core-*.jar ./stencil-core.jar
- name: Release Clojars
env:
CLOJARS_USER: ${{ secrets.CLOJARS_USER }}
CLOJARS_PASS: ${{ secrets.CLOJARS_PASS }}
run: lein deploy snapshots || echo skipping
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USER }}
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASS }}
run: clojure -X:deploy || echo skipping
docker_push:
needs: clojars_push
runs-on: ubuntu-latest
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Compile uberjar
run: lein uberjar
- name: Run javadoc tool
run: mkdir -p _site/javadoc && javadoc -d _site/javadoc --source-path ./java-src -cp target/stencil-core-*-standalone.jar -subpackages io.github.erdos.stencil
run: mkdir _site && make javadoc && cp -R target/javadoc _site
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build with Jekyll
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/pr_flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: lein deps
- name: Compile Java
run: lein javac
- name: Install Clojure tools
uses: DeLaGuardo/[email protected]
with:
cli: latest
- name: Coverage
run: lein coverage
run: make coverage
- name: Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./target/coverage/codecov.json
- name: Run Java Tests
run: lein pom && mvn test --batch-mode --fail-at-end
- name: Unit tests in Clojure
run: lein test
- name: Run unit tests
run: make clj-test java-test
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pr_visual_flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y libreoffice-core libreoffice-writer libreoffice-java-common imagemagick ghostscript --no-install-recommends
- name: Set PDF Policy
run: sudo sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml
- name: Install dependencies
run: lein deps
- name: Compile Java
run: lein javac
- name: Install Clojure tools
uses: DeLaGuardo/[email protected]
with:
cli: latest
- name: Test Clojure
run: lein test stencil.visual-test
run: make visual-test
- name: Archive diff png
uses: actions/upload-artifact@v3
if: failure()
Expand All @@ -35,5 +35,5 @@ jobs:
if: success() || failure()
with:
name: Visual Tests
path: target/visual-reports/*.xml
path: target/surefire-reports/*.xml
reporter: java-junit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ junit.xml
.lsp/
*.jfr
.clj-kondo/
/_site/
/_site/
.cpcache/
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.PHONY: clean prepare lint pom jar uberjar javadoc compile clj-test java-test visual-test coverage test all
.DEFAULT_GOAL := all

clean:
clojure -T:build clean

prepare:
clojure -P

lint: clean
clojure -M:lint/clj-kondo

pom: clean
clojure -T:build pom

jar: clean
clojure -T:build jar

uberjar: clean
clojure -T:build uber

javadoc: clean
clojure -T:build javadoc

compile: clean prepare
clojure -T:build compile-java

clj-test: clean compile
clojure -M:test

java-test: clean
clojure -T:build java-test

visual-test: clean compile
clojure -M:test --focus stencil.visual-test

coverage: clean prepare compile
clojure -M:coverage

test: clean prepare compile clj-test java-test visual-test

all: clean compile lint test javadoc uberjar
112 changes: 112 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
(ns build
(:require [clojure.tools.build.api :as b]
[clojure.tools.build.util.file :as file]))

(def build-folder "target")
(def jar-content (str build-folder "/classes"))
(def javadoc-dir "target/javadoc")

(def basis (b/create-basis {:project "deps.edn"}))

(def version (-> basis :aliases :stencil/version (doto assert)))

(def lib 'io.github.erdos/stencil-core)

(def jar-file-name (format "%s/%s-%s.jar" build-folder (name lib) version))
(def uber-file-name (format "%s/%s-%s-standalone.jar" build-folder (name lib) version))

(defn clean [opts]
(b/delete {:path build-folder})
(println (format "Build folder \"%s\" removed" build-folder))
opts)

(defn compile-java [opts]
(clean opts)
(println :should-compile-java-here)
(b/javac {:src-dirs ["java-src"]
:basis basis
:class-dir jar-content
:javac-opts ["-source" "8" "-target" "8"]})
(b/copy-file {:src "java-src/io/github/erdos/stencil/standalone/help.txt"
:target "target/classes/io/github/erdos/stencil/standalone/help.txt"})
(spit (str jar-content "/stencil-version") version)
opts)

(defn javadoc [opts]
(file/ensure-dir javadoc-dir)
(let [src-dirs ["java-src"]
args ["-d" javadoc-dir]
java-files (mapcat #(file/collect-files (b/resolve-path %) :collect (file/suffixes ".java")) src-dirs)
args (into args (map str) java-files)
tool (javax.tools.ToolProvider/getSystemDocumentationTool)
exit (.run tool nil nil nil (into-array String args))]
(if (zero? exit)
opts
(throw (ex-info "Javadoc command error" {:exit exit})))))

(defn pom [opts]
(println "Generating pom.xml file")
(b/write-pom
{:class-dir jar-content
:basis basis
:version version
:lib lib
:pom-data
[[:licenses
[:license
[:name "Eclipse Public License - v 2.0"]
[:url "https://www.eclipse.org/legal/epl-2.0/"]
[:distribution "repo"]]]]})
opts)

(defn jar [opts]
(clean opts)
(compile-java opts)
(pom opts)
(b/copy-dir {:src-dirs ["src"] :target-dir jar-content})
(b/jar {:class-dir jar-content
:jar-file jar-file-name})
(println "Built JAR file")
opts)

(defn java-test [_]
(def basis (b/create-basis {:project "deps.edn" :aliases [:junit]}))

(println "Running Java test cases")
(println "- compiling java sources")
(b/javac {:src-dirs ["java-src" "java-test"]
:basis basis
:class-dir jar-content
:javac-opts ["-source" "8" "-target" "8"]})
(println "- compiling clj sources")
(b/compile-clj {:basis basis
:src-dirs ["src"]
:class-dir jar-content
:bindings {#'*warn-on-reflection* true}})
(-> {:basis basis
:main "org.junit.platform.console.ConsoleLauncher"
:main-args ["-p" "io.github.erdos.stencil"
"--fail-if-no-tests"
"--reports-dir=target/surefire-reports"]}
(b/java-command)
(b/process)
(#(when-not (zero? (:exit %)) (throw (ex-info "junit error" %)))))
(println "Done"))

(defn uber [opts]
(jar opts)
(b/uber {:class-dir jar-content
:uber-file uber-file-name
:basis basis
:main 'io.github.erdos.stencil.Main})
(println (format "Uber file created: \"%s\"" uber-file-name))
opts)

(defn install [opts]
(jar opts)
(b/install {:basis basis
:lib lib
:version version
:class-dir jar-content
:jar-file jar-file-name})
opts)
50 changes: 50 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
org.slf4j/slf4j-api {:mvn/version "2.0.9"}}
:paths ["src" "target/classes"]
:aliases
{:stencil/version "0.5.10-SNAPSHOT"

:build
{:deps {org.clojure/clojure {:mvn/version "1.12.0-beta1"}
io.github.clojure/tools.build {:git/tag "v0.10.5" :git/sha "2a21b7a"}}
:ns-default build}

:junit
{:extra-deps {junit/junit {:mvn/version "4.13.2"}
org.slf4j/slf4j-simple {:mvn/version "1.7.32"}
org.junit.platform/junit-platform-console-standalone {:mvn/version "1.10.3"}}
:extra-paths ["target/classes" "test-resources"]}

:lint/clj-kondo
{:extra-deps {clj-kondo/clj-kondo {:mvn/version "2024.05.24"}}
:main-opts ["-m" "clj-kondo.main" "--lint" "src"]}

:coverage
{:extra-deps {cloverage/cloverage {:mvn/version "1.2.4"}}
:extra-paths ["test" "test-resources"]
:main-opts ["-m" "cloverage.coverage"
"--codecov"
"--exclude-call" "clojure.core/assert"
"--exclude-call" "stencil.util/trace"
"--exclude-call" "stencil.util/fail"
"--exclude-call" "clojure.spec.alpha/def"
"-p" "src" "-s" "test"]}

:test
{:extra-paths ["test" "test-resources"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.87.1366"}
lambdaisland/kaocha-junit-xml {:mvn/version "1.17.101"}
org.slf4j/slf4j-simple {:mvn/version "1.7.32"}}
:main-opts ["-e" "(require 'stencil.api 'stencil.process 'stencil.model) ((requiring-resolve 'stencil.spec/instrument))"
"-m" "kaocha.runner"
"--plugin" "kaocha.plugin/junit-xml"
"--junit-xml-file" "target/surefire-reports/kaocha.xml"]
:jvm-opts ["-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"]}

:deploy
{:extra-deps {slipset/deps-deploy {:mvn/version "0.2.2"}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote
:sign-releases? false ;; TODO for later
:artifact "stencil-core.jar"}}}}
2 changes: 1 addition & 1 deletion docs/Standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It may also be easier if your application's architecture is not written in java.

## Building

Build the project with the `lein uberjar` command to get a standalone application. The built output will be found in the `target` directory.
Build the project with the `make uberjar` command to get a standalone application. The built output will be found in the `target` directory.

Run the file with the `java -jar *-standalone.jar` command.

Expand Down
Loading
Loading