Skip to content

Commit

Permalink
refactor: make root workspace bzlmod only
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Aug 20, 2024
1 parent abbbd54 commit 79d2fb7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 187 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ jobs:
# Don't test RBE with on Windows (not configured)
- os: windows
config: rbe
# Root workspace is bzlmod-only
- folder: .
bzlmod: 0
# TODO: green up root Workspace on MacOS & Windows
- folder: .
os: macos
Expand Down
15 changes: 2 additions & 13 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
load("@aspect_bazel_lib_host//:defs.bzl", "host")
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("//lib:diff_test.bzl", "diff_test")
load("//lib:tar.bzl", "mtree_spec")
load("//lib:testing.bzl", "assert_contains")
load("//lib:utils.bzl", "is_bazel_7_or_greater")
load("//lib:write_source_files.bzl", "write_source_files")
load("//lib:yq.bzl", "yq")

Expand Down Expand Up @@ -71,16 +70,6 @@ alias(
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

bzl_library(
name = "internal_deps",
srcs = ["internal_deps.bzl"],
visibility = ["//visibility:public"],
deps = [
"@bazel_tools//tools/build_defs/repo:http.bzl",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if is_bazel_7_or_greater() else []),
)

# write_source_files() to a git ignored subdirectory of the root
genrule(
name = "write_source_file_root",
Expand Down Expand Up @@ -135,7 +124,7 @@ bzl_library(
name = "deps",
srcs = ["deps.bzl"],
visibility = ["//visibility:public"],
deps = ["@bazel_gazelle//:deps"],
deps = ["@gazelle//:deps"],
)

# Test case for mtree_spec: Ensure that multiple entries at the root directory are handled correctly (bug #851)
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ host = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "host", dev_depend
host.host()
use_repo(host, "aspect_bazel_lib_host")

bazel_dep(name = "aspect_rules_lint", version = "1.0.0-rc8", dev_dependency = True)
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
bazel_dep(name = "bazel_features", version = "0.2.0", dev_dependency = True)
83 changes: 2 additions & 81 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,62 +1,11 @@
# Declare the local Bazel workspace.
# This is *not* included in the published distribution.
workspace(
# see https://docs.bazel.build/versions/main/skylark/deploying.html#workspace
name = "aspect_bazel_lib",
)

load(":internal_deps.bzl", "bazel_lib_internal_deps")

# Fetch deps needed only locally for development
bazel_lib_internal_deps()

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps")

stardoc_external_deps()

load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")

stardoc_pinned_maven_install()

load("//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains")

aspect_bazel_lib_dependencies()

aspect_bazel_lib_register_toolchains()

# For running our own unit tests
load("@bazel_skylib//lib:unittest.bzl", "register_unittest_toolchains")

register_unittest_toolchains()

# An external repository for test to use
local_repository(
name = "external_test_repo",
path = "./lib/tests/external_test_repo",
)

load("//lib:host_repo.bzl", "host_repo")

host_repo(name = "aspect_bazel_lib_host")

############################################
# rules_go
# Go deps

load("//:deps.bzl", "go_dependencies")

Expand All @@ -65,36 +14,8 @@ load("//:deps.bzl", "go_dependencies")
# https://github.com/bazelbuild/bazel-gazelle/issues/1217#issuecomment-1152236735
go_dependencies()

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.18.3")

############################################
# Gazelle, for generating bzl_library targets

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

gazelle_dependencies()

# Buildifier
load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()

# rules_lint
load(
"@aspect_rules_lint//format:repositories.bzl",
"fetch_shfmt",
)

fetch_shfmt()

# rules_workflows
load("//.aspect/workflows:deps.bzl", "fetch_workflows_deps")

fetch_workflows_deps()
2 changes: 1 addition & 1 deletion deps.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""This module contains the project repository dependencies.
"""

load("@bazel_gazelle//:deps.bzl", "go_repository")
load("@gazelle//:deps.bzl", "go_repository")

def go_dependencies():
"""The Go dependencies.
Expand Down
71 changes: 0 additions & 71 deletions internal_deps.bzl

This file was deleted.

27 changes: 6 additions & 21 deletions tools/format/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
load("@aspect_rules_lint//format:defs.bzl", "multi_formatter_binary")
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")

sh_binary(
name = "noop",
srcs = ["noop.sh"],
)

alias(
name = "shfmt",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@shfmt_darwin_aarch64//file:shfmt",
"@bazel_tools//src/conditions:darwin_x86_64": "@shfmt_darwin_x86_64//file:shfmt",
"@bazel_tools//src/conditions:linux_aarch64": "@shfmt_linux_aarch64//file:shfmt",
"@bazel_tools//src/conditions:linux_x86_64": "@shfmt_linux_x86_64//file:shfmt",
"//conditions:default": ":noop",
}),
visibility = ["//:__subpackages__"],
)

multi_formatter_binary(
format_multirun(
name = "format",
go = "@go_sdk//:bin/gofmt",
sh = ":shfmt",
# TODO: enable formatters in follow-up PR
# go = "@aspect_rules_lint//format:gofumpt",
# shell = "@aspect_rules_lint//format:shfmt",
starlark = "@buildifier_prebuilt//:buildifier",
tags = ["manual"],
visibility = ["//:__subpackages__"],
# yaml = "@aspect_rules_lint//format:yamlfmt",
)

0 comments on commit 79d2fb7

Please sign in to comment.