upgrade: +images +dialyzer +elvis (#31)

* upgrade: +images +dialyzer as test +elvis
This commit is contained in:
dinama 2021-02-05 15:37:36 +03:00 committed by GitHub
parent 05a77b22c6
commit db7c94b991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 96 additions and 101 deletions

2
Jenkinsfile vendored
View File

@ -18,6 +18,6 @@ build('machinery', 'docker-host', finalHook) {
pipeErlangLib = load("${env.JENKINS_LIB}/pipeErlangLib.groovy")
}
pipeErlangLib.runPipe(true, true)
pipeErlangLib.runPipe(true, false, 'test')
}

View File

@ -8,9 +8,9 @@ SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
SERVICE_NAME := machinery
BASE_IMAGE_NAME := service-erlang
BASE_IMAGE_TAG := 54a794b4875ad79f90dba0a7708190b3b37d584f
BASE_IMAGE_TAG := 51bd5f25d00cbf75616e2d672601dfe7351dcaa4
BUILD_IMAGE_NAME := build-erlang
BUILD_IMAGE_TAG := 19ff48ccbe09b00b79303fc6e5c63a3a9f8fd859
BUILD_IMAGE_TAG := 61a001bbb48128895735a3ac35b0858484fdb2eb
CALL_ANYWHERE := all submodules compile xref lint dialyze clean distclean check_format format
@ -35,7 +35,7 @@ xref: submodules
$(REBAR) xref
lint:
elvis rock
elvis rock -V
check_format:
$(REBAR) as test fmt -c
@ -44,7 +44,7 @@ format:
$(REBAR) fmt -w
dialyze: submodules
$(REBAR) dialyzer
$(REBAR) as test dialyzer
clean:
$(REBAR) clean

View File

@ -15,7 +15,7 @@ services:
condition: service_healthy
machinegun:
image: dr2.rbkmoney.com/rbkmoney/machinegun:c35e8a08500fbc2f0f0fa376a145a7324d18a062
image: dr2.rbkmoney.com/rbkmoney/machinegun:0da2ffc23221e1e3f8557b03d48d11d2dd18fac0
command: /opt/machinegun/bin/machinegun foreground
volumes:
- ./test/machinegun/config.yaml:/opt/machinegun/etc/config.yaml

View File

