diff --git a/lint/buf.bzl b/lint/buf.bzl index 012f8ca7..0a373c62 100644 --- a/lint/buf.bzl +++ b/lint/buf.bzl @@ -14,6 +14,8 @@ buf = buf_lint_aspect( load("@rules_proto//proto:defs.bzl", "ProtoInfo") load("//lint/private:lint_aspect.bzl", "report_file") +_MNEMONIC = "buf" + def _short_path(file, _): return file.path @@ -70,13 +72,14 @@ def buf_lint_action(ctx, buf_toolchain, target, report, use_exit_code = False): exit_zero = "" if use_exit_code else "|| true", ), arguments = [args], + mnemonic = _MNEMONIC, ) def _buf_lint_aspect_impl(target, ctx): if ctx.rule.kind not in ["proto_library"]: return [] - report, info = report_file(target, ctx) + report, info = report_file(_MNEMONIC, target, ctx) buf_lint_action(ctx, ctx.toolchains[ctx.attr._buf_toolchain], target, report, ctx.attr.fail_on_violation) return [info] diff --git a/lint/eslint.bzl b/lint/eslint.bzl index 820e0766..1ccf4b81 100644 --- a/lint/eslint.bzl +++ b/lint/eslint.bzl @@ -16,6 +16,8 @@ load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_files_to_bin_actions") load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers") load("//lint/private:lint_aspect.bzl", "report_file") +_MNEMONIC = "ESLint" + def eslint_action(ctx, executable, srcs, report, use_exit_code = False): """Create a Bazel Action that spawns an eslint process. @@ -72,7 +74,7 @@ def eslint_action(ctx, executable, srcs, report, use_exit_code = False): executable = executable._eslint, arguments = [args], env = env, - mnemonic = "ESLint", + mnemonic = _MNEMONIC, ) # buildifier: disable=function-docstring @@ -80,7 +82,7 @@ def _eslint_aspect_impl(target, ctx): if ctx.rule.kind not in ["ts_project", "ts_project_rule"]: return [] - report, info = report_file(target, ctx) + report, info = report_file(_MNEMONIC, target, ctx) eslint_action(ctx, ctx.executable, ctx.rule.files.srcs, report, ctx.attr.fail_on_violation) return [info] diff --git a/lint/flake8.bzl b/lint/flake8.bzl index 997b2c3e..1423ca6e 100644 --- a/lint/flake8.bzl +++ b/lint/flake8.bzl @@ -14,6 +14,8 @@ flake8 = flake8_aspect( load("//lint/private:lint_aspect.bzl", "report_file") +_MNEMONIC = "flake8" + def flake8_action(ctx, executable, srcs, config, report, use_exit_code = False): """Run flake8 as an action under Bazel. @@ -44,7 +46,7 @@ def flake8_action(ctx, executable, srcs, config, report, use_exit_code = False): outputs = outputs, executable = executable, arguments = [args], - mnemonic = "flake8", + mnemonic = _MNEMONIC, ) # buildifier: disable=function-docstring @@ -52,7 +54,7 @@ def _flake8_aspect_impl(target, ctx): if ctx.rule.kind not in ["py_library"]: return [] - report, info = report_file(target, ctx) + report, info = report_file(_MNEMONIC, target, ctx) flake8_action(ctx, ctx.executable._flake8, ctx.rule.files.srcs, ctx.file._config_file, report, ctx.attr.fail_on_violation) return [info] diff --git a/lint/pmd.bzl b/lint/pmd.bzl index 1ee9b79f..674d2a27 100644 --- a/lint/pmd.bzl +++ b/lint/pmd.bzl @@ -14,6 +14,8 @@ pmd = pmd_aspect( load("//lint/private:lint_aspect.bzl", "report_file") +_MNEMONIC = "PMD" + def pmd_action(ctx, executable, srcs, rulesets, report, use_exit_code = False): """Run PMD as an action under Bazel. @@ -48,7 +50,7 @@ def pmd_action(ctx, executable, srcs, rulesets, report, use_exit_code = False): outputs = [report], executable = executable, arguments = [args, "--file-list", src_args], - mnemonic = "PMD", + mnemonic = _MNEMONIC, ) # buildifier: disable=function-docstring @@ -56,7 +58,7 @@ def _pmd_aspect_impl(target, ctx): if ctx.rule.kind not in ["java_library"]: return [] - report, info = report_file(target, ctx) + report, info = report_file(_MNEMONIC, target, ctx) pmd_action(ctx, ctx.executable._pmd, ctx.rule.files.srcs, ctx.files._rulesets, report, ctx.attr.fail_on_violation) return [info] diff --git a/lint/private/lint_aspect.bzl b/lint/private/lint_aspect.bzl index eee4d080..0dc9b345 100644 --- a/lint/private/lint_aspect.bzl +++ b/lint/private/lint_aspect.bzl @@ -1,6 +1,6 @@ "Helpers to reduce boilerplate for writing linter aspects" -def report_file(target, ctx): - report = ctx.actions.declare_file(target.label.name + ".aspect_rules_lint.report") +def report_file(mnemonic, target, ctx): + report = ctx.actions.declare_file("{}.{}.aspect_rules_lint.report".format(mnemonic, target.label.name)) info = OutputGroupInfo(rules_lint_report = depset([report])) return report, info diff --git a/lint/ruff.bzl b/lint/ruff.bzl index 92da19ce..afc2590f 100644 --- a/lint/ruff.bzl +++ b/lint/ruff.bzl @@ -16,6 +16,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//lint/private:lint_aspect.bzl", "report_file") +_MNEMONIC = "ruff" + def ruff_action(ctx, executable, srcs, config, report, use_exit_code = False): """Run ruff as an action under Bazel. @@ -46,7 +48,7 @@ def ruff_action(ctx, executable, srcs, config, report, use_exit_code = False): outputs = outputs, executable = executable, arguments = [args], - mnemonic = "ruff", + mnemonic = _MNEMONIC, ) # buildifier: disable=function-docstring @@ -54,7 +56,7 @@ def _ruff_aspect_impl(target, ctx): if ctx.rule.kind not in ["py_library"]: return [] - report, info = report_file(target, ctx) + report, info = report_file(_MNEMONIC, target, ctx) ruff_action(ctx, ctx.executable._ruff, ctx.rule.files.srcs, ctx.file._config_file, report, ctx.attr.fail_on_violation) return [info] @@ -99,41 +101,41 @@ def ruff_aspect(binary, config): # Generated by running ./mirror_ruff.sh RUFF_VERSIONS = { "v0.1.2": { - "aarch64-apple-darwin": "99a245e703c1d95afc9b0c2e00bd47bca6ac5c17e6cc046e58bf3f70d6536330", - "aarch64-pc-windows-msvc": "644390067887b8b0f1bff2805211de6bd006c97ce259760260b27da5356a7db6", - "aarch64-unknown-linux-gnu": "fef09ce9591c72efd1ef4ce2b0956f1edba21328e29ad865e795d16186a20a06", - "aarch64-unknown-linux-musl": "a96338c7e96228531a0c2cef39ebe17a215fca3346e2352a00b9f88bc25d5197", - "armv7-unknown-linux-gnueabihf": "a15894de509ae15eeb48d0121e08536b1b8f16855d88cccb61ecab0c9f4e537d", - "armv7-unknown-linux-musleabihf": "1c6bf703c489d60ae1db402508d1527292411d9c4fac5d43cf79f08e444e6167", - "i686-pc-windows-msvc": "aca5b93beac3a76edd7c2ea55f0e09672d2d7f85fcf5c9f4f65c252db643b5b4", - "i686-unknown-linux-gnu": "fa42d9559589cee38f8ac34c48ce3f9981d204fa2be48fa72945e9c1f026db8c", - "i686-unknown-linux-musl": "f84d9770205f3b0387ba74dbc62a47f2b234f52fc58ec0e9b8ceb0697035a6cf", - "powerpc64-unknown-linux-gnu": "b8731842d1d762538a8d41e49853cac4b06b827b0f762bd08e951eb47ec2129c", - "powerpc64le-unknown-linux-gnu": "36015e708b571465e12ecb655e8165e51ee1d7295800484b94ab21e04c2b17b1", - "s390x-unknown-linux-gnu": "592fc30494bf63ddb510ac929233a6fa44488273099e064fcf91efc10a3c49ab", - "x86_64-apple-darwin": "cb339e9684043dae3cf530bca22f532198b9f151b01812f701ed0b85fec95b0a", - "x86_64-pc-windows-msvc": "5e515c69653469736e76848f401d9f72b4396d8b7be2be77f748109e04542d26", - "x86_64-unknown-linux-gnu": "cab189b03ed0d882d45691d6cb4a7843e9d8389ba4e2e43cb4616a46ae69545b", - "x86_64-unknown-linux-musl": "368594d2e96a8a7e14fc610259f1c0a29fab4a84cd061a9373ce415c742df04e" + "aarch64-apple-darwin": "99a245e703c1d95afc9b0c2e00bd47bca6ac5c17e6cc046e58bf3f70d6536330", + "aarch64-pc-windows-msvc": "644390067887b8b0f1bff2805211de6bd006c97ce259760260b27da5356a7db6", + "aarch64-unknown-linux-gnu": "fef09ce9591c72efd1ef4ce2b0956f1edba21328e29ad865e795d16186a20a06", + "aarch64-unknown-linux-musl": "a96338c7e96228531a0c2cef39ebe17a215fca3346e2352a00b9f88bc25d5197", + "armv7-unknown-linux-gnueabihf": "a15894de509ae15eeb48d0121e08536b1b8f16855d88cccb61ecab0c9f4e537d", + "armv7-unknown-linux-musleabihf": "1c6bf703c489d60ae1db402508d1527292411d9c4fac5d43cf79f08e444e6167", + "i686-pc-windows-msvc": "aca5b93beac3a76edd7c2ea55f0e09672d2d7f85fcf5c9f4f65c252db643b5b4", + "i686-unknown-linux-gnu": "fa42d9559589cee38f8ac34c48ce3f9981d204fa2be48fa72945e9c1f026db8c", + "i686-unknown-linux-musl": "f84d9770205f3b0387ba74dbc62a47f2b234f52fc58ec0e9b8ceb0697035a6cf", + "powerpc64-unknown-linux-gnu": "b8731842d1d762538a8d41e49853cac4b06b827b0f762bd08e951eb47ec2129c", + "powerpc64le-unknown-linux-gnu": "36015e708b571465e12ecb655e8165e51ee1d7295800484b94ab21e04c2b17b1", + "s390x-unknown-linux-gnu": "592fc30494bf63ddb510ac929233a6fa44488273099e064fcf91efc10a3c49ab", + "x86_64-apple-darwin": "cb339e9684043dae3cf530bca22f532198b9f151b01812f701ed0b85fec95b0a", + "x86_64-pc-windows-msvc": "5e515c69653469736e76848f401d9f72b4396d8b7be2be77f748109e04542d26", + "x86_64-unknown-linux-gnu": "cab189b03ed0d882d45691d6cb4a7843e9d8389ba4e2e43cb4616a46ae69545b", + "x86_64-unknown-linux-musl": "368594d2e96a8a7e14fc610259f1c0a29fab4a84cd061a9373ce415c742df04e", }, "v0.1.1": { - "aarch64-apple-darwin": "e2444e4c7bda7133a0c47a368993be55f7bbe3c3a68d14be83dca480fe624c5e", - "aarch64-pc-windows-msvc": "8eb1f83b0e3c9ddd818176fc26065b87b7cb119764c84b109c70d12dff283d21", - "aarch64-unknown-linux-gnu": "2d56dd602aa62e5e8185971e19c77d6df1e9f14a9190176d8f8212dcde827dde", - "aarch64-unknown-linux-musl": "ee1117ea3e4c32c92f598592c946bb941cca437cc0ce62bd4e86ea889a081e29", - "armv7-unknown-linux-gnueabihf": "f0f0b4db10954496149ddb7b6a9d7c16418f386210f3da2823904bde713ba369", - "armv7-unknown-linux-musleabihf": "894e6f0c5f8a8830fcddf38afa81960fb902211082ef7a1aec00637a2c6e2710", - "i686-pc-windows-msvc": "a6d5601c9704790409a3540d6dc6cc2a955b234f07df9553e5b4555f9b8ac7e5", - "i686-unknown-linux-gnu": "9617cd3a921f9d65be973482fae5b888e9e1a9617e779d7d47f3d5f2cdb5c332", - "i686-unknown-linux-musl": "55d574637179362a2ddf10125d0386054a0cfb3daef0943e9082a87a1a3424e6", - "powerpc64-unknown-linux-gnu": "143b227ace509cb0a2e2411a5675935d67910f7a280f35931e112e137dc3b894", - "powerpc64le-unknown-linux-gnu": "94158cc4d4208b29962a6be2245fa391ce158673c4e8c8baa5e9f592c080dc29", - "s390x-unknown-linux-gnu": "22dcfb5338e546713b86acc1c25d0c11bb72175df652bbd0ad58082c4e273b8b", - "x86_64-apple-darwin": "da0e3156387a419db6c123fd7d009d7f6153dfb631a17e7aa1551f4d6aec5c7a", - "x86_64-pc-windows-msvc": "080877770e3494637a01cca05e88ed9a5a450f6129b90053e7f3014ce761f178", - "x86_64-unknown-linux-gnu": "0f70840c8c10ac8013f734e76977494311b7264a12782bc95be5f9d2e1414176", - "x86_64-unknown-linux-musl": "2b5555abb21598969be862a05101f35079ff6c72466d74eb22f9a1c773d646d0" - } + "aarch64-apple-darwin": "e2444e4c7bda7133a0c47a368993be55f7bbe3c3a68d14be83dca480fe624c5e", + "aarch64-pc-windows-msvc": "8eb1f83b0e3c9ddd818176fc26065b87b7cb119764c84b109c70d12dff283d21", + "aarch64-unknown-linux-gnu": "2d56dd602aa62e5e8185971e19c77d6df1e9f14a9190176d8f8212dcde827dde", + "aarch64-unknown-linux-musl": "ee1117ea3e4c32c92f598592c946bb941cca437cc0ce62bd4e86ea889a081e29", + "armv7-unknown-linux-gnueabihf": "f0f0b4db10954496149ddb7b6a9d7c16418f386210f3da2823904bde713ba369", + "armv7-unknown-linux-musleabihf": "894e6f0c5f8a8830fcddf38afa81960fb902211082ef7a1aec00637a2c6e2710", + "i686-pc-windows-msvc": "a6d5601c9704790409a3540d6dc6cc2a955b234f07df9553e5b4555f9b8ac7e5", + "i686-unknown-linux-gnu": "9617cd3a921f9d65be973482fae5b888e9e1a9617e779d7d47f3d5f2cdb5c332", + "i686-unknown-linux-musl": "55d574637179362a2ddf10125d0386054a0cfb3daef0943e9082a87a1a3424e6", + "powerpc64-unknown-linux-gnu": "143b227ace509cb0a2e2411a5675935d67910f7a280f35931e112e137dc3b894", + "powerpc64le-unknown-linux-gnu": "94158cc4d4208b29962a6be2245fa391ce158673c4e8c8baa5e9f592c080dc29", + "s390x-unknown-linux-gnu": "22dcfb5338e546713b86acc1c25d0c11bb72175df652bbd0ad58082c4e273b8b", + "x86_64-apple-darwin": "da0e3156387a419db6c123fd7d009d7f6153dfb631a17e7aa1551f4d6aec5c7a", + "x86_64-pc-windows-msvc": "080877770e3494637a01cca05e88ed9a5a450f6129b90053e7f3014ce761f178", + "x86_64-unknown-linux-gnu": "0f70840c8c10ac8013f734e76977494311b7264a12782bc95be5f9d2e1414176", + "x86_64-unknown-linux-musl": "2b5555abb21598969be862a05101f35079ff6c72466d74eb22f9a1c773d646d0", + }, } def fetch_ruff(version = RUFF_VERSIONS.keys()[0]): diff --git a/lint/shellcheck.bzl b/lint/shellcheck.bzl index 2cf2150f..ae7c3d43 100644 --- a/lint/shellcheck.bzl +++ b/lint/shellcheck.bzl @@ -21,6 +21,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//lint/private:lint_aspect.bzl", "report_file") +_MNEMONIC = "shellcheck" + def shellcheck_binary(name): """Wrapper around native_binary to select the correct shellcheck executable for the execution platform.""" native_binary( @@ -69,7 +71,7 @@ def shellcheck_action(ctx, executable, srcs, config, report, use_exit_code = Fal exit_zero = "" if use_exit_code else "|| true", ), arguments = [args], - mnemonic = "shellcheck", + mnemonic = _MNEMONIC, ) # buildifier: disable=function-docstring @@ -77,7 +79,7 @@ def _shellcheck_aspect_impl(target, ctx): if ctx.rule.kind not in ["sh_library"]: return [] - report, info = report_file(target, ctx) + report, info = report_file(_MNEMONIC, target, ctx) shellcheck_action(ctx, ctx.executable._shellcheck, ctx.rule.files.srcs, ctx.file._config_file, report, ctx.attr.fail_on_violation) return [info]