Skip to content

Commit

Permalink
Add a workflow to compare the bazel/erlang.mk output
Browse files Browse the repository at this point in the history
To catch any drift between the builds
  • Loading branch information
HoloRin committed May 15, 2023
1 parent 1ee8454 commit eb94a58
Show file tree
Hide file tree
Showing 29 changed files with 315 additions and 62 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/check-build-system-equivalence.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Check Bazel/Erlang.mk Equivalence
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
env:
erlang_version: 25.3
elixir_version: 1.14
VERSION: 3.13.0
PLUGINS: amqp10_common amqp10_client rabbitmq_amqp1_0 rabbitmq_auth_backend_cache rabbitmq_auth_backend_http rabbitmq_auth_backend_ldap rabbitmq_auth_backend_oauth2 rabbitmq_auth_mechanism_ssl rabbitmq_consistent_hash_exchange rabbitmq_event_exchange rabbitmq_federation rabbitmq_jms_topic_exchange rabbitmq_mqtt rabbitmq_random_exchange rabbitmq_recent_history_exchange rabbitmq_sharding rabbitmq_shovel rabbitmq_stomp rabbitmq_stream rabbitmq_trust_store rabbitmq_web_dispatch rabbitmq_management_agent rabbitmq_management rabbitmq_prometheus rabbitmq_federation_management rabbitmq_shovel_management rabbitmq_stream_management rabbitmq_top rabbitmq_tracing rabbitmq_web_mqtt rabbitmq_web_mqtt_examples rabbitmq_web_stomp rabbitmq_web_stomp_examples rabbitmq_aws rabbitmq_peer_discovery_common rabbitmq_peer_discovery_aws rabbitmq_peer_discovery_k8s rabbitmq_peer_discovery_consul rabbitmq_peer_discovery_etcd
jobs:
build-with-bazel:
name: bazel build package-generic-unix.tar.xz
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: CHECKOUT REPOSITORY
uses: actions/checkout@v3
- name: CONFIGURE ERLANG
uses: erlef/[email protected]
with:
otp-version: ${{ env.erlang_version }}
elixir-version: ${{ env.elixir_version }}
- name: CONFIGURE BAZEL
run: |
cat << EOF >> user.bazelrc
build --disk_cache=
build --color=yes
EOF
- name: BUILD package-generic-unix.tar.xz
run: |
bazelisk build //:package-generic-unix
- name: RESOLVE ARCHIVES_DIR
run: |
echo "archives_dir=$(readlink -f bazel-bin)" >> $GITHUB_ENV
- name: UPLOAD package-generic-unix.tar.xz
uses: actions/[email protected]
with:
name: bazel-package-generic-unix.tar.xz
path: ${{ env.archives_dir }}/package-generic-unix.tar.xz
if-no-files-found: error

build-with-make:
name: make package-generic-unix.tar.xz
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: CHECKOUT REPOSITORY
uses: actions/checkout@v3
with:
path: rabbitmq
- name: CONFIGURE ERLANG
uses: erlef/[email protected]
with:
otp-version: ${{ env.erlang_version }}
elixir-version: ${{ env.elixir_version }}
- name: BUILD package-generic-unix.tar.xz
env:
MAKE: make
run: |
$MAKE -C rabbitmq \
source-dist \
PACKAGES_DIR="$PWD/PACKAGES" \
PLUGINS="$PLUGINS" \
PROJECT_VERSION="$VERSION"
$MAKE -C rabbitmq/packaging \
package-generic-unix \
PACKAGES_DIR="$PWD/PACKAGES" \
VERSION="$VERSION"
- name: UPLOAD package-generic-unix.tar.xz
uses: actions/[email protected]
with:
name: make-package-generic-unix.tar.xz
path: PACKAGES/rabbitmq-server-generic-unix-*.tar.xz
if-no-files-found: error