@ -2,46 +2,26 @@
{elvis, [
{config, [
#{
dirs => ["src"],
filter => "*.erl",
ignore => ["_thrift.erl$"],
rules => [
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace},
{elvis_style, macro_module_names},
{elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}},
{elvis_style, nesting_level, #{level => 3}},
{elvis_style, god_modules, #{limit => 30}},
{elvis_style, no_if_expression},
{elvis_style, invalid_dynamic_call, #{ignore => [elvis]}},
{elvis_style, used_ignored_variable},
{elvis_style, no_behavior_info},
{elvis_style, module_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$"}},
{elvis_style, function_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*$"}},
{elvis_style, state_record_and_type},
{elvis_style, no_spec_with_records},
{elvis_style, dont_repeat_yourself, #{min_complexity => 15}},
{elvis_style, no_debug_call, #{ignore => [elvis, elvis_utils]}}
]
},
#{
dirs => ["test"],
dirs => ["src", "test"],
filter => "*.erl",
rules => [
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace},
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_text_style, no_tabs},
{elvis_text_style, no_trailing_whitespace},
{elvis_style, macro_module_names},
{elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}},
{elvis_style, nesting_level, #{level => 3}},
{elvis_style, nesting_level, #{level => 4}},
{elvis_style, god_modules, #{limit => 30, ignore => []}},
{elvis_style, no_if_expression},
{elvis_style, invalid_dynamic_call, #{ignore => []}},
{elvis_style, used_ignored_variable},
{elvis_style, no_behavior_info},
{elvis_style, module_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$"}},
{elvis_style, function_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*$"}},
{elvis_style, module_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*(_SUITE)?$"}},
{elvis_style, function_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*$"}},
{elvis_style, state_record_and_type, #{ignore => []}},
{elvis_style, no_spec_with_records},
{elvis_style, dont_repeat_yourself, #{min_complexity => 30}}
{elvis_style, dont_repeat_yourself, #{min_complexity => 30}},
{elvis_style, no_debug_call, #{}}
]
},
#{
@ -58,18 +38,18 @@
dirs => ["."],
filter => "rebar.config",
rules => [
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace}
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_text_style, no_tabs},
{elvis_text_style, no_trailing_whitespace}
]
},
#{
dirs => ["src"],
filter => "*.app.src",
rules => [
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace}
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_text_style, no_tabs},
{elvis_text_style, no_trailing_whitespace}
]
}
]}

View File

@ -1,6 +1,5 @@
% Common project erlang options.
{erl_opts, [
% mandatory
debug_info,
warnings_as_errors,
@ -23,20 +22,13 @@
% bin_opt_info
% no_auto_import
% warn_missing_spec_all
]}.
% Common project dependencies.
{deps, [
{genlib,
{git, "https://github.com/rbkmoney/genlib.git", {branch, "master"}}
},
{woody,
{git, "https://github.com/rbkmoney/woody_erlang.git", {branch, "master"}}
},
{mg_proto,
{git, "https://github.com/rbkmoney/machinegun_proto.git", {branch, "master"}}
}
{genlib, {git, "https://github.com/rbkmoney/genlib.git", {branch, "master"}}},
{woody, {git, "https://github.com/rbkmoney/woody_erlang.git", {branch, "master"}}},
{mg_proto, {git, "https://github.com/rbkmoney/machinegun_proto.git", {branch, "master"}}}
]}.
{xref_checks, [
@ -54,14 +46,15 @@
race_conditions,
unknown
]},
{plt_apps, all_deps}
{plt_apps, all_deps},
{plt_extra_apps, [eunit, common_test]}
]}.
{plugins, [
{erlfmt, "0.8.0"}
{erlfmt, "0.10.0"}
]}.
{erlfmt, [
{print_width, 120},
{files, "{src,include,test}/*.{hrl,erl}"}
{files, ["{src,include,test}/*.{hrl,erl}", "rebar.config", "elvis.config"]}
]}.

View File

@ -1,7 +1,7 @@
{"1.1.0",
{"1.2.0",
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},3},
{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},2},
{<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},1},
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.3">>},2},
{<<"cg_mon">>,
{git,"https://github.com/rbkmoney/cg_mon.git",
{ref,"5a87a37694e42b6592d3b4164ae54e0e87e24e18"}},
@ -17,48 +17,63 @@
{ref,"4565a8d73f34a0b78cca32c9cd2b97d298bdadf8"}},
0},
{<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},1},
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.15.2">>},1},
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.17.0">>},1},
{<<"how_are_you">>,
{git,"https://github.com/rbkmoney/how_are_you.git",
{ref,"8f11d17eeb6eb74096da7363a9df272fd3099718"}},
1},
{<<"idna">>,{pkg,<<"idna">>,<<"6.0.0">>},2},
{<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2},
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2},
{<<"mg_proto">>,
{git,"https://github.com/rbkmoney/machinegun_proto.git",
{ref,"d814d6948d4ff13f6f41d12c6613f59c805750b2"}},
0},
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},3},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},2},
{<<"snowflake">>,
{git,"https://github.com/rbkmoney/snowflake.git",
{ref,"7f379ad5e389e1c96389a8d60bae8117965d6a6d"}},
{ref,"de159486ef40cec67074afe71882bdc7f7deab72"}},
1},
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.5">>},2},
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},2},
{<<"thrift">>,
{git,"https://github.com/rbkmoney/thrift_erlang.git",
{ref,"846a0819d9b6d09d0c31f160e33a78dbad2067b4"}},
1},
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.4.1">>},3},
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2},
{<<"woody">>,
{git,"https://github.com/rbkmoney/woody_erlang.git",
{ref,"58f56b462429ab1fee65e1bdb34b73512406ba00"}},
{ref,"f2cd30883d58eb1c3ab2172556956f757bc27e23"}},
0}]}.
[
{pkg_hash,[
{<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>},
{<<"cache">>, <<"3C11DBF4CD8FCD5787C95A5FB2A04038E3729CFCA0386016EEA8C953AB48A5AB">>},
{<<"certifi">>, <<"867CE347F7C7D78563450A18A6A28A8090331E77FA02380B4A21962A65D36EE5">>},
{<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>},
{<<"certifi">>, <<"70BDD7E7188C804F3A30EE0E7C99655BC35D8AC41C23E12325F36AB449B70651">>},
{<<"cowboy">>, <<"91ED100138A764355F43316B1D23D7FF6BDB0DE4EA618CB5D8677C93A7A2F115">>},
{<<"cowlib">>, <<"FD0FF1787DB84AC415B8211573E9A30A3EBE71B5CBFF7F720089972B2319C8A4">>},
{<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>},
{<<"hackney">>, <<"07E33C794F8F8964EE86CEBEC1A8ED88DB5070E52E904B8F12209773C1036085">>},
{<<"idna">>, <<"689C46CBCDF3524C44D5F3DDE8001F364CD7608A99556D8FBD8239A5798D4C10">>},
{<<"hackney">>, <<"717EA195FD2F898D9FE9F1CE0AFCC2621A41ECFE137FAE57E7FE6E9484B9AA99">>},
{<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>},
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
{<<"parse_trans">>, <<"16328AB840CC09919BD10DAB29E431DA3AF9E9E7E7E6F0089DD5A2D2820011D8">>},
{<<"ranch">>, <<"6B1FAB51B49196860B733A49C07604465A47BDB78AA10C1C16A3D199F7F8C881">>},
{<<"ssl_verify_fun">>, <<"6EAF7AD16CB568BB01753DBBD7A95FF8B91C7979482B95F38443FE2C8852A79B">>},
{<<"unicode_util_compat">>, <<"D869E4C68901DD9531385BB0C8C40444EBF624E60B6962D95952775CAC5E90CD">>}]}
{<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>},
{<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]},
{pkg_hash_ext,[
{<<"bear">>, <<"534217DCE6A719D59E54FB0EB7A367900DBFC5F85757E8C1F94269DF383F6D9B">>},
{<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>},
{<<"certifi">>, <<"ED516ACB3929B101208A9D700062D520F3953DA3B6B918D866106FFA980E1C10">>},
{<<"cowboy">>, <<"04FD8C6A39EDC6AAA9C26123009200FC61F92A3A94F3178C527B70B767C6E605">>},
{<<"cowlib">>, <<"79F954A7021B302186A950A32869DBC185523D99D3E44CE430CD1F3289F41ED4">>},
{<<"gproc">>, <<"580ADAFA56463B75263EF5A5DF4C86AF321F68694E7786CB057FD805D1E2A7DE">>},
{<<"hackney">>, <<"64C22225F1EA8855F584720C0E5B3CD14095703AF1C9FBC845BA042811DC671C">>},
{<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>},
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
{<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>},
{<<"parse_trans">>, <<"07CD9577885F56362D414E8C4C4E6BDF10D43A8767ABB92D24CBE8B24C54888B">>},
{<<"ranch">>, <<"451D8527787DF716D99DC36162FCA05934915DB0B6141BBDAC2EA8D3C7AFC7D7">>},
{<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>},
{<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]}
].

