Install and configure cljstyle

This commit is contained in:
Rob Hanlon 2020-08-06 23:14:19 -07:00
parent 1e24824916
commit 7b52904635
No known key found for this signature in database
GPG key ID: 14C05B6156CB50E6
3 changed files with 72 additions and 27 deletions

View file

@ -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
jobs:
build:
version: 2.1
executors:
ubuntu:
machine:
image: ubuntu-1604:202004-01
working_directory: ~/repo
jobs:
build:
executor: ubuntu
environment:
# Customize the JVM maximum heap limit
JVM_OPTS: -Xmx3200m
@ -40,3 +44,19 @@ jobs:
- store_test_results:
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"

View file

@ -1,10 +1,19 @@
(ns clj-test-containers.core
(:require [clojure.java.io :as io])
(:import [org.testcontainers.containers GenericContainer]
[org.testcontainers.utility MountableFile]
[org.testcontainers.containers BindMode Network]
[org.testcontainers.images.builder ImageFromDockerfile]
[java.nio.file Path Paths]))
(:require
[clojure.java.io :as io])
(:import
(java.nio.file
Path
Paths)
(org.testcontainers.containers
BindMode
GenericContainer
Network)
(org.testcontainers.images.builder
ImageFromDockerfile)
(org.testcontainers.utility
MountableFile)))
(defn- resolve-bind-mode
[bind-mode]
@ -12,6 +21,7 @@
BindMode/READ_WRITE
BindMode/READ_ONLY))
(defn init
"Sets the properties for a testcontainer instance"
[{:keys [container exposed-ports env-vars command network network-aliases]}]
@ -35,6 +45,7 @@
:host (.getHost container)
:network network})
(defn create
"Creates a generic testcontainer and sets its properties"
[{:keys [image-name] :as options}]
@ -42,6 +53,7 @@
(assoc options :container)
init))
(defn create-from-docker-file
"Creates a testcontainer from a provided Dockerfile"
[{:keys [docker-file] :as options}]
@ -50,6 +62,7 @@
(assoc options :container)
init))
(defn map-classpath-resource!
"Maps a resource in the classpath to the given container path. Should be called before starting the container!"
[container-config
@ -59,6 +72,7 @@
container-path
(resolve-bind-mode mode))))
(defn bind-filesystem!
"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]}]
@ -68,6 +82,7 @@
container-path
(resolve-bind-mode mode))))
(defn copy-file-to-container!
"Copies a file into the running container"
[container-config
@ -86,6 +101,7 @@
mountable-file
container-path))))
(defn execute-command!
"Executes a command in the container, and returns the result"
[container-config command]
@ -96,6 +112,7 @@
:stdout (.getStdout result)
:stderr (.getStderr result)}))
(defn start!
"Starts the underlying testcontainer instance and adds new values to the response map, e.g. :id and :first-mapped-port"
[container-config]
@ -107,6 +124,7 @@
(map (fn [port] [port (.getMappedPort container port)])
(:exposed-ports container-config)))))))
(defn stop!
"Stops the underlying container"
[container-config]
@ -133,6 +151,7 @@
:ipv6 (.getEnableIpv6 network)
:driver (.getDriver network)})))
(defn init-network
"Creates a network. The optional map accepts config values for enabling ipv6 and setting the driver"
([]

View file

@ -1,7 +1,11 @@
(ns clj-test-containers.core-test
(:require [clojure.test :refer :all]
[clj-test-containers.core :refer :all])
(:import [org.testcontainers.containers PostgreSQLContainer]))
(:require
[clj-test-containers.core :refer :all]
[clojure.test :refer :all])
(:import
(org.testcontainers.containers
PostgreSQLContainer)))
(deftest create-test
(testing "Testing basic testcontainer generic image initialisation"
@ -37,6 +41,7 @@
(is (= 0 (:exit-code result)))
(is (= "root\n" (:stdout result))))))
(deftest execute-command-in-container
(testing "Executing a command in the running Docker container"
@ -49,6 +54,7 @@
(is (= 0 (:exit-code result)))
(is (= "root\n" (:stdout result))))))
(deftest init-volume-test
(testing "Testing mapping of a classpath resource"