diff --git a/.bazelrc b/.bazelrc index 09511ac7..b53a6f45 100644 --- a/.bazelrc +++ b/.bazelrc @@ -7,6 +7,9 @@ # https://bazelbuild.slack.com/archives/C014RARENH0/p1691158021917459?thread_ts=1691156601.420349&cid=C014RARENH0 common --check_direct_dependencies=off +# TODO: enable this flag after stardoc allows it +common --noincompatible_disallow_empty_glob + # Load any settings specific to the current user. # .bazelrc.user should appear in .gitignore so that settings are not shared with team members # This needs to be last statement in this diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 760396b8..c265578d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,18 +18,13 @@ concurrency: jobs: bazel-test: - uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6 + uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v7 with: folders: '[".", "example"]' # Don't try for Windows support yet. exclude_windows: true - # Root module is bzlmod-only and uses newer stardoc that requires Bazel 7. - # Example uses incompatible_enable_proto_toolchain_resolution exclude: | - [ - {"bzlmodEnabled": false, "folder": "."}, - {"bazelversion": "6.4.0"} - ] + [{"bzlmodEnabled": false, "folder": "."}] integration-test: runs-on: ubuntu-latest diff --git a/MODULE.bazel b/MODULE.bazel index ed6f3f66..fcbf81ea 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,6 +12,7 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.7.7") # Minimum version needs 'chore: bump bazel-lib to 2.0 by @alexeagle in #1311' # to allow users on bazel-lib 2.0 bazel_dep(name = "aspect_rules_js", version = "1.40.0") +bazel_dep(name = "bazel_features", version = "1.19.0") bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "platforms", version = "0.0.7") bazel_dep(name = "rules_multirun", version = "0.9.0") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel deleted file mode 100644 index 9f0c4f08..00000000 --- a/WORKSPACE.bazel +++ /dev/null @@ -1 +0,0 @@ -# Marker that this folder is the root of a Bazel workspace diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 0f7cc148..29bc7ebe 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -1,6 +1,7 @@ # This load statement must be in the docs/ package rather than anything users depend on # so that the dependency on stardoc doesn't leak to them. load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs") +load("@bazel_features//:features.bzl", "bazel_features") stardoc_with_diff_test( name = "lint_test", @@ -35,6 +36,7 @@ stardoc_with_diff_test( stardoc_with_diff_test( name = "format", bzl_library_target = "//format:defs", + target_compatible_with = ["@platforms//:incompatible"] if bazel_features.docs.kwargs_name_with_double_star else [], ) stardoc_with_diff_test( diff --git a/docs/vale.md b/docs/vale.md index 5b7b605f..76ebf10d 100644 --- a/docs/vale.md +++ b/docs/vale.md @@ -135,3 +135,13 @@ Run Vale as an action under Bazel. | env | environment variables for vale | `{}` | + + +## vale_dependencies + +
+vale_dependencies = use_extension("@aspect_rules_lint//lint:vale.bzl", "vale_dependencies")
+
+
+
+
diff --git a/example/MODULE.bazel b/example/MODULE.bazel
index d88b2ee7..525a51e9 100644
--- a/example/MODULE.bazel
+++ b/example/MODULE.bazel
@@ -9,6 +9,7 @@ bazel_dep(name = "rules_buf", version = "0.3.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "toolchains_llvm", version = "0.10.3")
bazel_dep(name = "toolchains_protoc", version = "0.3.0")
+bazel_dep(name = "protobuf", version = "29.0-rc2")
bazel_dep(name = "rules_java", version = "5.5.0")
bazel_dep(name = "rules_jvm_external", version = "4.5")
bazel_dep(name = "rules_go", version = "0.42.0", repo_name = "io_bazel_rules_go")
@@ -25,6 +26,18 @@ local_path_override(
path = "..",
)
+vale_dependencies = use_extension("@aspect_rules_lint//lint:vale.bzl", "vale_dependencies")
+use_repo(
+ vale_dependencies,
+ "vale_Google",
+ "vale_Linux_64-bit",
+ "vale_Linux_arm64",
+ "vale_Windows_64-bit",
+ "vale_macOS_64-bit",
+ "vale_macOS_arm64",
+ "vale_write-good",
+)
+
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext")
rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")
@@ -99,6 +112,24 @@ use_repo(
"unpinned_maven",
)
+jvm_format_dependencies = use_extension("@aspect_rules_lint//format:repositories.bzl", "jvm_dependencies")
+
+jvm_lint_dependencies = use_extension("@aspect_rules_lint//lint:extensions.bzl", "jvm_dependencies")
+
+# Only need to list the repositories actually being referenced
+use_repo(
+ jvm_format_dependencies,
+ "google-java-format",
+ "ktfmt",
+)
+
+use_repo(
+ jvm_lint_dependencies,
+ "com_github_pinterest_ktlint",
+ "com_puppycrawl_tools_checkstyle",
+ "net_sourceforge_pmd",
+)
+
buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")
# see https://github.com/bufbuild/buf/releases
@@ -110,3 +141,6 @@ rust.toolchain(
edition = "2021",
versions = ["1.75.0"],
)
+
+swift_dependencies = use_extension("@aspect_rules_lint//format:repositories.bzl", "swift_dependencies")
+use_repo(swift_dependencies, "swiftformat", "swiftformat_mac")
diff --git a/example/WORKSPACE.bzlmod b/example/WORKSPACE.bzlmod
index 840a1e98..a04cd3f8 100644
--- a/example/WORKSPACE.bzlmod
+++ b/example/WORKSPACE.bzlmod
@@ -5,29 +5,7 @@
# Needed until Bazel 7 allows MODULE.bazel to directly call repository rules
load(
"@aspect_rules_lint//format:repositories.bzl",
- "fetch_java_format",
- "fetch_ktfmt",
"fetch_swiftformat",
)
-fetch_java_format()
-
-fetch_ktfmt()
-
fetch_swiftformat()
-
-load("@aspect_rules_lint//lint:pmd.bzl", "fetch_pmd")
-
-fetch_pmd()
-
-load("@aspect_rules_lint//lint:checkstyle.bzl", "fetch_checkstyle")
-
-fetch_checkstyle()
-
-load("@aspect_rules_lint//lint:vale.bzl", "fetch_vale")
-
-fetch_vale()
-
-load("@aspect_rules_lint//lint:ktlint.bzl", "fetch_ktlint")
-
-fetch_ktlint()
diff --git a/format/extensions.bzl b/format/extensions.bzl
new file mode 100644
index 00000000..734acd69
--- /dev/null
+++ b/format/extensions.bzl
@@ -0,0 +1 @@
+"Adapt repository rule macros to bzlmod"
diff --git a/format/repositories.bzl b/format/repositories.bzl
index c9b3b35d..d441714e 100644
--- a/format/repositories.bzl
+++ b/format/repositories.bzl
@@ -52,6 +52,14 @@ def fetch_ktfmt():
url = "https://repo1.maven.org/maven2/com/facebook/ktfmt/0.46/ktfmt-0.46-jar-with-dependencies.jar",
)
+def _jvm_dependencies_impl(_ctx):
+ fetch_ktfmt()
+ fetch_java_format()
+
+jvm_dependencies = module_extension(
+ implementation = _jvm_dependencies_impl,
+)
+
def fetch_swiftformat():
# TODO: after https://github.com/bazelbuild/rules_swift/issues/864 we should only fetch for host
http_archive(
@@ -73,3 +81,10 @@ def fetch_swiftformat():
sha256 = "978eaffdc3716bbc0859aecee0d83875cf3ab8d8725779448f0035309d9ad9f3",
url = "https://github.com/nicklockwood/SwiftFormat/releases/download/0.49.17/swiftformat.zip",
)
+
+def _swift_dependencies_impl(_ctx):
+ fetch_swiftformat()
+
+swift_dependencies = module_extension(
+ implementation = _swift_dependencies_impl,
+)
diff --git a/lint/extensions.bzl b/lint/extensions.bzl
new file mode 100644
index 00000000..d19f18a7
--- /dev/null
+++ b/lint/extensions.bzl
@@ -0,0 +1,14 @@
+"Adapt repository rule macros to bzlmod"
+
+load("checkstyle.bzl", "fetch_checkstyle")
+load("ktlint.bzl", "fetch_ktlint")
+load("pmd.bzl", "fetch_pmd")
+
+def _jvm_dependencies_impl(_ctx):
+ fetch_checkstyle()
+ fetch_ktlint()
+ fetch_pmd()
+
+jvm_dependencies = module_extension(
+ implementation = _jvm_dependencies_impl,
+)
diff --git a/lint/vale.bzl b/lint/vale.bzl
index b668a93c..0cf66052 100644
--- a/lint/vale.bzl
+++ b/lint/vale.bzl
@@ -202,4 +202,11 @@ def fetch_vale(tag = VALE_VERSIONS.keys()[0]):
build_file_content = """exports_files(["vale", "vale.exe"])""",
)
- fetch_styles()
+ fetch_styles()
+
+def _vale_dependencies_impl(_ctx):
+ fetch_vale()
+
+vale_dependencies = module_extension(
+ implementation = _vale_dependencies_impl,
+)