From d90566be5c5a533a143388612e21fa767744a453 Mon Sep 17 00:00:00 2001 From: k32 <10274441+k32@users.noreply.github.com> Date: Fri, 21 Jan 2022 13:18:54 +0100 Subject: [PATCH] ci(bpapi): Fail static check on BPAPI violations --- apps/emqx/test/emqx_bpapi_static_checks.erl | 23 +++++++++++++-------- apps/emqx/test/emqx_bpapi_suite.erl | 4 +++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/apps/emqx/test/emqx_bpapi_static_checks.erl b/apps/emqx/test/emqx_bpapi_static_checks.erl index 2d514d5e5..57f6d95ea 100644 --- a/apps/emqx/test/emqx_bpapi_static_checks.erl +++ b/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(). diff --git a/apps/emqx/test/emqx_bpapi_suite.erl b/apps/emqx/test/emqx_bpapi_suite.erl index 5d0a313f8..ab86e5211 100644 --- a/apps/emqx/test/emqx_bpapi_suite.erl +++ b/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()).