Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
caumond committed Oct 24, 2023
1 parent 8a6b141 commit a096b08
Show file tree
Hide file tree
Showing 68 changed files with 1,055 additions and 1,452 deletions.
170 changes: 72 additions & 98 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -1,98 +1,72 @@
{:paths ["src/clj"]
:deps {hephaistox/automaton-build-app {:git/url "[email protected]:hephaistox/automaton-build-app.git"
:sha "33c8941cb6df63006bafaaf1d5e7f0383b10468a"}}

:tasks {:requires [[automaton-build-app.log :as build-log]
[automaton-build-app.os.commands :as build-cmds]
[babashka.fs :as fs]]
:init (do
(defn- cicd? []
(System/getenv "CI"))

(defn qualified-name [s]
(apply str
(interpose "/"
((juxt namespace name) (symbol s)))))

(defn- task-name []
(-> (babashka.tasks/current-task)
:name))

(defn run-bb
"Run the `body-fn` on the current bb environment"
[body-fn]
(build-log/trace-format "Run %s task on bb" (task-name))
(let [ns (-> (symbol body-fn)
namespace
symbol)]
(require ns)
((resolve body-fn) {:command-line-args *command-line-args*})))

(defn run-clj
[body-fn]
(build-log/trace-format "Run %s task on clj" (task-name))
(build-cmds/execute-and-trace ["clojure" "-X:build" (qualified-name body-fn)
:command-line-args *command-line-args*]))

(defn dispatch
"Execute the body-fn directy in currently running bb env
* `body` body to execute
* `executing-pf` could be :bb or :clj, the task will be executed on one or the other"
[body-fn executing-pf]
(if (= :clj executing-pf)
(run-clj body-fn)
(run-bb body-fn)))

(defn execute-task
"Run the function and manage
Params:
* `body` body to execute
* `executing-pf` (Optional, default = :bb) could be :bb or :clj, the task will be executed on one or the other"
[body-fn & executing-pf]
(try
(build-log/info-format "Run %s task" (-> (current-task)
:name))
(dispatch body-fn
(first executing-pf))
(catch Exception e
(println (format "Error during execution of `%s`, %s`" (:name (current-task)) (pr-str (ex-message e))))
(if (cicd?)
(println e)
(let [file (fs/create-temp-file {:suffix ".edn"})]
(println (format "See details in `%s`" (.toString (.toAbsolutePath file))))
(spit (fs/file file) (prn-str e))
""))
(System/exit 1)))))

blog {:doc "Transforms md file to pdf based on edn file"
:task (execute-task 'automaton-build-app.tasks.doc/blog-task :clj)}

clean {:doc "Clean cache files for compiles, and logs"
:task (execute-task 'automaton-build-app.tasks.clean/clean)}

clean-hard {:doc "Clean all files which are not under version control (it doesn't remove untracked file or staged files if there are eligible to `git add .`)"
:task (execute-task 'automaton-build-app.tasks.clean/clean-hard)}

code-doc {:doc "Create the documentation of the app"
:task (execute-task 'automaton-build-app.tasks.code-helpers-clj/code-doc :clj)}

compile-to-jar {:doc "Compile that code to a jar"
:task (execute-task 'automaton-build-app.tasks.code-helpers/compile-to-jar :clj)}

gha {:doc "Github action command - is launched automatically by github"
:task (execute-task 'automaton-build-app.tasks.test/gha :clj)}

gha-lconnect {:doc "Connect to a local container running this code"
:task (execute-task 'automaton-build-app.tasks.test/gha)}

lconnect {:doc "Local connect - repl"
:task (execute-task 'automaton-build-app.tasks.code-helpers/lconnect)}

ltest {:doc "Local test"
:task (execute-task 'automaton-build.app.test/ltest)}

push {:doc "Push this repo"
:task (execute-task 'automaton-build-app.tasks.publication/push-from-local :clj)}

update-deps {:doc "Update the dependencies, cider-nrepl and refactor are to be updated manually"
:task (execute-task 'automaton-build-app.tasks.code-helpers-clj/update-deps :clj)}}}
{:deps {hephaistox/automaton-build-app
{:local/root "../../automaton/automaton_build_app"}},
:paths [],
:tasks
{:enter (let [task-name (-> (babashka.tasks/current-task)
:name
str)]
(def execute-task
(partial build-task-helper/execute-task
task-name
(build-task-helper/enter-tasks task-name {})))),
:init (build-task-helper/init-tasks),
:requires [[automaton-build-app.tasks-helper :as build-task-helper]],
blog {:doc "Transforms md file to pdf based on edn file",
:task (execute-task 'automaton-build-app.tasks.doc-clj/blog-task
{:executing-pf :clj})},
clean {:doc "Clean cache files for compiles, and logs",
:task (execute-task 'automaton-build-app.tasks.clean/clean)},
clean-hard
{:doc
"Clean all files which are not under version control (it doesn't remove untracked file or staged files if there are eligible to `git add .`)",
:task (execute-task 'automaton-build-app.tasks.clean/clean-hard)},
code-doc {:doc "Create the documentation of the app",
:task (execute-task 'automaton-build-app.tasks.doc-clj/code-doc
{:executing-pf :clj})},
compile-to-jar
{:doc "Compile that code to a jar",
:task (execute-task
'automaton-build-app.tasks.code-helpers-clj/compile-to-jar
{:executing-pf :clj})},
container-clear
{:doc "Clear all local containers",
:task
(execute-task
'automaton-build-app.tasks.container-publication/container-clean)},
container-list
{:doc "List all available containers",
:task
(execute-task
'automaton-build-app.tasks.container-publication/container-list)},
gha {:doc "Github action command - is launched automatically by github",
:task (execute-task 'automaton-build-app.tasks.test-clj/gha
{:executing-pf :clj})},
gha-lconnect {:doc "Connect to a local container running this code",
:task (execute-task
'automaton-build-app.tasks.test/gha-lconnect)},
la {:doc "Local acceptance test",
:task (execute-task 'automaton-build-app.tasks.test/la)},
lconnect {:doc "Local connect - repl",
:task (execute-task
'automaton-build-app.tasks.code-helpers/lconnect)},
ltest {:doc "Local test",
:task (execute-task 'automaton-build-app.tasks.test/ltest)},
publish
{:doc "Publish the container, useful to push the github container itself",
:task
(execute-task
'automaton-build-app.tasks.container-publication/push-gha-from-local)},
push {:doc "Push this repo",
:task (execute-task
'automaton-build-app.tasks.publication-clj/push-from-local
{:executing-pf :clj})},
report {:doc "Creates the reports of code analyzis",
:task (execute-task
'automaton-build-app.tasks.code-analyze-clj/reports
{:executing-pf :clj})},
update-deps
{:doc
"Update the dependencies, cider-nrepl and refactor are to be updated manually",
:task (execute-task
'automaton-build-app.tasks.code-helpers-clj/update-deps
{:executing-pf :clj})}}}
14 changes: 12 additions & 2 deletions build_config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@
:branch "main"}
:as-lib hephaistox/automaton-core
:major-version "1.2.%s"
:gha-container {:repo-url "[email protected]:hephaistox/gha_image.git"
:repo-branch "main"
:account "hephaistox"
:workflows [[".github/workflows/commit_validation.yml" "gha-automaton-core"]]}
:shadow-cljs {:target-build nil}
:jar {:class-dir "target/classes"
:excluded-aliases #{}
:target-filename "target/%s-%s.jar"}}
:lconnect {:aliases [:common-test :env-development-repl]}
:ltest {:aliases [:env-development-test :common-test]}
:la {:selected-tasks ["blog" "clean" "clean-hard" "code-doc" "compile-to-jar" "container-clear" "container-list" "gha" "gha-lconnect" "ltest" "publish-gha-container" "push" "report" "update-deps"]}
:customer-materials {:html-dir "tmp/html"
:dir "customer_materials"
:pdf-dir "tmp/pdf"}
:container-repo {:account "hephaistox"}
:doc {:dir "docs"
:archi {:dir "docs/archi/"}
:code-stats {:output-file "docs/code/stats.md"}
:reports {:output-files {:automaton-build-app.code-helpers.test-toolings/comments "XX"}}
:reports {:output-files {:comments "docs/code/comments.edn"
:alias "docs/code/alias.edn"
:css "docs/code/css.edn"
:deps-ns "docs/code/deps-ns.svg"
:deps "docs/code/deps.png"
:ns "docs/code/ns.png"}}
:code-doc {:dir "docs/code"
:title "Build app automaton"
:description "Autonomous project to build an hephaistox app"}}
Expand Down
80 changes: 40 additions & 40 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,41 +1,4 @@
{:aliases
{:common-test {:exec-fn cognitect.test-runner.api/test
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner",
:sha "7284cda41fb9edc0f3bc6b6185cfb7138fc8a023"},
org.clojure/tools.namespace #:mvn{:version "1.4.4"},
org.clojure/tools.reader #:mvn{:version "1.3.6"}}}

:env-development-repl {:extra-paths ["env/development/resources"
"env/development/src/clj"
"env/development/src/cljc"]
:extra-deps {cider/cider-nrepl {:mvn/version "0.21.1"}
org.clojure/core.async {:mvn/version "1.6.681"}}
:main-opts ["-m" "automaton-core.repl-core"]
:jvm-opts ["-Dheph-conf=env/development/config.edn"
"-Dheph-common-conf=env/common_config.edn"]},

:env-development-test {:jvm-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory"
;;TODO I don't get where I'm wrong, shouldn't it suppose to disable logs like that, it's like the files are found, but the log is still printed
"-Dlog4j.configurationFile=resources/log_config/appenders.properties,resources/log_config/logging-tests.properties"
"-Dheph-conf=env/development/config.edn"
"-Dheph-common-conf=env/common_config.edn"],
:extra-paths ["test/clj"
"test/cljc"
"test/resources"]
:main-opts ["-m" "cognitect.test-runner"
"-r" ".*-test.*"
"-d" "test/clj"
"-d" "test/cljc"]}

:build {:extra-deps {hephaistox/automaton-build-app {:git/url "[email protected]:hephaistox/automaton-build-app.git"
:sha "33c8941cb6df63006bafaaf1d5e7f0383b10468a"}}}

:cljs-deps {:extra-paths ["src/cljs" "src/cljc" "resources" "test/cljs" "test/cljc"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.25.8"}
cider/cider-nrepl {:mvn/version "0.21.1"}
binaryage/devtools {:mvn/version "1.0.7"}}}}

:deps {babashka/fs #:mvn{:version "0.4.19"},
{:deps {babashka/fs #:mvn{:version "0.4.19"},
babashka/process #:mvn{:version "0.5.21"},
danlentz/clj-uuid #:mvn{:version "0.1.9"},
metosin/malli #:mvn{:version "0.13.0"},
Expand All @@ -53,7 +16,44 @@
refactor-nrepl/refactor-nrepl #:mvn{:version "3.9.0"},
org.clojure/clojure #:mvn{:version "1.11.1"},
org.clojure/tools.logging #:mvn{:version "1.2.4"}
zprint/zprint {:mvn/version "1.2.8"}
org.clojure/tools.cli #:mvn{:version "1.0.219"}}

:paths ["src/clj" "src/cljc" "resources"]}
:paths ["src/clj" "src/cljc" "resources"]

:aliases {:common-test {:exec-fn cognitect.test-runner.api/test
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner",
:sha "7284cda41fb9edc0f3bc6b6185cfb7138fc8a023"},
org.clojure/tools.namespace #:mvn{:version "1.4.4"},
org.clojure/tools.reader #:mvn{:version "1.3.6"}}
:extra-paths ["test/clj" "test/cljc" "test/resources"]
:jvm-opts ["-Dheph-conf=env/test/config.edn"
"-Dheph-common-conf=env/common_config.edn"]}

:build {:extra-deps {hephaistox/automaton-build-app {:git/url "[email protected]:hephaistox/automaton-build-app.git"
:sha "33c8941cb6df63006bafaaf1d5e7f0383b10468a"}}}

:env-development-repl {:extra-paths ["env/development/resources"
"env/development/src/clj"
"env/development/src/cljc"]
:extra-deps {cider/cider-nrepl {:mvn/version "0.21.1"}
org.clojure/core.async {:mvn/version "1.6.681"}}
:main-opts ["-m" "automaton-core.repl-core"]
:jvm-opts ["-Dheph-conf=env/development/config.edn"
"-Dheph-common-conf=env/common_config.edn"]},

:env-development-test {:jvm-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory"
"-Dhephaistox-in-test=true"
"-Dlog4j.configurationFile=resources/log_config/appenders.properties,resources/log_config/logging-tests.properties"]
:main-opts ["-m" "cognitect.test-runner"
"-r" ".*-test.*"
"-d" "test/clj"
"-d" "test/cljc"]}

:cljs-deps {:extra-paths ["src/cljs" "src/cljc" "resources" "test/cljs" "test/cljc"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.25.8"}
cider/cider-nrepl {:mvn/version "0.21.1"}
binaryage/devtools {:mvn/version "1.0.7"}}}

:bb-deps {:extra-deps {hephaistox/automaton-build-app {:local/root "../../automaton/automaton_build_app"}
#_{:git/url "[email protected]:hephaistox/automaton-build-app.git"
:sha "df88ec49ea3cdbc8606c22cc1635ac7a309d8c03"}}}}}
2 changes: 2 additions & 0 deletions docs/code/alias.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
;; List of aliases referencing many namespaces Tue Oct 24 19:33:10 CEST 2023
{}
1 change: 1 addition & 0 deletions docs/code/comments.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
List of forbidden comments
1 change: 1 addition & 0 deletions docs/code/css.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
List of forbidden css forms
3 changes: 3 additions & 0 deletions docs/code/deps-ns.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/code/deps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/code/namespace.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
;; List of aliases referencing many namespaces Tue Oct 24 19:33:11 CEST 2023
{}
3 changes: 3 additions & 0 deletions env/development/resources/version.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;; Last generated version, note a failed push consume a number Tue Oct 24
;; 19:32:54 CEST 2023
{:major-version "1.2.%s", :minor-version 3, :version "1.2.3"}
17 changes: 7 additions & 10 deletions env/development/src/clj/automaton_core/repl_core.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
(ns automaton-core.repl-core
"repl for `automaton-core` stand alone
This namespace is called to start a repl on `automaton-core` only"
(:require
[automaton-core.log :as log]
[automaton-core.repl :as core-repl]
[clojure.core.async :refer [<! chan go]]
[mount.core :as mount]
[mount.tools.graph :as graph])
(:require [automaton-core.log :as log]
[automaton-core.repl :as repl]
[clojure.core.async :refer [<! chan go]]
[mount.core :as mount]
[mount.tools.graph :as graph])
(:gen-class))

(defn -main
Expand All @@ -15,7 +14,5 @@
(log/info "Start `automaton-core`")
(log/trace "Component dependencies: " (graph/states-with-deps))
(mount/start)
(core-repl/start-repl)
(let [c (chan 1)]
(go
(<! c))))
(repl/start-repl)
(let [c (chan 1)] (go (<! c))))
21 changes: 0 additions & 21 deletions src/clj/automaton_core/adapters/bb_edn.clj

This file was deleted.

Loading

0 comments on commit a096b08

Please sign in to comment.