From 02790ef3367d3cebfd40b1fecf378a6f3aa520e6 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Thu, 1 Dec 2016 09:35:43 +0200
Subject: [PATCH] - Moved lint to pre-commit. - Added local hook to run make
 test to pre-commit. - Added Travis CI. - Updated README accordingly.

---
 .pre-commit-config.yaml | 15 ++++++++++-----
 .travis.yml             | 27 +++++++++++++++++++++++++++
 Makefile                | 11 ++---------
 README.rst              | 10 ++++++----
 4 files changed, 45 insertions(+), 18 deletions(-)
 create mode 100644 .travis.yml

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 1a60e50..bb25a23 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,12 +2,17 @@
     sha: 97b88d9610bcc03982ddac33caba98bb2b751f5f
     hooks:
     -   id: check-added-large-files
-    -   id: check-json
-    -   id: check-xml
-    -   id: check-yaml
     -   id: check-merge-conflict
 -   repo: https://www.shore.co.il/git/shell-pre-commit/
-    sha: 604fe77b53d3514d5ad0f66764c7783850bb6e98
+    sha: v0.1.0
     hooks:
     -   id: shell-lint
-        files: bundle-certs
+        files: bundle_certs
+-   repo: local
+    hooks:
+    -   id: test
+        name: make test
+        language: system
+        entry: make test
+        files: bundle_certs
+
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..e3a68d0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,27 @@
+---
+language: python
+python: "2.7"
+dist: trusty
+sudo: false
+group: beta
+cache:
+  - pip
+  - directories:
+      - $HOME/.pre-commit
+
+addons:
+  apt:
+    packages:
+      - mawk
+      - openssl
+      - curl
+      - build-essential
+
+install:
+  - pip install pre_commit
+
+script:
+  - pre-commit run --all-files
+
+notifications:
+  email: false
diff --git a/Makefile b/Makefile
index 4524ce2..a79872b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,4 @@
-.PHONY: test clean lint
-
-lint:
-	/bin/sh -en bundle_certs
-
-clean:
-	if [ -f .server.pid ] && [ -d "/proc/$$(cat .server.pid)" ]; then kill "$$(cat .server.pid)"; fi
-	rm -rf .testcerts certs .server.pid
+.PHONY: test
 
 .testcerts:
 	mkdir -p .testcerts
@@ -52,7 +45,7 @@ clean:
 .testcerts/bundle.crt: .testcerts/intermediates.crt .testcerts/server.crt
 	./bundle_certs .testcerts/* > .testcerts/bundle.crt
 
-test: lint .testcerts/bundle.crt .testcerts/root.crt .testcerts/server.key
+test: .testcerts/bundle.crt .testcerts/root.crt .testcerts/server.key
 	openssl s_server -cert .testcerts/bundle.crt -key .testcerts/server.key -quiet -www -no_dhe & echo "$$!" > .server.pid
 	test "$$(curl --fail --cacert .testcerts/root.crt --write-out '%{ssl_verify_result}' --silent --output /dev/null https://localhost:4433)" = "0"
 	if [ -f .server.pid ] && [ -d "/proc/$$(cat .server.pid)" ]; then kill "$$(cat .server.pid)"; fi
diff --git a/README.rst b/README.rst
index 4d8ce79..2e1a21e 100644
--- a/README.rst
+++ b/README.rst
@@ -1,6 +1,9 @@
 bundle-certs
 ############
 
+.. image:: https://travis-ci.org/adarnimrod/bundle_certs.svg?branch=master
+    :target: https://travis-ci.org/adarnimrod/bundle_certs
+
 A shell script to bundle SSL certificates in the correct order. The use case
 envisioned is programmatically handling SSL certificate renewal.
 
@@ -58,10 +61,9 @@ Shell functions
 Development
 -----------
 
-To ease development :code:`make clean`, :code:`make lint` and :code:`make test`
-are available. It's recommended to add :code:`make lint`  and :code:`make test`
-to to your Git pre-commit and pre-push hooks accordingly. Also, this repo has
-`pre-commit <http://pre-commit.com/>`_ configured.
+For testing run :code:`make test`. For cleaning temporary files run :code:`git
+clean -fdx`. You can use `pre-commit <http://pre-commit.com/>`_ to have the test
+(which is quite quick) run on every commit to ensure quality code.
 
 License
 -------
-- 
GitLab