From c641ec0e8247ffa60010c1f749ef281d9d5dfb59 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 1 May 2023 11:18:40 +0200 Subject: [PATCH 01/13] Express the multi-arch nature of .beam files via a transition This allows beam files to cache across architectures --- erlang_app_info.bzl | 10 +++++++++- private/beam_transition.bzl | 17 +++++++++++++++++ private/erlang_bytecode2.bzl | 5 +++++ private/escript_archive.bzl | 12 +++++++++++- private/escript_flat.bzl | 8 ++++++++ private/eunit.bzl | 8 ++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 private/beam_transition.bzl diff --git a/erlang_app_info.bzl b/erlang_app_info.bzl index 0d485153..d035485c 100644 --- a/erlang_app_info.bzl +++ b/erlang_app_info.bzl @@ -1,3 +1,5 @@ +load("//private:beam_transition.bzl", "beam_transition") + ErlangAppInfo = provider( doc = "Compiled Erlang Application", fields = { @@ -62,11 +64,17 @@ erlang_app_info = rule( "extra_apps": attr.string_list(), "hdrs": attr.label_list(allow_files = True), "app": attr.label(allow_files = [".app"]), - "beam": attr.label_list(allow_files = [".beam", ".appup"]), + "beam": attr.label_list( + allow_files = [".beam", ".appup"], + cfg = beam_transition, + ), "priv": attr.label_list(allow_files = True), "license_files": attr.label_list(allow_files = True), "srcs": attr.label_list(allow_files = True), "deps": attr.label_list(providers = [ErlangAppInfo]), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, provides = [ErlangAppInfo], ) diff --git a/private/beam_transition.bzl b/private/beam_transition.bzl new file mode 100644 index 00000000..e45f0ac9 --- /dev/null +++ b/private/beam_transition.bzl @@ -0,0 +1,17 @@ +def _impl(settings, attr): + _ignore = (settings, attr) + + # print("_impl") + # print("settings", settings) + # print("attr", attr) + return { + "arm": {"//command_line_option:cpu": "arm"}, + "x86": {"//command_line_option:cpu": "x86"}, + "k8": {"//command_line_option:cpu": "k8"}, + } + +beam_transition = transition( + implementation = _impl, + inputs = [], + outputs = ["//command_line_option:cpu"], +) diff --git a/private/erlang_bytecode2.bzl b/private/erlang_bytecode2.bzl index cc1a657d..293e9952 100644 --- a/private/erlang_bytecode2.bzl +++ b/private/erlang_bytecode2.bzl @@ -1,5 +1,6 @@ load("//:erlang_app_info.bzl", "ErlangAppInfo", "flat_deps") load("//:util.bzl", "path_join") +load(":beam_transition.bzl", "beam_transition") load(":erlang_bytecode.bzl", "unique_dirnames") load(":util.bzl", "erl_libs_contents") load( @@ -133,6 +134,7 @@ erlang_bytecode = rule( ), "beam": attr.label_list( allow_files = [".beam"], + cfg = beam_transition, ), "deps": attr.label_list( providers = [ErlangAppInfo], @@ -146,6 +148,9 @@ erlang_bytecode = rule( "outs": attr.output_list( mandatory = True, ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], ) diff --git a/private/escript_archive.bzl b/private/escript_archive.bzl index 746bac54..144cf098 100644 --- a/private/escript_archive.bzl +++ b/private/escript_archive.bzl @@ -12,6 +12,10 @@ load( "//:util.bzl", "path_join", ) +load( + ":beam_transition.bzl", + "beam_transition", +) load( ":util.bzl", "additional_file_dest_relative_path", @@ -137,10 +141,16 @@ escript_archive = rule( ), "srcs": attr.label_list(allow_files = [".erl"]), "hdrs": attr.label_list(allow_files = [".hrl"]), - "beam": attr.label_list(allow_files = [".beam"]), + "beam": attr.label_list( + allow_files = [".beam"], + cfg = beam_transition, + ), "app": attr.label(providers = [ErlangAppInfo]), "flat": attr.bool(), "drop_hrl": attr.bool(), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], executable = True, diff --git a/private/escript_flat.bzl b/private/escript_flat.bzl index 0c630146..720c46f1 100644 --- a/private/escript_flat.bzl +++ b/private/escript_flat.bzl @@ -3,6 +3,10 @@ load( "erlang_dirs", "maybe_install_erlang", ) +load( + ":beam_transition.bzl", + "beam_transition", +) def _impl(ctx): out = ctx.actions.declare_file(ctx.attr.out if ctx.attr.out != "" else ctx.label.name) @@ -63,8 +67,12 @@ escript_flat = rule( ), "beam": attr.label( allow_single_file = [".beam"], + cfg = beam_transition, ), "out": attr.string(), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], ) diff --git a/private/eunit.bzl b/private/eunit.bzl index 7a5adb35..ecd08dfc 100644 --- a/private/eunit.bzl +++ b/private/eunit.bzl @@ -8,6 +8,10 @@ load( "path_join", "windows_path", ) +load( + ":beam_transition.bzl", + "beam_transition", +) load( ":util.bzl", "erl_libs_contents", @@ -222,6 +226,7 @@ eunit_test = rule( "is_windows": attr.bool(mandatory = True), "compiled_suites": attr.label_list( allow_files = [".beam"], + cfg = beam_transition, ), "eunit_mods": attr.string_list(), "target": attr.label(providers = [ErlangAppInfo]), @@ -234,6 +239,9 @@ eunit_test = rule( ), "tools": attr.label_list(), "test_env": attr.string_dict(), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], test = True, From d95bc0ca963cc703bea1eaabd224b1150a8d12f9 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 1 May 2023 18:25:55 +0200 Subject: [PATCH 02/13] Use an incoming transition only on erlang_bytecode2 --- erlang_app_info.bzl | 8 ++++---- private/erlang_bytecode2.bzl | 12 +++++++++++- private/escript_archive.bzl | 8 ++++---- private/escript_flat.bzl | 10 +++++----- private/eunit.bzl | 8 ++++---- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/erlang_app_info.bzl b/erlang_app_info.bzl index d035485c..21e540d0 100644 --- a/erlang_app_info.bzl +++ b/erlang_app_info.bzl @@ -66,15 +66,15 @@ erlang_app_info = rule( "app": attr.label(allow_files = [".app"]), "beam": attr.label_list( allow_files = [".beam", ".appup"], - cfg = beam_transition, + # cfg = beam_transition, ), "priv": attr.label_list(allow_files = True), "license_files": attr.label_list(allow_files = True), "srcs": attr.label_list(allow_files = True), "deps": attr.label_list(providers = [ErlangAppInfo]), - "_allowlist_function_transition": attr.label( - default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - ), + # "_allowlist_function_transition": attr.label( + # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + # ), }, provides = [ErlangAppInfo], ) diff --git a/private/erlang_bytecode2.bzl b/private/erlang_bytecode2.bzl index 293e9952..575e5b53 100644 --- a/private/erlang_bytecode2.bzl +++ b/private/erlang_bytecode2.bzl @@ -16,6 +16,15 @@ ErlcOptsInfo = provider( }, ) +def _transition_impl(settings, attr): + return {"//command_line_option:cpu": "beam"} + +transition = transition( + implementation = _transition_impl, + inputs = [], + outputs = ["//command_line_option:cpu"], +) + def _impl(ctx): if len(ctx.attr.outs) == 0: fail("attr outs must not be empty") @@ -123,6 +132,7 @@ fi erlang_bytecode = rule( implementation = _impl, + cfg = transition, attrs = { "app_name": attr.string(), "hdrs": attr.label_list( @@ -134,7 +144,7 @@ erlang_bytecode = rule( ), "beam": attr.label_list( allow_files = [".beam"], - cfg = beam_transition, + # cfg = beam_transition, ), "deps": attr.label_list( providers = [ErlangAppInfo], diff --git a/private/escript_archive.bzl b/private/escript_archive.bzl index 144cf098..7d8474f2 100644 --- a/private/escript_archive.bzl +++ b/private/escript_archive.bzl @@ -143,14 +143,14 @@ escript_archive = rule( "hdrs": attr.label_list(allow_files = [".hrl"]), "beam": attr.label_list( allow_files = [".beam"], - cfg = beam_transition, + # cfg = beam_transition, ), "app": attr.label(providers = [ErlangAppInfo]), "flat": attr.bool(), "drop_hrl": attr.bool(), - "_allowlist_function_transition": attr.label( - default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - ), + # "_allowlist_function_transition": attr.label( + # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + # ), }, toolchains = ["//tools:toolchain_type"], executable = True, diff --git a/private/escript_flat.bzl b/private/escript_flat.bzl index 720c46f1..694a3bd8 100644 --- a/private/escript_flat.bzl +++ b/private/escript_flat.bzl @@ -31,7 +31,7 @@ halt(). body = body, )) - (erlang_home, erlang_release_dir, runfiles) = erlang_dirs(ctx) + (erlang_home, _, runfiles) = erlang_dirs(ctx) inputs = depset( direct = ctx.files.src + ctx.files.beam, @@ -67,12 +67,12 @@ escript_flat = rule( ), "beam": attr.label( allow_single_file = [".beam"], - cfg = beam_transition, + # cfg = beam_transition, ), "out": attr.string(), - "_allowlist_function_transition": attr.label( - default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - ), + # "_allowlist_function_transition": attr.label( + # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + # ), }, toolchains = ["//tools:toolchain_type"], ) diff --git a/private/eunit.bzl b/private/eunit.bzl index ecd08dfc..d38b8d33 100644 --- a/private/eunit.bzl +++ b/private/eunit.bzl @@ -226,7 +226,7 @@ eunit_test = rule( "is_windows": attr.bool(mandatory = True), "compiled_suites": attr.label_list( allow_files = [".beam"], - cfg = beam_transition, + # cfg = beam_transition, ), "eunit_mods": attr.string_list(), "target": attr.label(providers = [ErlangAppInfo]), @@ -239,9 +239,9 @@ eunit_test = rule( ), "tools": attr.label_list(), "test_env": attr.string_dict(), - "_allowlist_function_transition": attr.label( - default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - ), + # "_allowlist_function_transition": attr.label( + # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + # ), }, toolchains = ["//tools:toolchain_type"], test = True, From 8b5384886ec23699b8f49ef1d20ff89cbf669f8b Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 1 May 2023 18:33:48 +0200 Subject: [PATCH 03/13] Fixup redeclaration of 'transition' --- private/beam_transition.bzl | 10 +--------- private/erlang_bytecode2.bzl | 11 +---------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/private/beam_transition.bzl b/private/beam_transition.bzl index e45f0ac9..506967cb 100644 --- a/private/beam_transition.bzl +++ b/private/beam_transition.bzl @@ -1,14 +1,6 @@ def _impl(settings, attr): _ignore = (settings, attr) - - # print("_impl") - # print("settings", settings) - # print("attr", attr) - return { - "arm": {"//command_line_option:cpu": "arm"}, - "x86": {"//command_line_option:cpu": "x86"}, - "k8": {"//command_line_option:cpu": "k8"}, - } + return {"//command_line_option:cpu": "beam"} beam_transition = transition( implementation = _impl, diff --git a/private/erlang_bytecode2.bzl b/private/erlang_bytecode2.bzl index 575e5b53..5035395b 100644 --- a/private/erlang_bytecode2.bzl +++ b/private/erlang_bytecode2.bzl @@ -16,15 +16,6 @@ ErlcOptsInfo = provider( }, ) -def _transition_impl(settings, attr): - return {"//command_line_option:cpu": "beam"} - -transition = transition( - implementation = _transition_impl, - inputs = [], - outputs = ["//command_line_option:cpu"], -) - def _impl(ctx): if len(ctx.attr.outs) == 0: fail("attr outs must not be empty") @@ -132,7 +123,7 @@ fi erlang_bytecode = rule( implementation = _impl, - cfg = transition, + cfg = beam_transition, attrs = { "app_name": attr.string(), "hdrs": attr.label_list( From 69c1e9b85ead3a2e8d8497c0e575df188a652907 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Tue, 2 May 2023 13:54:45 +0200 Subject: [PATCH 04/13] WIP --- private/escript_flat.bzl | 8 ++++---- test/BUILD.bazel | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/private/escript_flat.bzl b/private/escript_flat.bzl index 694a3bd8..adbe1f4b 100644 --- a/private/escript_flat.bzl +++ b/private/escript_flat.bzl @@ -67,12 +67,12 @@ escript_flat = rule( ), "beam": attr.label( allow_single_file = [".beam"], - # cfg = beam_transition, + cfg = beam_transition, ), "out": attr.string(), - # "_allowlist_function_transition": attr.label( - # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - # ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], ) diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 48a435a3..6b3f42cc 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -5,6 +5,7 @@ platform( name = "erlang_internal_platform", constraint_values = [ "@erlang_config//:erlang_internal", + "@erlang_config//:erlang_24", ], parents = ["@rbe//config:platform"], ) From a8ebdc1a74c34a73256ce15dbe1b9c1589d7d97a Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Tue, 16 May 2023 17:50:00 +0200 Subject: [PATCH 05/13] //ccAdd cli flag to disable transitions --- erlang_app_info.bzl | 2 +- private/erlang_bytecode2.bzl | 2 +- private/escript_archive.bzl | 2 +- private/escript_flat.bzl | 2 +- transitions/BUILD.bazel | 7 +++++++ {private => transitions}/beam_transition.bzl | 6 ++++-- 6 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 transitions/BUILD.bazel rename {private => transitions}/beam_transition.bzl (54%) diff --git a/erlang_app_info.bzl b/erlang_app_info.bzl index 21e540d0..8cdc9c27 100644 --- a/erlang_app_info.bzl +++ b/erlang_app_info.bzl @@ -1,4 +1,4 @@ -load("//private:beam_transition.bzl", "beam_transition") +load("//transitions:beam_transition.bzl", "beam_transition") ErlangAppInfo = provider( doc = "Compiled Erlang Application", diff --git a/private/erlang_bytecode2.bzl b/private/erlang_bytecode2.bzl index 5035395b..e4cfb205 100644 --- a/private/erlang_bytecode2.bzl +++ b/private/erlang_bytecode2.bzl @@ -1,8 +1,8 @@ load("//:erlang_app_info.bzl", "ErlangAppInfo", "flat_deps") load("//:util.bzl", "path_join") -load(":beam_transition.bzl", "beam_transition") load(":erlang_bytecode.bzl", "unique_dirnames") load(":util.bzl", "erl_libs_contents") +load("//transitions:beam_transition.bzl", "beam_transition") load( "//tools:erlang_toolchain.bzl", "erlang_dirs", diff --git a/private/escript_archive.bzl b/private/escript_archive.bzl index 7d8474f2..f210a29f 100644 --- a/private/escript_archive.bzl +++ b/private/escript_archive.bzl @@ -13,7 +13,7 @@ load( "path_join", ) load( - ":beam_transition.bzl", + "//transitions:beam_transition.bzl", "beam_transition", ) load( diff --git a/private/escript_flat.bzl b/private/escript_flat.bzl index adbe1f4b..c1ca4cbf 100644 --- a/private/escript_flat.bzl +++ b/private/escript_flat.bzl @@ -4,7 +4,7 @@ load( "maybe_install_erlang", ) load( - ":beam_transition.bzl", + "//transitions:beam_transition.bzl", "beam_transition", ) diff --git a/transitions/BUILD.bazel b/transitions/BUILD.bazel new file mode 100644 index 00000000..129c4c3a --- /dev/null +++ b/transitions/BUILD.bazel @@ -0,0 +1,7 @@ +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") + +bool_flag( + name = "enable", + build_setting_default = True, + visibility = ["//visibility:public"], +) diff --git a/private/beam_transition.bzl b/transitions/beam_transition.bzl similarity index 54% rename from private/beam_transition.bzl rename to transitions/beam_transition.bzl index 506967cb..aca1ed6d 100644 --- a/private/beam_transition.bzl +++ b/transitions/beam_transition.bzl @@ -1,9 +1,11 @@ def _impl(settings, attr): - _ignore = (settings, attr) + _ignore = (attr) + if not settings["@rules_erlang//transitions:enable"]: + return {} return {"//command_line_option:cpu": "beam"} beam_transition = transition( implementation = _impl, - inputs = [], + inputs = ["@rules_erlang//transitions:enable"], outputs = ["//command_line_option:cpu"], ) From e5ff6b49122c5ebdb2f92e2c45b35b7b5658afd6 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Wed, 17 May 2023 10:29:02 +0200 Subject: [PATCH 06/13] Use the beam_transition on all relevant rules --- erlang_app_info.bzl | 8 ++++---- private/erlang_bytecode.bzl | 12 +++++++----- private/erlang_bytecode2.bzl | 2 +- private/escript_archive.bzl | 8 ++++---- private/eunit.bzl | 8 ++++---- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/erlang_app_info.bzl b/erlang_app_info.bzl index 8cdc9c27..3e820d1e 100644 --- a/erlang_app_info.bzl +++ b/erlang_app_info.bzl @@ -66,15 +66,15 @@ erlang_app_info = rule( "app": attr.label(allow_files = [".app"]), "beam": attr.label_list( allow_files = [".beam", ".appup"], - # cfg = beam_transition, + cfg = beam_transition, ), "priv": attr.label_list(allow_files = True), "license_files": attr.label_list(allow_files = True), "srcs": attr.label_list(allow_files = True), "deps": attr.label_list(providers = [ErlangAppInfo]), - # "_allowlist_function_transition": attr.label( - # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - # ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, provides = [ErlangAppInfo], ) diff --git a/private/erlang_bytecode.bzl b/private/erlang_bytecode.bzl index 93615c35..35de899a 100644 --- a/private/erlang_bytecode.bzl +++ b/private/erlang_bytecode.bzl @@ -1,6 +1,7 @@ load("//:erlang_app_info.bzl", "ErlangAppInfo") load("//:util.bzl", "path_join") load(":util.bzl", "erl_libs_contents") +load("//transitions:beam_transition.bzl", "beam_transition") load( "//tools:erlang_toolchain.bzl", "erlang_dirs", @@ -146,14 +147,11 @@ fi erlang_bytecode = rule( implementation = _impl, + cfg = beam_transition, attrs = { "compile_first": attr.label( executable = True, - # I would have thought this should be "exec", since this is run - # in the execution environment. However, it's an ecript needing - # beam, and "target" allows it to match the toolchains for this - # rule. - cfg = "target", + cfg = "exec", ), "app_name": attr.string(), "hdrs": attr.label_list( @@ -165,6 +163,7 @@ erlang_bytecode = rule( ), "beam": attr.label_list( allow_files = [".beam"], + cfg = beam_transition, ), "deps": attr.label_list( providers = [ErlangAppInfo], @@ -176,6 +175,9 @@ erlang_bytecode = rule( "dest": attr.string( default = "ebin", ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], ) diff --git a/private/erlang_bytecode2.bzl b/private/erlang_bytecode2.bzl index e4cfb205..6615cdcb 100644 --- a/private/erlang_bytecode2.bzl +++ b/private/erlang_bytecode2.bzl @@ -135,7 +135,7 @@ erlang_bytecode = rule( ), "beam": attr.label_list( allow_files = [".beam"], - # cfg = beam_transition, + cfg = beam_transition, ), "deps": attr.label_list( providers = [ErlangAppInfo], diff --git a/private/escript_archive.bzl b/private/escript_archive.bzl index f210a29f..a93c2ad8 100644 --- a/private/escript_archive.bzl +++ b/private/escript_archive.bzl @@ -143,14 +143,14 @@ escript_archive = rule( "hdrs": attr.label_list(allow_files = [".hrl"]), "beam": attr.label_list( allow_files = [".beam"], - # cfg = beam_transition, + cfg = beam_transition, ), "app": attr.label(providers = [ErlangAppInfo]), "flat": attr.bool(), "drop_hrl": attr.bool(), - # "_allowlist_function_transition": attr.label( - # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - # ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], executable = True, diff --git a/private/eunit.bzl b/private/eunit.bzl index d38b8d33..ecd08dfc 100644 --- a/private/eunit.bzl +++ b/private/eunit.bzl @@ -226,7 +226,7 @@ eunit_test = rule( "is_windows": attr.bool(mandatory = True), "compiled_suites": attr.label_list( allow_files = [".beam"], - # cfg = beam_transition, + cfg = beam_transition, ), "eunit_mods": attr.string_list(), "target": attr.label(providers = [ErlangAppInfo]), @@ -239,9 +239,9 @@ eunit_test = rule( ), "tools": attr.label_list(), "test_env": attr.string_dict(), - # "_allowlist_function_transition": attr.label( - # default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - # ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], test = True, From c30943dac7c778eb06d093353b16d2ca9a7c7914 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Fri, 19 May 2023 20:12:27 +0200 Subject: [PATCH 07/13] Use `bazel info bazel-testlogs` to find the test logs --- .github/workflows/test.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8e162c41..3e949d40 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -124,9 +124,11 @@ jobs: working-directory: test shell: bash run: | - LOGS_TAR=$PWD/logs.tar - cd bazel-testlogs - tar -cf $LOGS_TAR * + TESTLOGS_DIR="$(bazel info bazel-testlogs)" + if [[ -d $TESTLOGS_DIR ]]; then + cd $TESTLOGS_DIR + tar -cf $LOGS_TAR * + fi - name: CAPTURE TEST LOGS if: always() uses: actions/upload-artifact@v3 @@ -200,9 +202,11 @@ jobs: working-directory: test shell: bash run: | - LOGS_TAR=$PWD/logs.tar - cd bazel-testlogs - tar -cf $LOGS_TAR * + TESTLOGS_DIR="$(bazel info bazel-testlogs)" + if [[ -d $TESTLOGS_DIR ]]; then + cd $TESTLOGS_DIR + tar -cf $LOGS_TAR * + fi - name: CAPTURE TEST LOGS if: always() uses: actions/upload-artifact@v3 From 70942bed8930afbcec348bd32e631ed55ecd2109 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 22 May 2023 09:12:58 +0200 Subject: [PATCH 08/13] oh windows --- .github/workflows/test.yaml | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3e949d40..aeacecdb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -73,7 +73,7 @@ jobs: if: always() working-directory: test run: | - echo "::set-output name=LOGS_PATH::$(readlink -f bazel-testlogs)" + echo "LOGS_PATH=$(readlink -f bazel-testlogs)" | tee $GITHUB_OUTPUT id: resolve-test-logs-path - name: CAPTURE TEST LOGS if: always() @@ -124,17 +124,14 @@ jobs: working-directory: test shell: bash run: | - TESTLOGS_DIR="$(bazel info bazel-testlogs)" - if [[ -d $TESTLOGS_DIR ]]; then - cd $TESTLOGS_DIR - tar -cf $LOGS_TAR * - fi + echo "LOGS_PATH=$(bazel info bazel-testlogs)" | tee $GITHUB_OUTPUT + id: resolve-test-logs-path - name: CAPTURE TEST LOGS if: always() uses: actions/upload-artifact@v3 with: - name: bazel-testlogs-windows-${{matrix.otp}} - path: test/logs.tar + name: bazel-testlogs-bzlmod-windows-${{matrix.otp}} + path: ${{ steps.resolve-test-logs-path.outputs.LOGS_PATH }}/* test-bzlmod: runs-on: ubuntu-20.04 strategy: @@ -158,7 +155,7 @@ jobs: if: always() working-directory: test run: | - echo "::set-output name=LOGS_PATH::$(readlink -f bazel-testlogs)" + echo "LOGS_PATH=$(readlink -f bazel-testlogs)" | tee $GITHUB_OUTPUT id: resolve-test-logs-path - name: CAPTURE TEST LOGS if: always() @@ -202,17 +199,14 @@ jobs: working-directory: test shell: bash run: | - TESTLOGS_DIR="$(bazel info bazel-testlogs)" - if [[ -d $TESTLOGS_DIR ]]; then - cd $TESTLOGS_DIR - tar -cf $LOGS_TAR * - fi + echo "LOGS_PATH=$(bazel info bazel-testlogs)" | tee $GITHUB_OUTPUT + id: resolve-test-logs-path - name: CAPTURE TEST LOGS if: always() uses: actions/upload-artifact@v3 with: name: bazel-testlogs-bzlmod-windows-${{matrix.otp}} - path: test/logs.tar + path: ${{ steps.resolve-test-logs-path.outputs.LOGS_PATH }}/* test-bzlmod-internal-erlang: runs-on: ubuntu-20.04 steps: @@ -244,7 +238,7 @@ jobs: if: always() working-directory: test run: | - echo "::set-output name=LOGS_PATH::$(readlink -f bazel-testlogs)" + echo "LOGS_PATH=$(readlink -f bazel-testlogs)" | tee $GITHUB_OUTPUT id: resolve-test-logs-path - name: CAPTURE TEST LOGS if: always() @@ -346,7 +340,7 @@ jobs: if: always() working-directory: test run: | - echo "::set-output name=LOGS_PATH::$(readlink -f bazel-testlogs)" + echo "LOGS_PATH=$(readlink -f bazel-testlogs)" | tee $GITHUB_OUTPUT id: resolve-test-logs-path - name: CAPTURE TEST LOGS if: always() From 36e1df539c0fdbcd9aad9b366b1c2f36d495f597 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Tue, 23 May 2023 10:10:40 +0200 Subject: [PATCH 09/13] bazel 6 workaround to keep test logs --- test/.bazelrc | 3 +++ test/BUILD.bazel | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/.bazelrc b/test/.bazelrc index 1214f439..fa25f56f 100644 --- a/test/.bazelrc +++ b/test/.bazelrc @@ -1,6 +1,9 @@ build --enable_bzlmod build --incompatible_strict_action_env +# https://github.com/bazelbuild/bazel/issues/17081 +build --use_top_level_targets_for_symlinks=false + build --flag_alias=erlang_home=@rules_erlang//:erlang_home build --flag_alias=erlang_version=@rules_erlang//:erlang_version diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 6b3f42cc..ab1f9767 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -5,7 +5,7 @@ platform( name = "erlang_internal_platform", constraint_values = [ "@erlang_config//:erlang_internal", - "@erlang_config//:erlang_24", + "@erlang_config//:erlang_26", ], parents = ["@rbe//config:platform"], ) From ae1735915f222f7217c4acd3b52a9b572e44c789 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 19 Jun 2023 08:56:24 +0200 Subject: [PATCH 10/13] Apply transition where .beam files are used --- private/ct.bzl | 5 +++++ private/dialyze.bzl | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/private/ct.bzl b/private/ct.bzl index dbfa749b..ef92e22c 100644 --- a/private/ct.bzl +++ b/private/ct.bzl @@ -27,6 +27,7 @@ load( "erlang_dirs", "maybe_install_erlang", ) +load("//transitions:beam_transition.bzl", "beam_transition") def sanitize_sname(s): return s.replace("@", "-").replace(".", "_") @@ -336,6 +337,7 @@ ct_test = rule( "compiled_suites": attr.label_list( allow_files = [".beam"], mandatory = True, + cfg = beam_transition, ), "ct_hooks": attr.string_list(), "ct_run_extra_args": attr.string_list(), @@ -350,6 +352,9 @@ ct_test = rule( default = "group", values = ["group", "case"], ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], test = True, diff --git a/private/dialyze.bzl b/private/dialyze.bzl index b6df475b..1696d9e0 100644 --- a/private/dialyze.bzl +++ b/private/dialyze.bzl @@ -7,6 +7,7 @@ load("//:erlang_app_info.bzl", "ErlangAppInfo") load("//:util.bzl", "path_join", "windows_path") load(":util.bzl", "erl_libs_contents") load(":ct.bzl", "code_paths", "unique_short_dirnames") +load("//transitions:beam_transition.bzl", "beam_transition") def _impl(ctx): if ctx.attr.target == None and len(ctx.attr.beam) == 0: @@ -114,6 +115,7 @@ dialyze_test = rule( ), "beam": attr.label_list( allow_files = [".beam"], + cfg = beam_transition, ), "target": attr.label( providers = [ErlangAppInfo], @@ -129,6 +131,9 @@ dialyze_test = rule( ], ), "warnings_as_errors": attr.bool(default = True), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), }, toolchains = ["//tools:toolchain_type"], test = True, From 27ea5d81508a473de4322108430a46525635194b Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 30 Oct 2023 12:24:38 +0100 Subject: [PATCH 11/13] remove unused import --- private/eunit.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/private/eunit.bzl b/private/eunit.bzl index ecd08dfc..2b8aa14b 100644 --- a/private/eunit.bzl +++ b/private/eunit.bzl @@ -1,7 +1,6 @@ load( "//:erlang_app_info.bzl", "ErlangAppInfo", - "flat_deps", ) load( "//:util.bzl", From 930713a3a34329a382c977e1dcc69bfd4a679d4f Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 30 Oct 2023 12:26:51 +0100 Subject: [PATCH 12/13] fix broken load statement --- private/eunit.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private/eunit.bzl b/private/eunit.bzl index 2b8aa14b..17daf6e4 100644 --- a/private/eunit.bzl +++ b/private/eunit.bzl @@ -8,7 +8,7 @@ load( "windows_path", ) load( - ":beam_transition.bzl", + "//transitions:beam_transition.bzl", "beam_transition", ) load( From f8cb08aec362f8e117049cee26d6a74d6c516e6a Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Mon, 30 Oct 2023 12:27:15 +0100 Subject: [PATCH 13/13] buildifier --- MODULE.bazel | 2 +- gazelle/erl_attrs_to_json/BUILD.bazel | 1 + test/erl_attrs_to_json/BUILD.bazel | 2 +- test/gazelle/BUILD.bazel | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 96f2ace9..2fadd38a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -41,8 +41,8 @@ erlang_package.hex_package( use_repo( erlang_package, "getopt_src", - "xref_runner_src", "thoas", + "xref_runner_src", ) erlang_config_extension = use_extension( diff --git a/gazelle/erl_attrs_to_json/BUILD.bazel b/gazelle/erl_attrs_to_json/BUILD.bazel index 3cb59b94..3b72adb1 100644 --- a/gazelle/erl_attrs_to_json/BUILD.bazel +++ b/gazelle/erl_attrs_to_json/BUILD.bazel @@ -2,6 +2,7 @@ load("@rules_erlang//:erlang_app.bzl", "erlang_app", "test_erlang_app") load("//:escript.bzl", "escript_archive") APP_NAME = "erl_attrs_to_json" + APP_VERSION = "1.0.0" DEPS = ["@thoas//:erlang_app"] diff --git a/test/erl_attrs_to_json/BUILD.bazel b/test/erl_attrs_to_json/BUILD.bazel index 3f7b19ed..02456c97 100644 --- a/test/erl_attrs_to_json/BUILD.bazel +++ b/test/erl_attrs_to_json/BUILD.bazel @@ -40,8 +40,8 @@ ct_suite( name = "erl_attrs_to_json_SUITE", size = "small", data = [ - "test/basic.hrl", "test/basic.erl", + "test/basic.hrl", "test/test.erl", ], deps = [ diff --git a/test/gazelle/BUILD.bazel b/test/gazelle/BUILD.bazel index afdf5e54..6bf9ec66 100644 --- a/test/gazelle/BUILD.bazel +++ b/test/gazelle/BUILD.bazel @@ -14,9 +14,9 @@ go_test( data = [ ":gazelle_erlang_binary", "@rules_erlang//gazelle:dot_app_to_json", - "@rules_erlang//gazelle/erl_attrs_to_json:erl_attrs_to_json", "@rules_erlang//gazelle:hex_metadata_config_to_json", "@rules_erlang//gazelle:rebar_config_to_json", + "@rules_erlang//gazelle/erl_attrs_to_json", ] + glob(["testdata/**"]), tags = ["manual"], deps = [ @@ -103,6 +103,6 @@ EOF """, executable = True, tools = [ - "@rules_erlang//gazelle/erl_attrs_to_json:erl_attrs_to_json", + "@rules_erlang//gazelle/erl_attrs_to_json", ], )