diff options
author | Rin Kuryloski <kuryloskip@vmware.com> | 2023-05-01 10:32:59 +0200 |
---|---|---|
committer | Rin Kuryloski <kuryloskip@vmware.com> | 2023-05-15 13:54:14 +0200 |
commit | eb94a58bc9f4db7a226af26d6f57fdfa24076ed8 (patch) | |
tree | 7cc1ae03a0b3883dd9454085a5d770e1e9515008 /tools | |
parent | 1ee8454129b7769fda6dfc1a528e886b290aa258 (diff) | |
download | rabbitmq-server-git-eb94a58bc9f4db7a226af26d6f57fdfa24076ed8.tar.gz |
Add a workflow to compare the bazel/erlang.mk output
To catch any drift between the builds
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/compare_dist.sh | 44 | ||||
-rwxr-xr-x | tools/erlang_app_equal | 68 |
2 files changed, 112 insertions, 0 deletions
diff --git a/tools/compare_dist.sh b/tools/compare_dist.sh new file mode 100755 index 0000000000..7b6f2d374e --- /dev/null +++ b/tools/compare_dist.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -euo pipefail + +GOLDEN=$1 +SECOND=$2 + +echo "Check both have INSTALL" +test -f $GOLDEN/rabbitmq_server-${VERSION}/INSTALL +test -f $SECOND/rabbitmq_server-${VERSION}/INSTALL + +echo "Check LICENSEs" +diff \ + <(grep LICENSE make.manifest) \ + <(grep LICENSE bazel.manifest | grep -v ".md" | grep -v ".txt") + +echo "Check plugins" +plugins_rel=rabbitmq_server-${VERSION}/plugins +diff <(grep $plugins_rel make.manifest | grep -v ".ez") <(grep $plugins_rel bazel.manifest | grep -v ".ez") + +echo "Plugins exist with same version and deps" +for p in ${PLUGINS}; do + echo "$p" + f="$(cd $GOLDEN && ls -d $plugins_rel/$p-*)" + test -f $GOLDEN/$f/ebin/$p.app || (echo "$GOLDEN/$f/ebin/$p.app does not exist"; exit 1) + test -d $SECOND/$f || (echo "$SECOND/$f does not exist"; exit 1) + test -f $SECOND/$f/ebin/$p.app || (echo "$SECOND/$f/ebin/$p.app does not exist"; exit 1) + ./rabbitmq-server/tools/erlang_app_equal \ + $GOLDEN/$f/ebin/$p.app \ + $SECOND/$f/ebin/$p.app +done + +echo "Both have escript" +escript_rel=rabbitmq_server-${VERSION}/escript +diff <(grep $escript_rel make.manifest) <(grep $escript_rel bazel.manifest) + +echo "Both have sbin" +sbin_rel=rabbitmq_server-${VERSION}/sbin +diff <(grep $sbin_rel make.manifest) <(grep $sbin_rel bazel.manifest) + +echo "Both have manpages" +manpages_rel=rabbitmq_server-${VERSION}/share/man +diff <(grep $manpages_rel make.manifest) <(grep $manpages_rel bazel.manifest) + +echo "PASS" diff --git a/tools/erlang_app_equal b/tools/erlang_app_equal new file mode 100755 index 0000000000..ba3a4bef28 --- /dev/null +++ b/tools/erlang_app_equal @@ -0,0 +1,68 @@ +#!/usr/bin/env escript +%% -*- erlang -*- +%%! -nocookie + +-mode(compile). + +main([Left, Right]) -> + {ok, LeftMetadata} = file:consult(Left), + {ok, RightMetadata} = file:consult(Right), + compare(LeftMetadata, RightMetadata), + halt(); +main(_) -> + halt(1). + +compare(LeftMetadata, RightMetadata) -> + [{application, LeftApp, LeftProps}] = LeftMetadata, + [{application, RightApp, RightProps}] = RightMetadata, + + assert_equal(LeftApp, RightApp, "application name"), + + LeftId = proplists:get_value(id, LeftProps), + RightId = proplists:get_value(id, RightProps), + case LeftId of + RightId -> + ok; + _ -> + io:format(standard_error, + "Warning:\t 'id' does not match (~p != ~p)~n", [LeftId, RightId]) + end, + + LeftPropsMap = proplists:to_map(proplists:delete(id, LeftProps)), + RightPropsMap = proplists:to_map(proplists:delete(id, RightProps)), + assert_equal( + lists:sort(maps:keys(LeftPropsMap)), + lists:sort(maps:keys(RightPropsMap)), + "app property keys" + ), + [case K of + K when K =:= applications orelse K =:= modules -> + assert_equal( + lists:sort(maps:get(K, LeftPropsMap)), + lists:sort(maps:get(K, RightPropsMap)), + K + ); + env -> + assert_equal( + proplists:to_map(maps:get(K, LeftPropsMap)), + proplists:to_map(maps:get(K, RightPropsMap)), + K + ); + _ -> + assert_equal( + maps:get(K, LeftPropsMap), + maps:get(K, RightPropsMap), + K + ) + end || K <- lists:sort(maps:keys(LeftPropsMap))], + ok. + +assert_equal(Expected, Actual, Context) -> + case Actual of + Expected -> + ok; + _ -> + io:format(standard_error, + "Expected:\t~p~n But got:\t~p~n For:\t~p~n", [Expected, Actual, Context]), + erlang:error(assertion_failed) + end. |