diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..eebb8a313b1d4bc133d3818beefadae2ef777d04 --- /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 cdf8d10cd675832f8ccc04256cf6756cb708977f..72340fdc9ea8adbed50f50663d05de1c61e17c23 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 49015df7d87393b98d6d97245d4065aced487f93..e6b84a28718d37104dbc08c0d3f17c0592f06c73 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 658003f97dc0555d4a3eeaa99a26ff0cd1618bfa..cbc0ac7b1961e5a00061f5da0b244a15bc276820 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};