compare:
needs:
- build-with-bazel
- build-with-make
name: Compare package-generic-unix.tar.xz
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: CHECKOUT REPOSITORY
uses: actions/checkout@v3
with:
path: rabbitmq-server
- name: CONFIGURE ERLANG
uses: erlef/[email protected]
with:
otp-version: ${{ env.erlang_version }}
elixir-version: ${{ env.elixir_version }}
- name: DOWNLOAD bazel-package-generic-unix.tar.xz
uses: actions/download-artifact@v3
with:
name: bazel-package-generic-unix.tar.xz
- name: DOWNLOAD make-package-generic-unix.tar.xz
uses: actions/download-artifact@v3
with:
name: make-package-generic-unix.tar.xz
- name: EXPAND & COMPARE
run: |
mkdir bazel
pushd bazel
tar -xf ${{ github.workspace }}/package-generic-unix.tar.xz
find . | sort > ${{ github.workspace }}/bazel.manifest
popd
mkdir make
pushd make
tar -xf ${{ github.workspace }}/rabbitmq-server-generic-unix-*.tar.xz
# delete an empty directory
rm -d rabbitmq_server-*/plugins/rabbitmq_random_exchange-*/include
find . | sort > ${{ github.workspace }}/make.manifest
popd
tree -L 2 bazel
tree -L 2 make
sleep 1
set -x
./rabbitmq-server/tools/compare_dist.sh make bazel
11 changes: 4 additions & 7 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ exports_files([
# gazelle:exclude deps/*/deps
# gazelle:exclude deps/*/.erlang.mk
# gazelle:exclude deps/rabbitmq_cli/_build
# gazelle:exclude extra_deps
# gazelle:exclude packaging
# gazelle:exclude PACKAGES
# gazelle:exclude plugins
# gazelle:exclude release-notes
# gazelle:exclude logs
# gazelle:erlang_apps_dirs deps
# gazelle:erlang_skip_rules test_erlang_app
Expand Down Expand Up @@ -217,13 +220,7 @@ iex_eval(

filegroup(
name = "root-licenses",
srcs = glob(
["LICENSE*"],
exclude = [
"LICENSE.md",
"LICENSE.txt",
],
),
srcs = glob(["LICENSE*"]),
visibility = ["//visibility:public"],
)

Expand Down
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ erlang_package.hex_package(
erlang_package.hex_package(
name = "gen_batch_server",
build_file = "@rabbitmq-server//bazel:BUILD.gen_batch_server",
sha256 = "94a49a528486298b009d2a1b452132c0a0d68b3e89d17d3764cb1ec879b7557a",
version = "0.8.7",
sha256 = "c3e6a1a2a0fb62aee631a98cfa0fd8903e9562422cbf72043953e2fb1d203017",
version = "0.8.8",
)

erlang_package.hex_package(
Expand Down
53 changes: 22 additions & 31 deletions bazel/BUILD.ranch
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ erlc_opts(

erlang_bytecode(
name = "behaviours",
srcs = ["src/ranch_transport.erl"],
outs = ["ebin/ranch_transport.beam"],
hdrs = [],
srcs = [
"src/ranch_transport.erl",
],
hdrs = [":public_and_private_hdrs"],
app_name = "ranch",
dest = "ebin",
erlc_opts = "//:erlc_opts",
)

Expand All @@ -44,27 +46,10 @@ erlang_bytecode(
"src/ranch_sup.erl",
"src/ranch_tcp.erl",
],
outs = [
"ebin/ranch.beam",
"ebin/ranch_acceptor.beam",
"ebin/ranch_acceptors_sup.beam",
"ebin/ranch_app.beam",
"ebin/ranch_conns_sup.beam",
"ebin/ranch_conns_sup_sup.beam",
"ebin/ranch_crc32c.beam",
"ebin/ranch_embedded_sup.beam",
"ebin/ranch_listener_sup.beam",
"ebin/ranch_protocol.beam",
"ebin/ranch_proxy_header.beam",
"ebin/ranch_server.beam",
"ebin/ranch_server_proxy.beam",
"ebin/ranch_ssl.beam",
"ebin/ranch_sup.beam",
"ebin/ranch_tcp.beam",
],
hdrs = [],
hdrs = [":public_and_private_hdrs"],
app_name = "ranch",
beam = [":behaviours"],
dest = "ebin",
erlc_opts = "//:erlc_opts",
)

Expand Down Expand Up @@ -99,19 +84,15 @@ filegroup(
],
)

filegroup(
name = "private_hdrs",
srcs = [],
)
filegroup(name = "private_hdrs")

filegroup(
name = "public_hdrs",
srcs = [],
)
filegroup(name = "public_hdrs")

filegroup(
name = "priv",
srcs = [],
srcs = [
"ebin/ranch.appup", # keep
],
)

filegroup(
Expand All @@ -138,13 +119,23 @@ filegroup(
erlang_app(
name = "erlang_app",
srcs = [":all_srcs"],
hdrs = [":public_hdrs"],
app_name = "ranch",
beam_files = [":beam_files"],
extra_apps = ["ssl"],
license_files = [":license_files"],
priv = [":priv"],
)

alias(
name = "ranch",
actual = ":erlang_app",
visibility = ["//visibility:public"],
)

filegroup(
name = "license_files",
srcs = [
"LICENSE",
],
)
2 changes: 1 addition & 1 deletion deps/amqp10_client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APP_EXTRA_KEYS = """%% Hex.pm package informations.
{licenses, ["MPL-2.0"]},
{links, [
{"Website", "https://www.rabbitmq.com/"},
{"GitHub", "https://github.com/rabbitmq/rabbitmq-server/deps/amqp10_client"}
{"GitHub", "https://github.com/rabbitmq/rabbitmq-server/tree/main/deps/amqp10_client"}
]},
{build_tools, ["make", "rebar3"]},
{files, [
Expand Down
2 changes: 1 addition & 1 deletion deps/amqp10_client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PACKAGES_DIR ?= $(abspath PACKAGES)
BUILD_DEPS = rabbit_common elvis_mk
DEPS = amqp10_common
TEST_DEPS = rabbit rabbitmq_amqp1_0 rabbitmq_ct_helpers
LOCAL_DEPS = ssl inets crypto
LOCAL_DEPS = ssl inets crypto public_key

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-test.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-macros.mk \
Expand Down
4 changes: 2 additions & 2 deletions deps/amqp10_common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ APP_EXTRA_KEYS = """%% Hex.pm package informations.
{licenses, ["MPL-2.0"]},
{links, [
{"Website", "https://www.rabbitmq.com/"},
{"GitHub", "https://github.com/rabbitmq/rabbitmq-server/deps/amqp10_common"}
{"GitHub", "https://github.com/rabbitmq/rabbitmq-server/tree/main/deps/amqp10_common"}
]},
{build_tools, ["make", "rebar3"]},
{files, [
Expand All @@ -66,7 +66,7 @@ APP_EXTRA_KEYS = """%% Hex.pm package informations.
"rabbitmq-components.mk",
"README",
"README.md",
"mk"
"src"
]}
"""

Expand Down
6 changes: 3 additions & 3 deletions deps/rabbit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1140,16 +1140,16 @@ genrule(
outs = ["manpages.tar"],
cmd = """set -euo pipefail
DESTDIR=manpages-tmp/share/man
DESTDIR=share/man
mkdir -p $${DESTDIR}
for mp in $(SRCS); do
section=$${mp##*.}
mkdir -p $${DESTDIR}/man$$section
gzip < $$mp \\
> $${DESTDIR}/man$$section/$$(basename $$mp).gz
done
tar --strip-components 1 -cf $@ manpages-tmp/*
rm -dr manpages-tmp
tar -cf $@ share
rm -dr share
""",
visibility = ["//visibility:public"],
)
Expand Down
5 changes: 1 addition & 4 deletions deps/rabbit/app.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,7 @@ def all_srcs(name = "all_srcs"):

filegroup(
name = "priv",
srcs = [
"priv/schema/.gitignore",
"priv/schema/rabbit.schema",
],
srcs = ["priv/schema/rabbit.schema"], #keep
)
filegroup(
name = "private_hdrs",
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbit_common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ endef
LOCAL_DEPS = compiler crypto public_key sasl ssl syntax_tools tools xmerl
DEPS = thoas recon credentials_obfuscation

dep_credentials_obfuscation = hex 3.2.0
dep_credentials_obfuscation = hex 3.4.0

# Variables and recipes in development.*.mk are meant to be used from
# any Git clone. They are excluded from the files published to Hex.pm.
Expand Down
4 changes: 3 additions & 1 deletion deps/rabbitmq_auth_backend_http/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ load(
)

APP_ENV = """[
{http_method, get},
{http_method, get},
{request_timeout, 15000},
{connection_timeout, 15000},
{user_path, "http://localhost:8000/auth/user"},
{vhost_path, "http://localhost:8000/auth/vhost"},
{resource_path, "http://localhost:8000/auth/resource"},
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_auth_backend_ldap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define PROJECT_APP_EXTRA_KEYS
{broker_version_requirements, []}
endef

LOCAL_DEPS = eldap
LOCAL_DEPS = eldap public_key
DEPS = rabbit_common rabbit
TEST_DEPS = ct_helper rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client
dep_ct_helper = git https://github.com/extend/ct_helper.git master
Expand Down
1 change: 1 addition & 0 deletions deps/rabbitmq_auth_backend_oauth2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PROJECT_DESCRIPTION = OAuth 2 and JWT-based AuthN and AuthZ backend
BUILD_WITHOUT_QUIC=1
export BUILD_WITHOUT_QUIC

LOCAL_DEPS = inets public_key
BUILD_DEPS = rabbit_common
DEPS = rabbit cowlib jose base64url
TEST_DEPS = cowboy rabbitmq_web_dispatch rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client rabbitmq_mqtt emqtt
Expand Down
1 change: 1 addition & 0 deletions deps/rabbitmq_auth_mechanism_ssl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define PROJECT_APP_EXTRA_KEYS
{broker_version_requirements, []}
endef

LOCAL_DEPS = public_key
DEPS = rabbit_common rabbit

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_aws/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ define PROJECT_ENV
[]
endef

LOCAL_DEPS = crypto inets ssl xmerl
LOCAL_DEPS = crypto inets ssl xmerl public_key
BUILD_DEPS = rabbit_common
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
TEST_DEPS = meck
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_federation_management/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define PROJECT_APP_EXTRA_KEYS
{broker_version_requirements, []}
endef

DEPS = rabbit_common rabbit rabbitmq_management rabbitmq_federation
DEPS = amqp_client rabbit_common rabbit rabbitmq_management rabbitmq_federation
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
Expand Down
1 change: 1 addition & 0 deletions deps/rabbitmq_jms_topic_exchange/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PROJECT = rabbitmq_jms_topic_exchange
PROJECT_DESCRIPTION = RabbitMQ JMS topic selector exchange plugin

LOCAL_DEPS = mnesia
DEPS = rabbit_common rabbit
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client

Expand Down
Loading

0 comments on commit eb94a58

Please sign in to comment.