From cae7ede7b8f962007133740c16bc7d3811a55d01 Mon Sep 17 00:00:00 2001
From: rubo77 <github@r.z11.de>
Date: Sun, 2 Jul 2017 14:08:10 +0200
Subject: [PATCH] =?UTF-8?q?Tracis-CI=20check=20auf=20Validit=C3=A4t=20der?=
 =?UTF-8?q?=20site.conf?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .travis.yml            | 13 +++++++++++++
 tests/site_config.lua  |  9 +++++++++
 tests/validate_site.sh |  6 ++++++
 3 files changed, 28 insertions(+)
 create mode 100644 .travis.yml
 create mode 100644 tests/site_config.lua
 create mode 100644 tests/validate_site.sh

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f953ee2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,13 @@
+language: bash
+
+sudo: true
+
+before_install:
+  - sudo apt-get -qq update
+  - sudo apt-get install lua5.1 luarocks
+  
+install:
+  - sudo luarocks install lua-cjson
+
+script:
+  - bash tests/validate_site.sh
diff --git a/tests/site_config.lua b/tests/site_config.lua
new file mode 100644
index 0000000..d7bdc1f
--- /dev/null
+++ b/tests/site_config.lua
@@ -0,0 +1,9 @@
+local config = os.getenv('GLUON_SITEDIR')
+
+local function loader()
+   coroutine.yield('return ')
+   coroutine.yield(io.open(config .. '/site.conf'):read('*a'))
+end
+
+-- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
+return setfenv(assert(load(coroutine.wrap(loader), 'site.conf')), {})()
diff --git a/tests/validate_site.sh b/tests/validate_site.sh
new file mode 100644
index 0000000..34a4a3f
--- /dev/null
+++ b/tests/validate_site.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# validate_site.sh checks if the site.conf is valid json
+
+GLUON_SITEDIR="." lua5.1 tests/site_config.lua
+              
-- 
GitLab