Compare commits
No commits in common. "e0b5eb0ee32734fa4a3422036b9ccb6346089770" and "1b91da0e3de671fd67d18453b5e02f54c4e0147b" have entirely different histories.
e0b5eb0ee3
...
1b91da0e3d
11 changed files with 23 additions and 110 deletions
2
deps.edn
2
deps.edn
|
@ -1,5 +1,5 @@
|
||||||
{:project {:name org.domaindrivenarchitecture/build
|
{:project {:name org.domaindrivenarchitecture/build
|
||||||
:version "0.1.1-SNAPSHOT"}
|
:version "0.1.0"}
|
||||||
|
|
||||||
:paths
|
:paths
|
||||||
["src" "resources"]
|
["src" "resources"]
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
(ns dda.build.devops
|
(ns dda.build.devops
|
||||||
(:require
|
(:require
|
||||||
[orchestra.core :refer [defn-spec]]
|
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[dda.build.devops.domain :as domain]
|
[dda.build.devops.domain :as domain]))
|
||||||
[dda.build.infrastructure :as i]))
|
|
||||||
|
|
||||||
(s/def ::name ::domain/name)
|
(s/def ::name ::domain/name)
|
||||||
(s/def ::module ::domain/module)
|
(s/def ::module ::domain/module)
|
||||||
|
@ -13,21 +11,9 @@
|
||||||
|
|
||||||
(s/def ::devops
|
(s/def ::devops
|
||||||
(s/keys :req-un [::name]
|
(s/keys :req-un [::name]
|
||||||
:opt-un [::module ::stage ::project-root-path ::build-dir-name ::debug ::dry-run]))
|
:opt-un [::module ::stage ::project-root-path ::build-dir-name]))
|
||||||
|
|
||||||
(def default {:name "dda-backup"
|
(def default {:name "dda-backup"
|
||||||
:project-root-path "."
|
:project-root-path "."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:stage "dev"
|
:stage "dev"})
|
||||||
:debug false
|
|
||||||
:dry-run false})
|
|
||||||
|
|
||||||
(defn-spec clean-build-dir nil?
|
|
||||||
[devops ::devops]
|
|
||||||
(let [final (merge default devops)]
|
|
||||||
(i/execute (domain/clean-build-dir-command final) final)))
|
|
||||||
|
|
||||||
(defn-spec create-build-dir nil?
|
|
||||||
[devops ::devops]
|
|
||||||
(let [final (merge default devops)]
|
|
||||||
(i/execute (domain/create-build-dir-command final) final)))
|
|
||||||
|
|
|
@ -9,11 +9,9 @@
|
||||||
(s/def ::stage string?)
|
(s/def ::stage string?)
|
||||||
(s/def ::project-root-path string?)
|
(s/def ::project-root-path string?)
|
||||||
(s/def ::build-dir-name string?)
|
(s/def ::build-dir-name string?)
|
||||||
(s/def ::debug boolean?)
|
|
||||||
(s/def ::dry-run boolean?)
|
|
||||||
|
|
||||||
(s/def ::devops
|
(s/def ::devops
|
||||||
(s/keys :req-un [::name ::stage ::project-root-path ::build-dir-name ::debug ::dry-run]
|
(s/keys :req-un [::name ::stage ::project-root-path ::build-dir-name]
|
||||||
:opt-un [::module]))
|
:opt-un [::module]))
|
||||||
|
|
||||||
(defn-spec build-path string?
|
(defn-spec build-path string?
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require [orchestra.core :refer [defn-spec]]
|
(:require [orchestra.core :refer [defn-spec]]
|
||||||
[babashka.tasks :as t]
|
[babashka.tasks :as t]
|
||||||
[dda.build.devops :as d]
|
[dda.build.devops :as d]
|
||||||
|
[dda.build.devops.domain :as dd]
|
||||||
[dda.build.image.domain :as domain]))
|
[dda.build.image.domain :as domain]))
|
||||||
|
|
||||||
(def default
|
(def default
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
(defn-spec dbuild nil?
|
(defn-spec dbuild nil?
|
||||||
[devops ::d/devops]
|
[devops ::d/devops]
|
||||||
(let [final (merge default devops)]
|
(let [final (merge default devops)]
|
||||||
(d/create-build-dir final)
|
(apply t/shell (dd/clean-build-dir-command final))
|
||||||
(d/create-build-dir final)
|
(apply t/shell (dd/create-build-dir-command final))
|
||||||
(apply t/shell (domain/copy-image-command final))
|
(apply t/shell (domain/copy-image-command final))
|
||||||
(apply t/shell (domain/dbuild-command final))))
|
(apply t/shell (domain/dbuild-command final))))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns dda.build.image.domain
|
(ns dda.build.image.domain
|
||||||
(:require [orchestra.core :refer [defn-spec]]
|
(:require [clojure.spec.alpha :as s]
|
||||||
|
[orchestra.core :refer [defn-spec]]
|
||||||
[dda.build.devops.domain :as d]))
|
[dda.build.devops.domain :as d]))
|
||||||
|
|
||||||
(defn-spec copy-image-command seq?
|
(defn-spec copy-image-command seq?
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
(ns dda.build.infrastructure
|
|
||||||
(:require [orchestra.core :refer [defn-spec]]
|
|
||||||
[babashka.tasks :as t]
|
|
||||||
[dda.build.devops.domain :as d]))
|
|
||||||
|
|
||||||
(defn-spec execute nil?
|
|
||||||
[command string?
|
|
||||||
devops ::d/devops]
|
|
||||||
(let [{:keys [dry-run debug]} devops]
|
|
||||||
(when debug
|
|
||||||
(println command))
|
|
||||||
(when-not dry-run
|
|
||||||
(apply t/shell command))))
|
|
|
@ -1,8 +1,9 @@
|
||||||
(ns dda.build.terragrunt
|
(ns dda.build.terragrunt
|
||||||
(:require [orchestra.core :refer [defn-spec]]
|
(:require [orchestra.core :refer [defn-spec]]
|
||||||
|
[babashka.tasks :as t]
|
||||||
[dda.build.devops :as d]
|
[dda.build.devops :as d]
|
||||||
[dda.build.terragrunt.domain :as domain]
|
[dda.build.devops.domain :as dd]
|
||||||
[dda.build.infrastructure :as i]))
|
[dda.build.terragrunt.domain :as dterra]))
|
||||||
|
|
||||||
(def default
|
(def default
|
||||||
(merge d/default {}))
|
(merge d/default {}))
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
(defn-spec plan nil?
|
(defn-spec plan nil?
|
||||||
[devops ::d/devops]
|
[devops ::d/devops]
|
||||||
(let [final (merge default devops)]
|
(let [final (merge default devops)]
|
||||||
(i/execute (domain/clean-build-dir-command final) final)
|
(apply t/shell (dd/clean-build-dir-command final))
|
||||||
(d/create-build-dir final)
|
(apply t/shell (dd/create-build-dir-command final))
|
||||||
(i/execute (domain/copy-terragrunt-command final) final)
|
(apply t/shell (dterra/copy-terragrunt-command final))
|
||||||
))
|
(apply t/shell (dterra/plan-command final))))
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
(ns dda.build.terragrunt.domain
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[orchestra.core :refer [defn-spec]]
|
|
||||||
[dda.build.devops.domain :as d]))
|
|
||||||
|
|
||||||
(s/def ::devops
|
|
||||||
(s/keys :req-un [::name ::stage ::project-root-path ::build-dir-name ::debug ::dry-run ::module]
|
|
||||||
:opt-un []))
|
|
||||||
|
|
||||||
(defn-spec clean-build-dir-command seq?
|
|
||||||
[devops ::devops]
|
|
||||||
["rm" "-rf" (d/build-path (dissoc devops :module))])
|
|
||||||
|
|
||||||
(defn-spec copy-terragrunt-command seq?
|
|
||||||
[devops ::devops]
|
|
||||||
(let [{:keys [module]} devops]
|
|
||||||
["cp" "." (d/build-path devops) "&&" "cp" module (d/build-path devops)]))
|
|
|
@ -13,18 +13,14 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"
|
:stage "dev"})))
|
||||||
:debug false
|
|
||||||
:dry-run false})))
|
|
||||||
(is (= "../../target/dda/backup"
|
(is (= "../../target/dda/backup"
|
||||||
(cut/build-path {:name "dda"
|
(cut/build-path {:name "dda"
|
||||||
:module "backup"
|
:module "backup"
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"
|
:stage "dev"}))))
|
||||||
:debug false
|
|
||||||
:dry-run false}))))
|
|
||||||
|
|
||||||
(deftest should-calculate-clean-build-dir-command
|
(deftest should-calculate-clean-build-dir-command
|
||||||
(is (= ["rm" "-rf" "../../target/dda-backup"]
|
(is (= ["rm" "-rf" "../../target/dda-backup"]
|
||||||
|
@ -32,9 +28,7 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"
|
:stage "dev"}))))
|
||||||
:debug false
|
|
||||||
:dry-run false}))))
|
|
||||||
|
|
||||||
(deftest should-calculate-create-build-dir-command
|
(deftest should-calculate-create-build-dir-command
|
||||||
(is (= ["mkdir" "-p" "../../target/dda-backup"]
|
(is (= ["mkdir" "-p" "../../target/dda-backup"]
|
||||||
|
@ -42,7 +36,5 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"
|
:stage "dev"}))))
|
||||||
:debug false
|
|
||||||
:dry-run false}))))
|
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"
|
:stage "dev"}))))
|
||||||
:debug false
|
|
||||||
:dry-run false}))))
|
|
||||||
|
|
||||||
(deftest should-calculate-dbuild-command
|
(deftest should-calculate-dbuild-command
|
||||||
(is (= ["docker"
|
(is (= ["docker"
|
||||||
|
@ -30,7 +28,5 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"
|
:stage "dev"}))))
|
||||||
:debug false
|
|
||||||
:dry-run false}))))
|
|
||||||
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
(ns dda.build.terragrunt.domain-test
|
|
||||||
(:require
|
|
||||||
[clojure.test :refer [deftest is are testing run-tests]]
|
|
||||||
[clojure.spec.test.alpha :as st]
|
|
||||||
[dda.build.terragrunt.domain :as cut]))
|
|
||||||
|
|
||||||
(st/instrument `cut/clean-build-dir-command)
|
|
||||||
(st/instrument `cut/copy-terragrunt-command)
|
|
||||||
|
|
||||||
(deftest should-calculate-clean-build-dir-command
|
|
||||||
(is (= ["rm" "-rf" "../../target/test"]
|
|
||||||
(cut/clean-build-dir-command {:name "test"
|
|
||||||
:module "statistics"
|
|
||||||
:project-root-path "../.."
|
|
||||||
:build-dir-name "target"
|
|
||||||
:version "4.11.8-dev"
|
|
||||||
:stage "dev"
|
|
||||||
:debug false
|
|
||||||
:dry-run false}))))
|
|
||||||
|
|
||||||
(deftest should-calculate-copy-terragrunt-command
|
|
||||||
(is (= ["cp" "." "../../target/test/statistics" "&&"
|
|
||||||
"cp" "statistics" "../../target/test/statistics"]
|
|
||||||
(cut/copy-terragrunt-command {:name "test"
|
|
||||||
:module "statistics"
|
|
||||||
:project-root-path "../.."
|
|
||||||
:build-dir-name "target"
|
|
||||||
:version "4.11.8-dev"
|
|
||||||
:stage "dev"
|
|
||||||
:debug false
|
|
||||||
:dry-run false}))))
|
|
||||||
|
|
Loading…
Reference in a new issue