initial commit

master
Josha von Gizycki 6 years ago
commit d4adfcf041

9
.gitignore vendored

@ -0,0 +1,9 @@
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port

@ -0,0 +1,24 @@
# wanijo-pipeline
A continuous delivery pipeline for FIXME
## Usage
* `lein run` will start your pipeline with a web-ui listening on port 8080
## Files
* `/`
* `project.clj` contains dependencies and build configuration for Leiningen
* `/src/wanijo_pipeline/`
* `pipeline.clj` contains your pipeline-definition
* `steps.clj` contains your custom build-steps
* `core.clj` contains the `main` function that wires everything together
* `/resources/`
* `logback.xml` contains a sample log configuration
## References
* for a more detailed example, look at the [example pipeline](https://github.com/flosell/lambdacd/tree/master/src/todopipeline) in the main LambdaCD project

@ -0,0 +1,14 @@
(defproject wanijo-pipeline "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[lambdacd "0.14.0"]
[lambdacd-git "0.4.1"]
[lambdaui "1.1.0"]
[http-kit "2.3.0"]
[org.clojure/clojure "1.9.0"]
[org.clojure/tools.logging "0.3.1"]
[org.slf4j/slf4j-api "1.7.5"]
[ch.qos.logback/logback-core "1.0.13"]
[ch.qos.logback/logback-classic "1.0.13"]]
:profiles {:uberjar {:aot :all}}
:main wanijo-pipeline.core)

@ -0,0 +1,13 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
<!-- Jetty is pretty noisy... -->
<logger name="org.eclipse.jetty" level="INFO"/>
</configuration>

@ -0,0 +1,31 @@
(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])
(:import (java.nio.file.attribute FileAttribute)
(java.nio.file Files LinkOption))
(:gen-class))
(defn- create-temp-dir []
(str (Files/createTempDirectory "lambdacd" (into-array FileAttribute []))))
(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)
;; 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)
;; start the webserver to serve the UI
(http-kit/run-server app {:port 30500})))

@ -0,0 +1,14 @@
(ns wanijo-pipeline.pipeline
(:use [lambdacd.steps.control-flow]
[wanijo-pipeline.steps])
(:require
[lambdacd.steps.manualtrigger :as manualtrigger]))
(def pipeline-def
`((either
manualtrigger/wait-for-manual-trigger
wait-for-repo)
(with-workspace
clone
compile
test)))

@ -0,0 +1,23 @@
(ns wanijo-pipeline.steps
(:require [lambdacd.steps.shell :as lcd-shell]
[lambdacd-git.core :as lcd-git]))
(def repo-uri "https://gitea.heevyis.ninja/josha/wanijo.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 compile [args ctx]
(lcd-shell/bash ctx (:cwd args) "lein compile"))
(defn test [args ctx]
(lcd-shell/bash ctx (:cwd args) "lein test"))

@ -0,0 +1,30 @@
(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]])
(: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"]]]]]))
(defn ui-routes [pipeline]
(let [lambdaui-app (lambdaui/ui-for pipeline :contextPath "/lambdaui")
referenceui-app (reference-ui/ui-for pipeline)]
(routes
(GET "/" [] (ui-selection))
(context "/lambdaui" [] lambdaui-app)
(context "/reference" [] referenceui-app))))
Loading…
Cancel
Save