From 853963da1ab0b060e26efa5cdcbfdba0833f4eaa Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 10 Jun 2024 22:17:21 +0200 Subject: [PATCH] removed rabbitmqctl_check_formatted We only apply it to later elixirs --- deps/rabbitmq_cli/BUILD.bazel | 30 ---- .../rabbitmqctl_check_formatted.bzl | 135 ------------------ 2 files changed, 165 deletions(-) delete mode 100644 deps/rabbitmq_cli/rabbitmqctl_check_formatted.bzl diff --git a/deps/rabbitmq_cli/BUILD.bazel b/deps/rabbitmq_cli/BUILD.bazel index 35931ebe5f54..a2c4e301d224 100644 --- a/deps/rabbitmq_cli/BUILD.bazel +++ b/deps/rabbitmq_cli/BUILD.bazel @@ -1,6 +1,5 @@ load("@rules_erlang//:dialyze.bzl", "dialyze", "plt") load(":rabbitmqctl.bzl", "rabbitmqctl") -load(":rabbitmqctl_check_formatted.bzl", "rabbitmqctl_check_formatted_test") load(":rabbitmqctl_test.bzl", "rabbitmqctl_test") load("//:rabbitmq_home.bzl", "rabbitmq_home") load("//:rabbitmq_run.bzl", "rabbitmq_run") @@ -68,35 +67,6 @@ rabbitmq_run( visibility = ["//visibility:public"], ) -rabbitmqctl_check_formatted_test( - name = "check_formatted", - size = "small", - srcs = [ - ".formatter.exs", - "config/config.exs", - "mix.exs", - ] + glob([ - "lib/**/*.ex", - "test/**/*.exs", - ]), - data = glob(["test/fixtures/**/*"]), - target_compatible_with = select({ - "@platforms//os:macos": [ - "@platforms//os:macos", - "@elixir_config//:elixir_1_15", - ], - "//conditions:default": [ - "@platforms//os:linux", - "@elixir_config//:elixir_1_15", - ], - }), -) - -test_suite( - name = "rabbitmqctl_check_formatted", - tests = ["check_formatted"], -) - plt( name = "deps_plt", apps = [ diff --git a/deps/rabbitmq_cli/rabbitmqctl_check_formatted.bzl b/deps/rabbitmq_cli/rabbitmqctl_check_formatted.bzl deleted file mode 100644 index b6f166a82970..000000000000 --- a/deps/rabbitmq_cli/rabbitmqctl_check_formatted.bzl +++ /dev/null @@ -1,135 +0,0 @@ -load( - "@rules_erlang//:util.bzl", - "path_join", - "windows_path", -) -load( - "//bazel/elixir:elixir_toolchain.bzl", - "elixir_dirs", - "erlang_dirs", - "maybe_install_erlang", -) - -def _impl(ctx): - (erlang_home, _, erlang_runfiles) = erlang_dirs(ctx) - (elixir_home, elixir_runfiles) = elixir_dirs(ctx, short_path = True) - - package_dir = path_join( - ctx.label.workspace_root, - ctx.label.package, - ) - - if not ctx.attr.is_windows: - output = ctx.actions.declare_file(ctx.label.name) - script = """set -euo pipefail - -{maybe_install_erlang} - -if [[ "{elixir_home}" == /* ]]; then - ABS_ELIXIR_HOME="{elixir_home}" -else - ABS_ELIXIR_HOME=$PWD/{elixir_home} -fi - -export PATH="$ABS_ELIXIR_HOME"/bin:"{erlang_home}"/bin:${{PATH}} - -export LANG="en_US.UTF-8" -export LC_ALL="en_US.UTF-8" - -INITIAL_DIR="$(pwd)" - -if [ ! -f ${{INITIAL_DIR}}/{package_dir}/test/test_helper.exs ]; then - echo "test_helper.exs cannot be found. 'bazel clean' might fix this." - exit 1 -fi - -cp -r ${{INITIAL_DIR}}/{package_dir}/config ${{TEST_UNDECLARED_OUTPUTS_DIR}} -cp -r ${{INITIAL_DIR}}/{package_dir}/lib ${{TEST_UNDECLARED_OUTPUTS_DIR}} -cp -r ${{INITIAL_DIR}}/{package_dir}/test ${{TEST_UNDECLARED_OUTPUTS_DIR}} -cp ${{INITIAL_DIR}}/{package_dir}/mix.exs ${{TEST_UNDECLARED_OUTPUTS_DIR}} -cp ${{INITIAL_DIR}}/{package_dir}/.formatter.exs ${{TEST_UNDECLARED_OUTPUTS_DIR}} - -cd ${{TEST_UNDECLARED_OUTPUTS_DIR}} - -export IS_BAZEL=true -export HOME=${{PWD}} -export MIX_ENV=test -export ERL_COMPILER_OPTIONS=deterministic -set -x -"${{ABS_ELIXIR_HOME}}"/bin/mix format --check-formatted -""".format( - maybe_install_erlang = maybe_install_erlang(ctx, short_path = True), - erlang_home = erlang_home, - elixir_home = elixir_home, - package_dir = package_dir, - ) - else: - output = ctx.actions.declare_file(ctx.label.name + ".bat") - script = """@echo off -:: set LANG="en_US.UTF-8" -:: set LC_ALL="en_US.UTF-8" - -set PATH="{elixir_home}\\bin";"{erlang_home}\\bin";%PATH% - -set OUTPUTS_DIR=%TEST_UNDECLARED_OUTPUTS_DIR:/=\\% - -:: robocopy exits non-zero when files are copied successfully -:: https://social.msdn.microsoft.com/Forums/en-US/d599833c-dcea-46f5-85e9-b1f028a0fefe/robocopy-exits-with-error-code-1?forum=tfsbuild -robocopy {package_dir}\\config %OUTPUTS_DIR%\\config /E /NFL /NDL /NJH /NJS /nc /ns /np -robocopy {package_dir}\\lib %OUTPUTS_DIR%\\lib /E /NFL /NDL /NJH /NJS /nc /ns /np -robocopy {package_dir}\\test %OUTPUTS_DIR%\\test /E /NFL /NDL /NJH /NJS /nc /ns /np -copy {package_dir}\\mix.exs %OUTPUTS_DIR%\\mix.exs || goto :error -copy {package_dir}\\.formatter.exs %OUTPUTS_DIR%\\.formatter.exs || goto :error - -cd %OUTPUTS_DIR% || goto :error - -set ERL_COMPILER_OPTIONS=deterministic -set MIX_ENV=test -"{elixir_home}\\bin\\mix" format --check-formatted || goto :error -goto :EOF -:error -exit /b 1 -""".format( - erlang_home = windows_path(erlang_home), - elixir_home = windows_path(elixir_home), - package_dir = windows_path(ctx.label.package), - ) - - ctx.actions.write( - output = output, - content = script, - ) - - runfiles = ctx.runfiles( - files = ctx.files.srcs + ctx.files.data, - ).merge_all([ - erlang_runfiles, - elixir_runfiles, - ]) - - return [DefaultInfo( - runfiles = runfiles, - executable = output, - )] - -rabbitmqctl_check_formatted_private_test = rule( - implementation = _impl, - attrs = { - "is_windows": attr.bool(mandatory = True), - "srcs": attr.label_list(allow_files = [".ex", ".exs"]), - "data": attr.label_list(allow_files = True), - }, - toolchains = [ - "//bazel/elixir:toolchain_type", - ], - test = True, -) - -def rabbitmqctl_check_formatted_test(**kwargs): - rabbitmqctl_check_formatted_private_test( - is_windows = select({ - "@bazel_tools//src/conditions:host_windows": True, - "//conditions:default": False, - }), - **kwargs - )