Skip to content

Commit

Permalink
Merge pull request #8 from paulo-ferraz-oliveira/tsloughter/add-ci
Browse files Browse the repository at this point in the history
Add Erlang/OTP 24 to CI (+ bump ranch to 2.0.0 and adapt to it)
  • Loading branch information
tsloughter authored Apr 11, 2022
2 parents 7b39bea + 08c5d70 commit 3ee4eb7
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 29 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ jobs:

strategy:
matrix:
otp_version: ['23.2.1', '22.3.4.2']
otp_version: ['24', '23', '22']
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2

- uses: bajankristof/setup-erlang@master
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
otp-version: ${{matrix.otp_version}}
rebar3-version: '3.16'

- name: Compile
run: rebar3 compile
Expand All @@ -32,7 +33,9 @@ jobs:
- name: Tests
run: rebar3 ct --cover
- name: Dialyzer
run: rebar3 dialyzer
run: rebar3 as check dialyzer
- name: Xref
run: rebar3 as check xref
# - name: Covertool
# run: rebar3 covertool generate

Expand Down
17 changes: 14 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

{ct_opts, [{verbose,true}]}.

{dialyzer, [unknown]}.

{profiles,
[
{test, [
Expand All @@ -24,7 +22,20 @@
nowarn_export_all
]},
{deps,
[{ranch, "1.2.1"}]}
[{ranch, "2.0.0"}]}
]
},
{check, [
{deps,
[{ranch, "2.0.0"}]},
{dialyzer,
[{warnings,
[error_handling, unknown]},
{plt_extra_apps,
[inets, ranch]}
]},
{xref_checks,
[deprecated_function_calls, locals_not_used, undefined_function_calls]}
]
}]
}.
Expand Down
14 changes: 7 additions & 7 deletions src/chatterbox_ranch_protocol.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
%%-behaviour(ranch_protocol).

-export([
start_link/4,
init/4
start_link/3,
init/3
]).

start_link(Ref, Socket, Transport, Opts) ->
Pid = proc_lib:spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]),
start_link(Ref, Transport, Opts) ->
Pid = proc_lib:spawn_link(?MODULE, init, [Ref, Transport, Opts]),
{ok, Pid}.

init(Ref, Socket, T, Opts) ->
ok = ranch:accept_ack(Ref),
init(Ref, Transport, Opts) ->
{ok, Socket} = ranch:handshake(Ref),
Http2Settings = proplists:get_value(http2_settings, Opts, chatterbox:settings(server)),
h2_connection:become({transport(T), Socket}, Http2Settings).
h2_connection:become({transport(Transport), Socket}, Http2Settings).

transport(ranch_ssl) ->
ssl;
Expand Down
8 changes: 4 additions & 4 deletions src/h2_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ start_link(https,Host) ->
%% both.
-spec start_link(http | https,
string(),
non_neg_integer() | [ssl:ssl_option()]) ->
non_neg_integer() | [ssl:tls_option()]) ->
{ok, pid()}
| ignore
| {error, term()}.
Expand Down Expand Up @@ -100,7 +100,7 @@ start_link(https, Host, SSLOptions)
-spec start_link(http | https,
string(),
non_neg_integer(),
[ssl:ssl_option()]) ->
[ssl:tls_option()]) ->
{ok, pid()}
| ignore
| {error, term()}.
Expand All @@ -117,7 +117,7 @@ start_link(Transport, Host, Port, SSLOptions, ConnectionSettings) ->
-spec start(http | https,
string(),
non_neg_integer(),
[ssl:ssl_option()]) ->
[ssl:tls_option()]) ->
{ok, pid()}
| ignore
| {error, term()}.
Expand All @@ -131,7 +131,7 @@ start(Transport, Host, Port, SSLOptions) ->
-spec start(http | https,
string(),
non_neg_integer(),
[ssl:ssl_option()],
[ssl:tls_option()],
map()) ->
{ok, pid()}
| ignore
Expand Down
16 changes: 8 additions & 8 deletions src/h2_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
]).

-record(h2_listening_state, {
ssl_options :: [ssl:ssl_option()],
ssl_options :: [ssl:tls_option()],
listen_socket :: ssl:sslsocket() | inet:socket(),
transport :: gen_tcp | ssl,
listen_ref :: non_neg_integer(),
Expand Down Expand Up @@ -122,9 +122,9 @@
-spec start_client_link(gen_tcp | ssl,
inet:ip_address() | inet:hostname(),
inet:port_number(),
[ssl:ssl_option()],
[ssl:tls_option()],
settings(),
maps:map()
map()
) ->
{ok, pid()} | ignore | {error, term()}.
start_client_link(Transport, Host, Port, SSLOptions, Http2Settings, ConnectionSettings) ->
Expand All @@ -133,7 +133,7 @@ start_client_link(Transport, Host, Port, SSLOptions, Http2Settings, ConnectionSe
-spec start_client(gen_tcp | ssl,
inet:ip_address() | inet:hostname(),
inet:port_number(),
[ssl:ssl_option()],
[ssl:tls_option()],
settings(),
map()
) ->
Expand All @@ -158,16 +158,16 @@ start_client({Transport, Socket}, Http2Settings) ->
-spec start_ssl_upgrade_link(inet:ip_address() | inet:hostname(),
inet:port_number(),
binary(),
[ssl:ssl_option()],
[ssl:tls_option()],
settings(),
maps:map()
map()
) ->
{ok, pid()} | ignore | {error, term()}.
start_ssl_upgrade_link(Host, Port, InitialMessage, SSLOptions, Http2Settings, ConnectionSettings) ->
gen_statem:start_link(?MODULE, {client_ssl_upgrade, Host, Port, InitialMessage, SSLOptions, Http2Settings, ConnectionSettings}, []).

-spec start_server_link(socket(),
[ssl:ssl_option()],
[ssl:tls_option()],
settings()) ->
{ok, pid()} | ignore | {error, term()}.
start_server_link({Transport, ListenSocket}, SSLOptions, Http2Settings) ->
Expand All @@ -181,7 +181,7 @@ become(Socket) ->
become(Socket, Http2Settings) ->
become(Socket, Http2Settings, #{}).

-spec become(socket(), settings(), maps:map()) -> no_return().
-spec become(socket(), settings(), map()) -> no_return().
become({Transport, Socket}, Http2Settings, ConnectionSettings) ->
ok = sock:setopts({Transport, Socket}, [{packet, raw}, binary]),
case start_http2_server(Http2Settings,
Expand Down
3 changes: 1 addition & 2 deletions test/chatterbox_test_buddy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ start(Config) ->
{ok, _RanchPid} =
ranch:start_listener(
chatterbox_ranch_protocol,
10,
ranch_ssl,
[{port, 8081}|proplists:get_value(ssl_options, Settings)],
#{ socket_opts => [{port, 8081}|proplists:get_value(ssl_options, Settings)] },
chatterbox_ranch_protocol,
[]),
Config.
Expand Down
2 changes: 1 addition & 1 deletion test/peer_test_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

-record(state, {conn_pid :: pid(),
stream_id :: stream_id(),
peer = undefined :: undefined | {inet:ip_addres(),
peer = undefined :: undefined | {inet:ip_address(),
inet:port_number()}
}).

Expand Down

0 comments on commit 3ee4eb7

Please sign in to comment.