View File

@ -89,9 +89,10 @@ construct_namespace(NS) ->
-type machine() :: machinery:machine(ev(), _).
-type handler_opts() :: machinery:handler_opts(_).
-type result() :: machinery:result(ev(), _).
-type response() :: machinery:response(
ok | {error, id()}
).
-type response() ::
machinery:response(
ok | {error, id()}
).
-type ev() :: id().

View File

@ -38,9 +38,10 @@
%% handler server spec
-type handler(A) :: {logic_handler(A), handler_config()}.
-type handler_opts() :: machinery:handler_opts(#{
woody_ctx := woody_context:ctx()
}).
-type handler_opts() ::
machinery:handler_opts(#{
woody_ctx := woody_context:ctx()
}).
-type backend_handler_opts() :: #{
handler := logic_handler(_),
@ -48,11 +49,12 @@
}.
%% Client types
-type backend_opts() :: machinery:backend_opts(#{
woody_ctx := woody_context:ctx(),
client := machinery_mg_client:woody_client(),
?BACKEND_CORE_OPTS
}).
-type backend_opts() ::
machinery:backend_opts(#{
woody_ctx := woody_context:ctx(),
client := machinery_mg_client:woody_client(),
?BACKEND_CORE_OPTS
}).
-type backend() :: {?MODULE, backend_opts()}.

