From 5202f7439387d97871d38a9457b02afddc09b211 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Erik=20Hedenstro=CC=88m?= <erik@hedenstroem.com>
Date: Tue, 5 Apr 2016 16:25:48 +0200
Subject: [PATCH] Added CI build config

---
 .gitlab-ci.yml | 23 +++++++++++++++++++++++
 rebar.config   | 15 +++++++++++++++
 rebar.lock     |  2 +-
 src/hijack.erl |  1 +
 4 files changed, 40 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..eebb8a3
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,23 @@
+cache:
+  paths:
+  - .rebar3
+
+before_script:
+  - export PATH=${ERL_HOME}/bin:$PATH
+  - rebar3 update
+
+stages:
+  - test
+  - publish
+
+test:
+  stage: test
+  script:
+    - rebar3 as test do eunit --cover --dir=test, cover --verbose
+    - coverage.escript _build/test/cover/eunit.coverdata
+
+aws_publish:
+  stage: publish
+  script:
+    - rebar3 as production do escriptize
+    - aws s3 cp _build/production/bin/hijack s3://s3.erlang.ninja/consul_proxy/extras/hijack
diff --git a/rebar.config b/rebar.config
index cdf8d10..72340fd 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,8 +1,23 @@
 {erl_opts, [debug_info, {parse_transform, lager_transform}]}.
+
 {escript_main_app, hijack}.
+
 {deps, [
     {getopt, "0.8.2"},
     {msgpack, "0.4.0"},
     {ranch, "1.1.0"},
     {gun, "1.0.0-pre.1"}
 ]}.
+
+{profiles, [
+    {test, [
+        {deps, [
+            {gurka, "0.1.7"}
+        ]},
+        {eunit_opts, [{report, {eunit_surefire, [{dir, "_build/test"}]}}]},
+        {erl_opts, [debug_info, nowarn_unused_vars]}
+    ]},
+    {production, [
+        {erl_opts, [no_debug_info, warnings_as_errors]}
+    ]}
+]}.
diff --git a/rebar.lock b/rebar.lock
index 49015df..e6b84a2 100644
--- a/rebar.lock
+++ b/rebar.lock
@@ -2,4 +2,4 @@
  {<<"getopt">>,{pkg,<<"getopt">>,<<"0.8.2">>},0},
  {<<"gun">>,{pkg,<<"gun">>,<<"1.0.0-pre.1">>},0},
  {<<"msgpack">>,{pkg,<<"msgpack">>,<<"0.4.0">>},0},
- {<<"ranch">>,{pkg,<<"ranch">>,<<"1.1.0">>},1}].
+ {<<"ranch">>,{pkg,<<"ranch">>,<<"1.1.0">>},0}].
diff --git a/src/hijack.erl b/src/hijack.erl
index 658003f..cbc0ac7 100644
--- a/src/hijack.erl
+++ b/src/hijack.erl
@@ -135,6 +135,7 @@ handle(State, #{<<"action">> := <<"bind">>, <<"host">> := Host, <<"path">> := Pa
     State;
 
 handle(State = #state{transport = Transport, consul_socket = Socket}, #{<<"action">> := <<"error">>, <<"message">> := Message}) ->
+    io:format("~s~n", [Message]),
     Transport:close(Socket),
     State#state{consul_socket = undefined};
 
-- 
GitLab