Skip to content

Commit

Permalink
chore: update rules_multirun
Browse files Browse the repository at this point in the history
Use the new features Keith added!
  • Loading branch information
alexeagle committed Feb 23, 2024
1 parent 136f9e1 commit 06e1117
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
9 changes: 1 addition & 8 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ bazel_dep(name = "aspect_bazel_lib", version = "1.38.0")
bazel_dep(name = "aspect_rules_js", version = "1.33.1")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "rules_multirun", version = "0.6.1")

# Needed in the root module to get bzl_library targets. Remove after next release.
git_override(
module_name = "rules_multirun",
commit = "9cca5f28c4a10107c91f9fbd5aba48d48122a054",
remote = "https://github.com/keith/rules_multirun.git",
)
bazel_dep(name = "rules_multirun", version = "0.7.0")

# Needed in the root because we dereference ProtoInfo in our aspect impl
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
Expand Down
6 changes: 3 additions & 3 deletions example/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ pinned_maven_install()

http_archive(
name = "rules_multirun",
sha256 = "9cd384e42b2da00104f0e18f25e66285aa21f64b573c667638a7a213206885ab",
strip_prefix = "rules_multirun-0.6.1",
url = "https://github.com/keith/rules_multirun/archive/refs/tags/0.6.1.tar.gz",
sha256 = "7b699b3922919d727e7f5aa868286e59cc69fa6aa14f6c3e54a4674010bd1582",
strip_prefix = "rules_multirun-0.7.0",
url = "https://github.com/keith/rules_multirun/releases/download/0.7.0/rules_multirun-0.7.0.tar.gz",
)

# Use whichever formatter binaries you need:
Expand Down
12 changes: 4 additions & 8 deletions format/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,13 @@ def format_multirun(name, **kwargs):
if lang_attribute not in kwargs.keys():
continue

# Target name should be human-readable since multirun 'print_targets' will echo it, e.g.
# Running @@//tools/format:format_Protocol_Buffer_with_buf
# Ideally multirun could print a message like "Formatting Protocol Buffer with Buf", see
# https://github.com/keith/rules_multirun/issues/31
target_name = "_".join([name, lang.replace(" ", "_"), "with", toolname])
target_name = "_".join([name, lang.replace(" ", "_")])

for mode in ["check", "fix"]:
command(
name = target_name + (".check" if mode == "check" else ""),
command = "@aspect_rules_lint//format/private:format",
description = "Formatting {} with {}".format(lang, toolname),
environment = {
# NB: can't use str(Label(target_name)) here because bzlmod makes it
# the apparent repository, starts with @@aspect_rules_lint~override
Expand All @@ -101,9 +98,8 @@ def format_multirun(name, **kwargs):
multirun(
name = name,
commands = commands,
# Run sequentially for now, see
# https://github.com/keith/rules_multirun/issues/32
jobs = 1,
# Run up to 4 formatters at the same time. This is an arbitrary choice, based on some idea that 4-core machines are typical.
jobs = 4,
)

multirun(
Expand Down

0 comments on commit 06e1117

Please sign in to comment.