View File

@ -28,20 +28,22 @@
%% handler server spec
-type handler() :: handler_config().
-type handler_opts() :: machinery:handler_opts(#{
woody_ctx := woody_context:ctx()
}).
-type handler_opts() ::
machinery:handler_opts(#{
woody_ctx := woody_context:ctx()
}).
-type backend_handler_opts() :: #{
?BACKEND_CORE_OPTS
}.
%% Client types
-type backend_opts() :: machinery:backend_opts(#{
woody_ctx := woody_context:ctx(),
client := machinery_mg_client:woody_client(),
?BACKEND_CORE_OPTS
}).
-type backend_opts() ::
machinery:backend_opts(#{
woody_ctx := woody_context:ctx(),
client := machinery_mg_client:woody_client(),
?BACKEND_CORE_OPTS
}).
-type backend() :: {?MODULE, backend_opts()}.

View File

@ -61,7 +61,7 @@ start_app(woody = AppName) ->
start_app(AppName) ->
{start_app_with(AppName, []), #{}}.
-spec start_app_with(app_name(), app_env()) -> {[app_name()], #{atom() => _}}.
-spec start_app_with(app_name(), app_env()) -> [app_name()].
start_app_with(AppName, Env) ->
_ = application:load(AppName),
_ = set_app_env(AppName, Env),

View File

@ -43,7 +43,7 @@ all() ->
{group, machinery_mg_backend}
].
-spec groups() -> [{group_name(), list(), test_case_name()}].
-spec groups() -> [{group_name(), list(), [test_case_name() | {group, group_name()}]}].
groups() ->
[
{machinery_mg_backend, [], [{group, all}]},

View File

@ -45,7 +45,7 @@ all() ->
{group, machinery_mg_backend}
].
-spec groups() -> [{group_name(), list(), test_case_name()}].
-spec groups() -> [{group_name(), list(), [test_case_name() | {group, group_name()}]}].
groups() ->
[
{machinery_mg_backend, [], [{group, all}]},
@ -130,6 +130,7 @@ init(init_something, _Machine, _, _Opts) ->
aux_state => #{}
}.
-dialyzer({nowarn_function, process_timeout/3}).
-spec process_timeout(machine(), undefined, handler_opts()) -> result().
process_timeout(_Args, _, _Opts) ->
erlang:error({not_implemented, process_timeout}).

View File

@ -42,7 +42,7 @@ all() ->
{group, all}
].
-spec groups() -> [{group_name(), list(), test_case_name()}].
-spec groups() -> [{group_name(), list(), [test_case_name()]}].
groups() ->
[
{all, [parallel], [

View File

@ -45,7 +45,7 @@ all() ->
{group, machinery_mg_backend}
].
-spec groups() -> [{group_name(), list(), test_case_name()}].
-spec groups() -> [{group_name(), list(), [test_case_name()]}].
groups() ->
[
{machinery_mg_backend, [], [{group, all}]},
@ -164,6 +164,7 @@ init(init_numbers, _Machine, _, _Opts) ->
events => lists:seq(1, 100)
}.
-dialyzer({nowarn_function, process_timeout/3}).
-spec process_timeout(machine(), undefined, handler_opts()) -> result().
process_timeout(#{}, _, _Opts) ->
erlang:error({not_implemented, process_timeout}).

View File

@ -41,7 +41,7 @@ all() ->
{group, machinery_mg_backend}
].
-spec groups() -> [{group_name(), list(), test_case_name()}].
-spec groups() -> [{group_name(), list(), [test_case_name() | {group, group_name()}]}].
groups() ->
[
{machinery_mg_backend, [], [{group, all}]},

View File

@ -43,7 +43,7 @@ all() ->
{group, machinery_mg_backend}
].
-spec groups() -> [{group_name(), list(), test_case_name()}].
-spec groups() -> [{group_name(), list(), [test_case_name() | {group, group_name()}]}].
groups() ->
[
{machinery_mg_backend, [], [{group, all}]},