Compare commits

..

No commits in common. "e0b5eb0ee32734fa4a3422036b9ccb6346089770" and "1b91da0e3de671fd67d18453b5e02f54c4e0147b" have entirely different histories.

11 changed files with 23 additions and 110 deletions

View file

@ -1,5 +1,5 @@
{:project {:name org.domaindrivenarchitecture/build
:version "0.1.1-SNAPSHOT"}
:version "0.1.0"}
:paths
["src" "resources"]

View file

@ -1,9 +1,7 @@
(ns dda.build.devops
(:require
[orchestra.core :refer [defn-spec]]
[clojure.spec.alpha :as s]
[dda.build.devops.domain :as domain]
[dda.build.infrastructure :as i]))
[dda.build.devops.domain :as domain]))
(s/def ::name ::domain/name)
(s/def ::module ::domain/module)
@ -13,21 +11,9 @@
(s/def ::devops
(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"
:project-root-path "."
:build-dir-name "target"
: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)))
:stage "dev"})

View file

@ -9,11 +9,9 @@
(s/def ::stage string?)
(s/def ::project-root-path string?)
(s/def ::build-dir-name string?)
(s/def ::debug boolean?)
(s/def ::dry-run boolean?)
(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]))
(defn-spec build-path string?

View file

@ -2,6 +2,7 @@
(:require [orchestra.core :refer [defn-spec]]
[babashka.tasks :as t]
[dda.build.devops :as d]
[dda.build.devops.domain :as dd]
[dda.build.image.domain :as domain]))
(def default
@ -10,7 +11,7 @@
(defn-spec dbuild nil?
[devops ::d/devops]
(let [final (merge default devops)]
(d/create-build-dir final)
(d/create-build-dir final)
(apply t/shell (dd/clean-build-dir-command final))
(apply t/shell (dd/create-build-dir-command final))
(apply t/shell (domain/copy-image-command final))
(apply t/shell (domain/dbuild-command final))))

View file

@ -1,5 +1,6 @@
(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]))
(defn-spec copy-image-command seq?

View file

@ -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))))

View file

@ -1,8 +1,9 @@
(ns dda.build.terragrunt
(:require [orchestra.core :refer [defn-spec]]
[babashka.tasks :as t]
[dda.build.devops :as d]
[dda.build.terragrunt.domain :as domain]
[dda.build.infrastructure :as i]))
[dda.build.devops.domain :as dd]
[dda.build.terragrunt.domain :as dterra]))
(def default
(merge d/default {}))
@ -10,7 +11,7 @@
(defn-spec plan nil?
[devops ::d/devops]
(let [final (merge default devops)]
(i/execute (domain/clean-build-dir-command final) final)
(d/create-build-dir final)
(i/execute (domain/copy-terragrunt-command final) final)
))
(apply t/shell (dd/clean-build-dir-command final))
(apply t/shell (dd/create-build-dir-command final))
(apply t/shell (dterra/copy-terragrunt-command final))
(apply t/shell (dterra/plan-command final))))

View file

@ -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)]))

View file

@ -13,18 +13,14 @@
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false})))
:stage "dev"})))
(is (= "../../target/dda/backup"
(cut/build-path {:name "dda"
:module "backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))
:stage "dev"}))))
(deftest should-calculate-clean-build-dir-command
(is (= ["rm" "-rf" "../../target/dda-backup"]
@ -32,9 +28,7 @@
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))
:stage "dev"}))))
(deftest should-calculate-create-build-dir-command
(is (= ["mkdir" "-p" "../../target/dda-backup"]
@ -42,7 +36,5 @@
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))
:stage "dev"}))))

View file

@ -14,9 +14,7 @@
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))
:stage "dev"}))))
(deftest should-calculate-dbuild-command
(is (= ["docker"
@ -30,7 +28,5 @@
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))
:stage "dev"}))))

View file

@ -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}))))