From da120f12377142ccfec533633df94358cf47f7d9 Mon Sep 17 00:00:00 2001
From: Tim Fechner <tim.fechner@hs-hannover.de>
Date: Tue, 26 Jul 2016 16:31:14 +0200
Subject: [PATCH] Introduce continuous integration (ci)

Provide "gulp build" command
---
 .gitlab-ci.yml                            | 47 +++++++++++++++++++++++
 gulpfile.js                               |  1 +
 salt_observer/private_settings.example.py |  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..b88591d
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,47 @@
+image: debian:stable
+
+# run this before every stage
+
+before_script:
+    # install environment
+    - apt-get update -q && apt-get install -qq curl python3-pip > /dev/null
+    - pip3 install -r requirements.txt
+
+    # set up project
+    - cp salt_observer/private_settings.example.py salt_observer/private_settings.py
+
+# build stage is the first stage
+
+ build_staticfiles:
+     stage: build
+     script:
+         # Install nodejs
+         - curl -sL https://deb.nodesource.com/setup_4.x | sh > /dev/null 2>&1
+         - apt-get update -q && apt-get install -qq nodejs
+
+         # install & run gulp
+         - npm i gulp-cli --global > /dev/null
+         - npm i > /dev/null
+         - gulp build
+
+         # collect staticfiles
+         - python3 manage.py collectstatic --noinput
+
+     artifacts:
+         paths:
+             - static/
+         name: "staticfiles"
+
+# execute test stage jobs if build stage is completed successful
+
+check_runserver:
+    stage: test
+    script:
+        - python3 manage.py runserver localhost:8000 &
+        - sleep 5
+        - curl -isSf http://localhost:8000/
+
+try_migrations:
+    stage: test
+    script:
+        - python3 manage.py migrate
diff --git a/gulpfile.js b/gulpfile.js
index 54dcca1..0527d11 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -20,6 +20,7 @@ gulp.task('default', [
     'collect:fonts',
     'compile:less'
 ]);
+gulp.task('build', ['default'])
 
 gulp.task('watch', ['default'], function() {
     var less_watcher = gulp.watch(src + 'less/**/*.less', ['compile:less']);
diff --git a/salt_observer/private_settings.example.py b/salt_observer/private_settings.example.py
index 183b256..2a4ab5d 100644
--- a/salt_observer/private_settings.example.py
+++ b/salt_observer/private_settings.example.py
@@ -7,7 +7,7 @@ SECRET_KEY = 'l=fg3h+kynh^y77ac7k%4ubsk4wz=z&1ud8uy*m%p(iw8*+xp-'
 
 # SECURITY WARNING:
 # don't run with debug turned on in production!
-DEBUG = False
+DEBUG = True
 
 # change this!
 ALLOWED_HOSTS = ['localhost']
-- 
GitLab