Install and configure cljstyle
This commit is contained in:
parent
1e24824916
commit
7b52904635
3 changed files with 72 additions and 27 deletions
|
|
@ -1,15 +1,19 @@
|
||||||
# Clojure CircleCI 2.0 configuration file
|
# Clojure CircleCI 2.1 configuration file
|
||||||
#
|
#
|
||||||
# Check https://circleci.com/docs/2.0/language-clojure/ for more details
|
# Check https://circleci.com/docs/2.0/language-ubuntu/ for more details
|
||||||
#
|
#
|
||||||
version: 2
|
version: 2.1
|
||||||
jobs:
|
|
||||||
build:
|
executors:
|
||||||
|
ubuntu:
|
||||||
machine:
|
machine:
|
||||||
image: ubuntu-1604:202004-01
|
image: ubuntu-1604:202004-01
|
||||||
|
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
executor: ubuntu
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
# Customize the JVM maximum heap limit
|
# Customize the JVM maximum heap limit
|
||||||
JVM_OPTS: -Xmx3200m
|
JVM_OPTS: -Xmx3200m
|
||||||
|
|
@ -40,3 +44,19 @@ jobs:
|
||||||
|
|
||||||
- store_test_results:
|
- store_test_results:
|
||||||
path: target
|
path: target
|
||||||
|
|
||||||
|
style:
|
||||||
|
executor: ubuntu
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Install cljstyle
|
||||||
|
environment:
|
||||||
|
CLJSTYLE_VERSION: 0.13.0
|
||||||
|
command: |
|
||||||
|
wget https://github.com/greglook/cljstyle/releases/download/${CLJSTYLE_VERSION}/cljstyle_${CLJSTYLE_VERSION}_linux.tar.gz
|
||||||
|
tar -xzf cljstyle_${CLJSTYLE_VERSION}_linux.tar.gz
|
||||||
|
- run:
|
||||||
|
name: Check style
|
||||||
|
command: "./cljstyle check --report"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
(ns clj-test-containers.core
|
(ns clj-test-containers.core
|
||||||
(:require [clojure.java.io :as io])
|
(:require
|
||||||
(:import [org.testcontainers.containers GenericContainer]
|
[clojure.java.io :as io])
|
||||||
[org.testcontainers.utility MountableFile]
|
(:import
|
||||||
[org.testcontainers.containers BindMode Network]
|
(java.nio.file
|
||||||
[org.testcontainers.images.builder ImageFromDockerfile]
|
Path
|
||||||
[java.nio.file Path Paths]))
|
Paths)
|
||||||
|
(org.testcontainers.containers
|
||||||
|
BindMode
|
||||||
|
GenericContainer
|
||||||
|
Network)
|
||||||
|
(org.testcontainers.images.builder
|
||||||
|
ImageFromDockerfile)
|
||||||
|
(org.testcontainers.utility
|
||||||
|
MountableFile)))
|
||||||
|
|
||||||
|
|
||||||
(defn- resolve-bind-mode
|
(defn- resolve-bind-mode
|
||||||
[bind-mode]
|
[bind-mode]
|
||||||
|
|
@ -12,6 +21,7 @@
|
||||||
BindMode/READ_WRITE
|
BindMode/READ_WRITE
|
||||||
BindMode/READ_ONLY))
|
BindMode/READ_ONLY))
|
||||||
|
|
||||||
|
|
||||||
(defn init
|
(defn init
|
||||||
"Sets the properties for a testcontainer instance"
|
"Sets the properties for a testcontainer instance"
|
||||||
[{:keys [container exposed-ports env-vars command network network-aliases]}]
|
[{:keys [container exposed-ports env-vars command network network-aliases]}]
|
||||||
|
|
@ -35,6 +45,7 @@
|
||||||
:host (.getHost container)
|
:host (.getHost container)
|
||||||
:network network})
|
:network network})
|
||||||
|
|
||||||
|
|
||||||
(defn create
|
(defn create
|
||||||
"Creates a generic testcontainer and sets its properties"
|
"Creates a generic testcontainer and sets its properties"
|
||||||
[{:keys [image-name] :as options}]
|
[{:keys [image-name] :as options}]
|
||||||
|
|
@ -42,6 +53,7 @@
|
||||||
(assoc options :container)
|
(assoc options :container)
|
||||||
init))
|
init))
|
||||||
|
|
||||||
|
|
||||||
(defn create-from-docker-file
|
(defn create-from-docker-file
|
||||||
"Creates a testcontainer from a provided Dockerfile"
|
"Creates a testcontainer from a provided Dockerfile"
|
||||||
[{:keys [docker-file] :as options}]
|
[{:keys [docker-file] :as options}]
|
||||||
|
|
@ -50,6 +62,7 @@
|
||||||
(assoc options :container)
|
(assoc options :container)
|
||||||
init))
|
init))
|
||||||
|
|
||||||
|
|
||||||
(defn map-classpath-resource!
|
(defn map-classpath-resource!
|
||||||
"Maps a resource in the classpath to the given container path. Should be called before starting the container!"
|
"Maps a resource in the classpath to the given container path. Should be called before starting the container!"
|
||||||
[container-config
|
[container-config
|
||||||
|
|
@ -59,6 +72,7 @@
|
||||||
container-path
|
container-path
|
||||||
(resolve-bind-mode mode))))
|
(resolve-bind-mode mode))))
|
||||||
|
|
||||||
|
|
||||||
(defn bind-filesystem!
|
(defn bind-filesystem!
|
||||||
"Binds a source from the filesystem to the given container path. Should be called before starting the container!"
|
"Binds a source from the filesystem to the given container path. Should be called before starting the container!"
|
||||||
[container-config {:keys [host-path container-path mode]}]
|
[container-config {:keys [host-path container-path mode]}]
|
||||||
|
|
@ -68,6 +82,7 @@
|
||||||
container-path
|
container-path
|
||||||
(resolve-bind-mode mode))))
|
(resolve-bind-mode mode))))
|
||||||
|
|
||||||
|
|
||||||
(defn copy-file-to-container!
|
(defn copy-file-to-container!
|
||||||
"Copies a file into the running container"
|
"Copies a file into the running container"
|
||||||
[container-config
|
[container-config
|
||||||
|
|
@ -86,6 +101,7 @@
|
||||||
mountable-file
|
mountable-file
|
||||||
container-path))))
|
container-path))))
|
||||||
|
|
||||||
|
|
||||||
(defn execute-command!
|
(defn execute-command!
|
||||||
"Executes a command in the container, and returns the result"
|
"Executes a command in the container, and returns the result"
|
||||||
[container-config command]
|
[container-config command]
|
||||||
|
|
@ -96,6 +112,7 @@
|
||||||
:stdout (.getStdout result)
|
:stdout (.getStdout result)
|
||||||
:stderr (.getStderr result)}))
|
:stderr (.getStderr result)}))
|
||||||
|
|
||||||
|
|
||||||
(defn start!
|
(defn start!
|
||||||
"Starts the underlying testcontainer instance and adds new values to the response map, e.g. :id and :first-mapped-port"
|
"Starts the underlying testcontainer instance and adds new values to the response map, e.g. :id and :first-mapped-port"
|
||||||
[container-config]
|
[container-config]
|
||||||
|
|
@ -107,6 +124,7 @@
|
||||||
(map (fn [port] [port (.getMappedPort container port)])
|
(map (fn [port] [port (.getMappedPort container port)])
|
||||||
(:exposed-ports container-config)))))))
|
(:exposed-ports container-config)))))))
|
||||||
|
|
||||||
|
|
||||||
(defn stop!
|
(defn stop!
|
||||||
"Stops the underlying container"
|
"Stops the underlying container"
|
||||||
[container-config]
|
[container-config]
|
||||||
|
|
@ -133,6 +151,7 @@
|
||||||
:ipv6 (.getEnableIpv6 network)
|
:ipv6 (.getEnableIpv6 network)
|
||||||
:driver (.getDriver network)})))
|
:driver (.getDriver network)})))
|
||||||
|
|
||||||
|
|
||||||
(defn init-network
|
(defn init-network
|
||||||
"Creates a network. The optional map accepts config values for enabling ipv6 and setting the driver"
|
"Creates a network. The optional map accepts config values for enabling ipv6 and setting the driver"
|
||||||
([]
|
([]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
(ns clj-test-containers.core-test
|
(ns clj-test-containers.core-test
|
||||||
(:require [clojure.test :refer :all]
|
(:require
|
||||||
[clj-test-containers.core :refer :all])
|
[clj-test-containers.core :refer :all]
|
||||||
(:import [org.testcontainers.containers PostgreSQLContainer]))
|
[clojure.test :refer :all])
|
||||||
|
(:import
|
||||||
|
(org.testcontainers.containers
|
||||||
|
PostgreSQLContainer)))
|
||||||
|
|
||||||
|
|
||||||
(deftest create-test
|
(deftest create-test
|
||||||
(testing "Testing basic testcontainer generic image initialisation"
|
(testing "Testing basic testcontainer generic image initialisation"
|
||||||
|
|
@ -37,6 +41,7 @@
|
||||||
(is (= 0 (:exit-code result)))
|
(is (= 0 (:exit-code result)))
|
||||||
(is (= "root\n" (:stdout result))))))
|
(is (= "root\n" (:stdout result))))))
|
||||||
|
|
||||||
|
|
||||||
(deftest execute-command-in-container
|
(deftest execute-command-in-container
|
||||||
|
|
||||||
(testing "Executing a command in the running Docker container"
|
(testing "Executing a command in the running Docker container"
|
||||||
|
|
@ -49,6 +54,7 @@
|
||||||
(is (= 0 (:exit-code result)))
|
(is (= 0 (:exit-code result)))
|
||||||
(is (= "root\n" (:stdout result))))))
|
(is (= "root\n" (:stdout result))))))
|
||||||
|
|
||||||
|
|
||||||
(deftest init-volume-test
|
(deftest init-volume-test
|
||||||
|
|
||||||
(testing "Testing mapping of a classpath resource"
|
(testing "Testing mapping of a classpath resource"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue