-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.clj
48 lines (43 loc) · 1.61 KB
/
build.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(ns build
(:refer-clojure :exclude [compile apply])
(:require [org.corfield.build :as b]
[clojure.java.shell :refer [sh]]))
(defn test "Run the tests." [_]
(b/run-tests {:aliases [:dev]}))
(defn compile
"Compile Clojure and create the jar package"
[opts]
(let [cmd0 ["mkdir" "classes"]
cmd1 ["clj" "-M" "-e" "(compile 'pro.juxt.lambda)"]
cmd2 ["clj" "-M:uberdeps" "--target" "target/lambda.jar"
"--main-class" "pro.juxt.lambda"]
output0 (clojure.core/apply sh (into cmd0 opts))
output1 (clojure.core/apply sh (into cmd1 opts))
output2 (clojure.core/apply sh (into cmd2 opts))
]
(println (:out output1))
(println (:err output1))
(println (:out output2))
(println (:err output2))
))
(defn- terraform [cmd & opts]
(let [cmd (clojure.core/apply sh "terraform" "-chdir=terraform" cmd opts)]
(println (:out cmd))
(println (:err cmd))))
(defn init [opts] (terraform "init"))
(defn plan [opts] (terraform "plan"))
(defn apply [opts] (terraform "apply" "-auto-approve"))
(defn destroy [opts] (terraform "destroy" "-auto-approve"))
(defn run [opts]
(let [cmd ["aws" "lambda" "invoke"
"--invocation-type" "RequestResponse"
"--function-name" "lambda"
"--region" "eu-west-1"
"--log-type" "Tail"
"--cli-binary-format" "raw-in-base64-out"
"--payload" "{\"some\":\"input\"}"
"target/results.txt"]
output (clojure.core/apply sh (into cmd opts))]
(println (:out output))
(println (:err output))
(println (slurp "target/results.txt"))))