Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: start testing on Bazel 8 #407

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion WORKSPACE.bazel

This file was deleted.

2 changes: 2 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions docs/vale.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions example/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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")
22 changes: 0 additions & 22 deletions example/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions format/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Adapt repository rule macros to bzlmod"
15 changes: 15 additions & 0 deletions format/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
)
14 changes: 14 additions & 0 deletions lint/extensions.bzl
Original file line number Diff line number Diff line change
@@ -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,
)
9 changes: 8 additions & 1 deletion lint/vale.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Loading