Merge pull request #4269 from zmstone/chore-replayq-upgrade-to-0.3.2

chore(deps): upgrade replayq to version 0.3.2
This commit is contained in:
Zaiming Shi 2021-03-03 06:19:52 +01:00 committed by GitHub
commit 2c5f2a8cdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 91 additions and 19 deletions

View File

@ -0,0 +1,13 @@
name: Check Rebar Dependencies
on: [pull_request]
jobs:
check_deps_integrity:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Run check-deps-integrity.escript
run: |
docker run --rm -v "$(pwd):/emqx" emqx/build-env:erl23.2.2-ubuntu20.04 sh -c 'cd /emqx && ./scripts/check-deps-integrity.escript'

View File

@ -1,5 +1,5 @@
{deps,
[{pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.3"}}}
[{pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
]}.
{edoc_opts, [{preprocess, true}]}.

View File

@ -1,14 +1 @@
{edoc_opts, [{preprocess, true}]}.
{erl_opts, [warn_unused_vars,
warn_shadow_vars,
warn_unused_import,
warn_obsolete_guard,
debug_info,
{parse_transform}]}.
{xref_checks, [undefined_function_calls, undefined_functions,
locals_not_used, deprecated_function_calls,
warnings_as_errors, deprecated_functions]}.
{cover_enabled, true}.
{cover_opts, [verbose]}.
{cover_export_enabled, true}.
{deps, []}.

View File

@ -46,7 +46,7 @@
, {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.1.0"}}}
, {minirest, {git, "https://github.com/emqx/minirest", {tag, "0.3.3"}}}
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.0"}}}
, {replayq, {git, "https://github.com/emqx/replayq", {tag, "0.3.1"}}}
, {replayq, {git, "https://github.com/emqx/replayq", {tag, "0.3.2"}}}
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.2.3"}}}
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.2"}}}

View File

@ -5,7 +5,7 @@
do(_Dir, CONFIG) ->
C1 = deps(CONFIG),
Config = dialyzer(C1),
dump(Config ++ [{overrides, overrides()}] ++ coveralls() ++ config()).
maybe_dump(Config ++ [{overrides, overrides()}] ++ coveralls() ++ config()).
bcrypt() ->
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}.
@ -286,10 +286,19 @@ get_vsn() ->
Vsn2 = re:replace(PkgVsn, "v", "", [{return ,list}]),
re:replace(Vsn2, "\n", "", [{return ,list}]).
dump(Config) ->
file:write_file("rebar.config.rendered", [io_lib:format("~p.\n", [I]) || I <- Config]),
maybe_dump(Config) ->
is_debug() andalso file:write_file("rebar.config.rendered", [io_lib:format("~p.\n", [I]) || I <- Config]),
Config.
is_debug() -> is_debug("DEBUG") orelse is_debug("DIAGNOSTIC").
is_debug(VarName) ->
case os:getenv(VarName) of
false -> false;
"" -> false;
_ -> true
end.
provide_bcrypt_dep() ->
case os:type() of
{win32, _} -> false;

View File

@ -0,0 +1,63 @@
#!/usr/bin/env escript
%% NOTE: this script should be executed at project root.
-mode(compile).
main([]) ->
AppsDir = case filelib:is_file("EMQX_ENTERPRISE") of
true -> "lib-ee";
false -> "lib-ce"
end,
true = filelib:is_dir(AppsDir),
Files = ["rebar.config"] ++
apps_rebar_config("apps") ++
apps_rebar_config(AppsDir),
Deps = collect_deps(Files, #{}),
case count_bad_deps(Deps) of
0 ->
io:format("OK~n");
N ->
io:format(standard_error, "~p dependency discrepancies", [N]),
halt(1)
end.
apps_rebar_config(Dir) ->
filelib:wildcard(filename:join([Dir, "*", "rebar.config"])).
%% collect a kv-list of {DepName, [{DepReference, RebarConfigFile}]}
%% the value part should have unique DepReference
collect_deps([], Acc) -> maps:to_list(Acc);
collect_deps([File | Files], Acc) ->
Deps =
try
{ok, Config} = file:consult(File),
{deps, Deps0} = lists:keyfind(deps, 1, Config),
Deps0
catch
C : E : St ->
erlang:raise(C, {E, {failed_to_find_deps_in_rebar_config, File}}, St)
end,
collect_deps(Files, do_collect_deps(Deps, File, Acc)).
do_collect_deps([], _File, Acc) -> Acc;
do_collect_deps([{Name, Ref} | Deps], File, Acc) ->
Refs = maps:get(Name, Acc, []),
do_collect_deps(Deps, File, Acc#{Name => [{Ref, File} | Refs]}).
count_bad_deps([]) -> 0;
count_bad_deps([{Name, Refs0} | Rest]) ->
Refs = lists:keysort(1, Refs0),
case is_unique_ref(Refs) of
true ->
count_bad_deps(Rest);
false ->
io:format(standard_error, "~p:~n~p~n", [Name, Refs]),
1 + count_bad_deps(Rest)
end.
is_unique_ref([_]) -> true;
is_unique_ref([{Ref, _File1}, {Ref, File2} | Rest]) ->
is_unique_ref([{Ref, File2} | Rest]);
is_unique_ref(_) ->
false.