Browse Source

Merge pull request #6829 from k32/bpapi-lockdown

ci(bpapi): Fail static check on BPAPI violations
k32 4 years ago
parent
commit
ffa857ccd9
2 changed files with 17 additions and 10 deletions
  1. 14 9
      apps/emqx/test/emqx_bpapi_static_checks.erl
  2. 3 1
      apps/emqx/test/emqx_bpapi_suite.erl

+ 14 - 9
apps/emqx/test/emqx_bpapi_static_checks.erl

@@ -70,15 +70,20 @@
 
 -spec run() -> boolean().
 run() ->
-    dump(), %% TODO: check return value
-    Dumps = filelib:wildcard(dumps_dir() ++ "/*.bpapi"),
-    case Dumps of
-        [] ->
-            ?ERROR("No BPAPI dumps are found in ~s, abort", [dumps_dir()]),
-            false;
-        _ ->
-            ?NOTICE("Running API compatibility checks for ~p", [Dumps]),
-            check_compat(Dumps)
+    case dump() of
+        true ->
+            Dumps = filelib:wildcard(dumps_dir() ++ "/*.bpapi"),
+            case Dumps of
+                [] ->
+                    ?ERROR("No BPAPI dumps are found in ~s, abort", [dumps_dir()]),
+                    false;
+                _ ->
+                    ?NOTICE("Running API compatibility checks for ~p", [Dumps]),
+                    check_compat(Dumps)
+            end;
+        false ->
+            ?CRITICAL("Backplane API violations found on the current branch."),
+            false
     end.
 
 -spec check_compat([file:filename()]) -> boolean().

+ 3 - 1
apps/emqx/test/emqx_bpapi_suite.erl

@@ -19,6 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
+-include_lib("emqx/include/logger.hrl").
 -include_lib("common_test/include/ct.hrl").
 -include_lib("stdlib/include/assert.hrl").
 
@@ -28,7 +29,8 @@ init_per_suite(Config) ->
     Config.
 
 end_per_suite(_Config) ->
-    ok.
+    ?NOTICE("If this test suite failed, and you are unsure why, read this:~n"
+            "https://github.com/emqx/emqx/blob/master/apps/emqx/src/bpapi/README.md", []).
 
 t_run_check(_) ->
     ?assertMatch(true, emqx_bpapi_static_checks:run()).