From 7efe4a42b6351cbc4b639303a57db06e532ed9fd Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 9 Oct 2024 07:49:44 -0700 Subject: [PATCH 1/9] Revert "Revert "feat: start testing on Bazel 8 (#401)" (#404)" This reverts commit 87347430e604b153318a0cd0ad613f3746028f7a. --- .github/workflows/ci.yaml | 9 +-------- MODULE.bazel | 1 + docs/BUILD.bazel | 3 +++ docs/format.md | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 760396b8..1887c35f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,18 +18,11 @@ concurrency: jobs: bazel-test: - uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6 + uses: bazel-contrib/.github/.github/workflows/bazel.yaml@bazel8 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"} - ] integration-test: runs-on: ubuntu-latest diff --git a/MODULE.bazel b/MODULE.bazel index ed6f3f66..235dc03f 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.18.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/docs/BUILD.bazel b/docs/BUILD.bazel index 0f7cc148..64084375 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//private:util.bzl", "lt") stardoc_with_diff_test( name = "lint_test", @@ -35,6 +36,8 @@ stardoc_with_diff_test( stardoc_with_diff_test( name = "format", bzl_library_target = "//format:defs", + # See https://github.com/bazel-contrib/bazel_features/pull/75 + target_compatible_with = ["@platforms//:incompatible"] if lt("8.0.0-pre.20240911.1") else [], ) stardoc_with_diff_test( diff --git a/docs/format.md b/docs/format.md index 15ba0e02..3795a4c7 100644 --- a/docs/format.md +++ b/docs/format.md @@ -101,7 +101,7 @@ Some languages have dialects:
 load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
 
-format_multirun(name, jobs, print_command, disable_git_attribute_checks, kwargs)
+format_multirun(name, jobs, print_command, disable_git_attribute_checks, **kwargs)
 
Create a [multirun] binary for the given languages. @@ -135,7 +135,7 @@ To check formatting with `bazel test`, use [format_test](#format_test) instead.
 load("@aspect_rules_lint//format:defs.bzl", "format_test")
 
-format_test(name, srcs, workspace, no_sandbox, disable_git_attribute_checks, tags, kwargs)
+format_test(name, srcs, workspace, no_sandbox, disable_git_attribute_checks, tags, **kwargs)
 
Create test for the given formatters. From 907181321f3f8c1e9f8228ecb0bc7d225ebc93c5 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 9 Oct 2024 07:50:28 -0700 Subject: [PATCH 2/9] pin to last commit on https://github.com/bazel-contrib/.github/pull/17 --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1887c35f..11a7ebfb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ concurrency: jobs: bazel-test: - uses: bazel-contrib/.github/.github/workflows/bazel.yaml@bazel8 + uses: bazel-contrib/.github/.github/workflows/bazel.yaml@1314bb5dc3bccbc26063ee0710830919bb9a0792 with: folders: '[".", "example"]' # Don't try for Windows support yet. From 4ffc57b2bc392392a0f25357cfff463677d68b0d Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 9 Oct 2024 09:03:32 -0700 Subject: [PATCH 3/9] restore exclusion --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 11a7ebfb..b7204d35 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,8 @@ jobs: folders: '[".", "example"]' # Don't try for Windows support yet. exclude_windows: true + exclude: | + [{"bzlmodEnabled": false, "folder": "."}] integration-test: runs-on: ubuntu-latest From 572fb71f189c235e2a0834ba6c52ec924853cb94 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 25 Oct 2024 09:27:08 -0700 Subject: [PATCH 4/9] fixes --- .bazelversion | 2 +- .github/workflows/ci.yaml | 2 +- WORKSPACE.bazel | 1 - example/MODULE.bazel | 24 ++++++++++++++++++++++++ example/WORKSPACE.bzlmod | 22 ---------------------- format/extensions.bzl | 1 + format/repositories.bzl | 15 +++++++++++++++ lint/extensions.bzl | 14 ++++++++++++++ lint/vale.bzl | 7 +++++++ 9 files changed, 63 insertions(+), 25 deletions(-) delete mode 100644 WORKSPACE.bazel create mode 100644 format/extensions.bzl create mode 100644 lint/extensions.bzl diff --git a/.bazelversion b/.bazelversion index 2b1ea10a..876acd8d 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1,4 +1,4 @@ -7.1.1 +last_rc # The first line of this file is used by Bazelisk and Bazel to be sure # the right version of Bazel is used to build and test this repo. # This also defines which version is used on CI. diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b7204d35..c265578d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ concurrency: jobs: bazel-test: - uses: bazel-contrib/.github/.github/workflows/bazel.yaml@1314bb5dc3bccbc26063ee0710830919bb9a0792 + uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v7 with: folders: '[".", "example"]' # Don't try for Windows support yet. 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/example/MODULE.bazel b/example/MODULE.bazel index d88b2ee7..03cb9779 100644 --- a/example/MODULE.bazel +++ b/example/MODULE.bazel @@ -25,6 +25,9 @@ local_path_override( path = "..", ) +vale_dependencies = use_extension("@aspect_rules_lint//lint:vale.bzl", "vale_dependencies") +use_repo(vale_dependencies, "vale_macOS_arm64") + 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 +102,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 +131,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..9cdb0011 100644 --- a/lint/vale.bzl +++ b/lint/vale.bzl @@ -203,3 +203,10 @@ def fetch_vale(tag = VALE_VERSIONS.keys()[0]): ) fetch_styles() + +def _vale_dependencies_impl(_ctx): + fetch_vale() + +vale_dependencies = module_extension( + implementation = _vale_dependencies_impl, +) From 389abf66d5658fec3265addb2f71639c9e850a92 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 25 Oct 2024 09:59:16 -0700 Subject: [PATCH 5/9] chore: fixes --- .bazelversion | 2 +- example/MODULE.bazel | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.bazelversion b/.bazelversion index 876acd8d..2b1ea10a 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1,4 +1,4 @@ -last_rc +7.1.1 # The first line of this file is used by Bazelisk and Bazel to be sure # the right version of Bazel is used to build and test this repo. # This also defines which version is used on CI. diff --git a/example/MODULE.bazel b/example/MODULE.bazel index 03cb9779..23983583 100644 --- a/example/MODULE.bazel +++ b/example/MODULE.bazel @@ -26,7 +26,14 @@ local_path_override( ) vale_dependencies = use_extension("@aspect_rules_lint//lint:vale.bzl", "vale_dependencies") -use_repo(vale_dependencies, "vale_macOS_arm64") +use_repo( + vale_dependencies, + "vale_Linux_64-bit", + "vale_Linux_arm64", + "vale_Windows_64-bit", + "vale_macOS_64-bit", + "vale_macOS_arm64", +) rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext") rules_ts_ext.deps() From 848672c29c901067ef5dfbe5e4cc32a27f0a90e1 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 25 Oct 2024 10:25:44 -0700 Subject: [PATCH 6/9] fixes --- lint/vale.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lint/vale.bzl b/lint/vale.bzl index 9cdb0011..0cf66052 100644 --- a/lint/vale.bzl +++ b/lint/vale.bzl @@ -202,7 +202,7 @@ 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() From 2db6eb48a03f97536dad82288288ae990ee2acf1 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 25 Oct 2024 10:29:40 -0700 Subject: [PATCH 7/9] chore: fix --- example/MODULE.bazel | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/MODULE.bazel b/example/MODULE.bazel index 23983583..4baa2882 100644 --- a/example/MODULE.bazel +++ b/example/MODULE.bazel @@ -28,11 +28,13 @@ local_path_override( 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") From 5b62ca2e7d31212c9d031b9d7cbd777a4a2890e1 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 25 Oct 2024 10:33:06 -0700 Subject: [PATCH 8/9] chore: fix --- .bazelrc | 3 +++ example/MODULE.bazel | 1 + 2 files changed, 4 insertions(+) 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/example/MODULE.bazel b/example/MODULE.bazel index 4baa2882..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") From 474e6b952a60d5b9d61ef523bb42aaf839949e24 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 25 Oct 2024 11:16:40 -0700 Subject: [PATCH 9/9] chore: fix --- MODULE.bazel | 2 +- docs/BUILD.bazel | 5 ++--- docs/format.md | 4 ++-- docs/vale.md | 10 ++++++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 235dc03f..fcbf81ea 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,7 +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.18.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/docs/BUILD.bazel b/docs/BUILD.bazel index 64084375..29bc7ebe 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -1,7 +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//private:util.bzl", "lt") +load("@bazel_features//:features.bzl", "bazel_features") stardoc_with_diff_test( name = "lint_test", @@ -36,8 +36,7 @@ stardoc_with_diff_test( stardoc_with_diff_test( name = "format", bzl_library_target = "//format:defs", - # See https://github.com/bazel-contrib/bazel_features/pull/75 - target_compatible_with = ["@platforms//:incompatible"] if lt("8.0.0-pre.20240911.1") else [], + target_compatible_with = ["@platforms//:incompatible"] if bazel_features.docs.kwargs_name_with_double_star else [], ) stardoc_with_diff_test( diff --git a/docs/format.md b/docs/format.md index 3795a4c7..15ba0e02 100644 --- a/docs/format.md +++ b/docs/format.md @@ -101,7 +101,7 @@ Some languages have dialects:
 load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
 
-format_multirun(name, jobs, print_command, disable_git_attribute_checks, **kwargs)
+format_multirun(name, jobs, print_command, disable_git_attribute_checks, kwargs)
 
Create a [multirun] binary for the given languages. @@ -135,7 +135,7 @@ To check formatting with `bazel test`, use [format_test](#format_test) instead.
 load("@aspect_rules_lint//format:defs.bzl", "format_test")
 
-format_test(name, srcs, workspace, no_sandbox, disable_git_attribute_checks, tags, **kwargs)
+format_test(name, srcs, workspace, no_sandbox, disable_git_attribute_checks, tags, kwargs)
 
Create test for the given formatters. 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")
+
+ + +