From 49a5731112f7c74850259da8c3b35a5af9d99a47 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Sat, 29 Sep 2018 21:28:24 +0200 Subject: [PATCH] add formulare --- src/wanijo_pipeline/core.clj | 45 +++++++++++++--------- src/wanijo_pipeline/formulare_pipeline.clj | 41 ++++++++++++++++++++ src/wanijo_pipeline/ui_selection.clj | 40 +++++++++---------- 3 files changed, 85 insertions(+), 41 deletions(-) create mode 100644 src/wanijo_pipeline/formulare_pipeline.clj diff --git a/src/wanijo_pipeline/core.clj b/src/wanijo_pipeline/core.clj index acd75a4..83d4d19 100644 --- a/src/wanijo_pipeline/core.clj +++ b/src/wanijo_pipeline/core.clj @@ -1,31 +1,38 @@ (ns wanijo-pipeline.core (:require - [wanijo-pipeline.pipeline :as pipeline] - [wanijo-pipeline.ui-selection :as ui-selection] - [org.httpkit.server :as http-kit] - [lambdacd.runners :as runners] - [lambdacd.core :as lambdacd] - [clojure.tools.logging :as log]) + [wanijo-pipeline.pipeline :as pipeline] + [wanijo-pipeline.ui-selection :as ui-selection] + [org.httpkit.server :as http-kit] + [lambdacd.runners :as runners] + [lambdacd.core :as lambdacd] + [clojure.tools.logging :as log] + [wanijo-pipeline.formulare-pipeline :as fp]) (:import (java.nio.file.attribute FileAttribute) - (java.nio.file Files LinkOption)) + (java.nio.file Files LinkOption)) (:gen-class)) (defn- create-temp-dir [] - (str (Files/createTempDirectory "lambdacd" (into-array FileAttribute [])))) + (str (Files/createTempDirectory "lambdacd" + (into-array FileAttribute [])))) + +(defn wanijo-pipeline [] + (lambdacd/assemble-pipeline pipeline/pipeline-def + {:home-dir (create-temp-dir) + :name "wanijo pipeline"})) + +(defn formulare-pipeline [] + (lambdacd/assemble-pipeline fp/pipeline-def + {:home-dir (create-temp-dir) + :name "formulare pipeline"})) (defn -main [& args] - (let [;; the home dir is where LambdaCD saves all data. - ;; point this to a particular directory to keep builds around after restarting - home-dir (create-temp-dir) - config {:home-dir home-dir - :name "wanijo pipeline"} - ;; initialize and wire everything together - pipeline (lambdacd/assemble-pipeline pipeline/pipeline-def config) - ;; create a Ring handler for the UI - app (ui-selection/ui-routes pipeline)] - (log/info "LambdaCD Home Directory is " home-dir) + (let [wanijo-pipeline (wanijo-pipeline) + formulare-pipeline (formulare-pipeline) + app (ui-selection/ui-routes wanijo-pipeline + formulare-pipeline)] ;; this starts the pipeline and runs one build after the other. ;; there are other runners and you can define your own as well. - (runners/start-one-run-after-another pipeline) + (runners/start-one-run-after-another wanijo-pipeline) + (runners/start-one-run-after-another formulare-pipeline) ;; start the webserver to serve the UI (http-kit/run-server app {:port 30500}))) diff --git a/src/wanijo_pipeline/formulare_pipeline.clj b/src/wanijo_pipeline/formulare_pipeline.clj new file mode 100644 index 0000000..9f7765a --- /dev/null +++ b/src/wanijo_pipeline/formulare_pipeline.clj @@ -0,0 +1,41 @@ +(ns wanijo-pipeline.formulare-pipeline + (:use [lambdacd.steps.control-flow]) + (:require [lambdacd.steps.manualtrigger :as manualtrigger] + [lambdacd.steps.shell :as lcd-shell] + [lambdacd-git.core :as lcd-git])) + +(def repo-uri "https://gitea.heevyis.ninja/josha/formulare.git") +(def repo-branch "master") + +(defn wait-for-repo [args ctx] + (lcd-git/wait-for-git ctx + repo-uri + :ref (str "refs/heads/" repo-branch))) + +(defn clone [args ctx] + (let [revision (:revision args) + cwd (:cwd args) + ref (or revision repo-branch)] + (lcd-git/clone ctx repo-uri ref cwd))) + +(defn lein [target args ctx] + (lcd-shell/bash ctx (:cwd args) (str "lein " target))) + +(defn compile [args ctx] + (lein "compile" args ctx)) + +(defn test [args ctx] + (lein "test" args ctx)) + +(defn deploy [args ctx] + (lein "deploy clojars" args ctx)) + +(def pipeline-def + `((either + manualtrigger/wait-for-manual-trigger + wait-for-repo) + (with-workspace + clone + compile + test + deploy))) diff --git a/src/wanijo_pipeline/ui_selection.clj b/src/wanijo_pipeline/ui_selection.clj index 2745d54..6d83615 100644 --- a/src/wanijo_pipeline/ui_selection.clj +++ b/src/wanijo_pipeline/ui_selection.clj @@ -1,30 +1,26 @@ (ns wanijo-pipeline.ui-selection (:require - [hiccup.core :as h] - [lambdaui.core :as lambdaui] - [lambdacd.ui.core :as reference-ui] - [compojure.core :refer [routes GET context]]) + [hiccup.core :as h] + [lambdaui.core :as lambdaui] + [lambdacd.ui.core :as reference-ui] + [compojure.core :refer [routes GET context]]) (:gen-class)) (defn- ui-selection [] (h/html - [:html - [:head - [:title "LambdaCD - UI Selection"]] - [:body - [:h1 "LambdaCD - UI Selection"] - [:p "Two different UIs for LambdaCD exist: The reference-ui shipped with the core of LambdaCD and " - [:a {:href "https://github.com/sroidl/lambda-ui"} "LambdaUI"] - ", a community developed, opinionated alternative with a more user friendly interface"] - [:ul - [:li [:a {:href "./lambdaui/lambdaui/index.html"} "LambdaUI"]] - [:li [:a {:href "./reference/"} "Reference UI"]]]]])) + [:html + [:head + [:title "LambdaCD - UI Selection"]] + [:body + [:h1 "LambdaCD - UI Selection"] + [:ul + [:li [:a {:href "./wanijo/lambdaui/index.html"} "Wanijo"]] + [:li [:a {:href "./formulare/lambdaui/index.html"} "Formulare"]]]]])) -(defn ui-routes [pipeline] - (let [lambdaui-app (lambdaui/ui-for pipeline :contextPath "/lambdaui") - referenceui-app (reference-ui/ui-for pipeline)] +(defn ui-routes [wanijo formulare] + (let [wanijo-app (lambdaui/ui-for wanijo :contextPath "/wanijo") + formulare-app (lambdaui/ui-for formulare :contextPath "/formulare")] (routes - (GET "/" [] (ui-selection)) - (context "/lambdaui" [] lambdaui-app) - (context "/reference" [] referenceui-app)))) - + (GET "/" [] (ui-selection)) + (context "/wanijo" [] wanijo-app) + (context "/formulare" [] formulare-app))))