refactor: make root workspace bzlmod only (#915)
This commit is contained in:
parent
0e1f1e82c9
commit
cccf5ac1b8
|
@ -112,6 +112,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
|
||||
|
|
15
BUILD.bazel
15
BUILD.bazel
|
@ -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")
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
|
|
|
@ -24,7 +24,7 @@ bazel_lib_toolchains.tar()
|
|||
bazel_lib_toolchains.zstd()
|
||||
bazel_lib_toolchains.expand_template()
|
||||
bazel_lib_toolchains.bats()
|
||||
use_repo(bazel_lib_toolchains, "bats_toolchains", "bsd_tar_toolchains", "copy_directory_toolchains", "copy_to_directory_toolchains", "coreutils_toolchains", "expand_template_toolchains", "jq_toolchains", "yq_toolchains", "zstd_toolchains")
|
||||
use_repo(bazel_lib_toolchains, "bats_toolchains", "bsd_tar_toolchains", "copy_directory_toolchains", "copy_to_directory_toolchains", "coreutils_toolchains", "expand_template_toolchains", "jq", "jq_toolchains", "yq", "yq_toolchains", "zstd_toolchains")
|
||||
|
||||
register_toolchains(
|
||||
"@copy_directory_toolchains//:all",
|
||||
|
@ -76,6 +76,7 @@ use_repo(host, "aspect_bazel_lib_host")
|
|||
host_platform = use_extension("@platforms//host:extension.bzl", "host_platform", dev_dependency = True)
|
||||
use_repo(host_platform, "host_platform")
|
||||
|
||||
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)
|
||||
|
|
100
WORKSPACE
100
WORKSPACE
|
@ -1,100 +0,0 @@
|
|||
# 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
|
||||
|
||||
load("//:deps.bzl", "go_dependencies")
|
||||
|
||||
# gazelle:repository_macro deps.bzl%go_dependencies
|
||||
# gazelle:repository go_repository name=org_golang_x_tools importpath=golang.org/x/tools
|
||||
# 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()
|
||||
|
||||
load("//.aspect/workflows:deps.bzl", "fetch_workflows_deps")
|
||||
|
||||
fetch_workflows_deps()
|
|
@ -0,0 +1,21 @@
|
|||
# An external repository for test to use
|
||||
local_repository(
|
||||
name = "external_test_repo",
|
||||
path = "./lib/tests/external_test_repo",
|
||||
)
|
||||
|
||||
############################################
|
||||
# Go dependencies
|
||||
|
||||
load("//:deps.bzl", "go_dependencies")
|
||||
|
||||
# gazelle:repository_macro deps.bzl%go_dependencies
|
||||
# gazelle:repository go_repository name=org_golang_x_tools importpath=golang.org/x/tools
|
||||
# https://github.com/bazelbuild/bazel-gazelle/issues/1217#issuecomment-1152236735
|
||||
go_dependencies()
|
||||
|
||||
############################################
|
||||
# Aspect Workflows
|
||||
load("//.aspect/workflows:deps.bzl", "fetch_workflows_deps")
|
||||
|
||||
fetch_workflows_deps()
|
2
deps.bzl
2
deps.bzl
|
@ -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.
|
||||
|
|
|
@ -12,9 +12,19 @@ register_copy_to_directory_toolchains()
|
|||
############################################
|
||||
# rules_go is needed to consume tools from sources
|
||||
|
||||
load("@aspect_bazel_lib//:internal_deps.bzl", "bazel_lib_internal_deps")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
bazel_lib_internal_deps()
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
|
||||
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "gazelle",
|
||||
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
|
||||
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
|
||||
)
|
||||
|
||||
load("@aspect_bazel_lib//:deps.bzl", "go_dependencies")
|
||||
|
||||
|
@ -26,6 +36,6 @@ go_rules_dependencies()
|
|||
|
||||
go_register_toolchains(version = "1.18.3")
|
||||
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
load("@gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
|
||||
gazelle_dependencies()
|
||||
|
|
|
@ -5,14 +5,25 @@ local_repository(
|
|||
path = "../..",
|
||||
)
|
||||
|
||||
load("@aspect_bazel_lib//:internal_deps.bzl", "bazel_lib_internal_deps")
|
||||
|
||||
bazel_lib_internal_deps()
|
||||
|
||||
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
|
||||
|
||||
aspect_bazel_lib_dependencies()
|
||||
|
||||
# rules_go is needed to consume tools from sources
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
|
||||
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "gazelle",
|
||||
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
|
||||
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
|
||||
)
|
||||
|
||||
load("@aspect_bazel_lib//:deps.bzl", "go_dependencies")
|
||||
|
||||
go_dependencies()
|
||||
|
@ -23,6 +34,6 @@ go_rules_dependencies()
|
|||
|
||||
go_register_toolchains(version = "1.18.3")
|
||||
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
load("@gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
|
||||
gazelle_dependencies()
|
||||
|
|
|
@ -8,14 +8,25 @@ local_repository(
|
|||
path = "../../..",
|
||||
)
|
||||
|
||||
load("@aspect_bazel_lib//:internal_deps.bzl", "bazel_lib_internal_deps")
|
||||
|
||||
bazel_lib_internal_deps()
|
||||
|
||||
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
|
||||
|
||||
aspect_bazel_lib_dependencies()
|
||||
|
||||
# rules_go is needed to consume tools from sources
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
|
||||
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "gazelle",
|
||||
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
|
||||
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
|
||||
)
|
||||
|
||||
load("@aspect_bazel_lib//:deps.bzl", "go_dependencies")
|
||||
|
||||
go_dependencies()
|
||||
|
@ -26,6 +37,6 @@ go_rules_dependencies()
|
|||
|
||||
go_register_toolchains(version = "1.18.3")
|
||||
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
load("@gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
|
||||
gazelle_dependencies()
|
||||
|
|
|
@ -9,12 +9,20 @@ aspect_bazel_lib_dependencies()
|
|||
|
||||
aspect_bazel_lib_register_toolchains()
|
||||
|
||||
############################################
|
||||
# rules_go is needed to consume tools from sources
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
load("@aspect_bazel_lib//:internal_deps.bzl", "bazel_lib_internal_deps")
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
|
||||
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"],
|
||||
)
|
||||
|
||||
bazel_lib_internal_deps()
|
||||
http_archive(
|
||||
name = "gazelle",
|
||||
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
|
||||
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
|
||||
)
|
||||
|
||||
load("@aspect_bazel_lib//:deps.bzl", "go_dependencies")
|
||||
|
||||
|
@ -26,6 +34,6 @@ go_rules_dependencies()
|
|||
|
||||
go_register_toolchains(version = "1.18.3")
|
||||
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
load("@gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
|
||||
gazelle_dependencies()
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
"""Our "development" dependencies
|
||||
|
||||
Users should *not* need to install these. If users see a load()
|
||||
statement from these, that's a bug in our distribution.
|
||||
"""
|
||||
|
||||
load("//lib:repositories.bzl", "register_bats_toolchains", "register_coreutils_toolchains", "register_jq_toolchains", "register_tar_toolchains", "register_yq_toolchains")
|
||||
load("//lib:utils.bzl", http_archive = "maybe_http_archive")
|
||||
|
||||
# buildifier: disable=unnamed-macro
|
||||
def bazel_lib_internal_deps():
|
||||
"Fetch deps needed for local development"
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
|
||||
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_gazelle",
|
||||
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
|
||||
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_skylib_gazelle_plugin",
|
||||
sha256 = "747addf3f508186234f6232674dd7786743efb8c68619aece5fb0cac97b8f415",
|
||||
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
|
||||
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_stardoc",
|
||||
sha256 = "62bd2e60216b7a6fec3ac79341aa201e0956477e7c8f6ccc286f279ad1d96432",
|
||||
urls = ["https://github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "buildifier_prebuilt",
|
||||
sha256 = "8ada9d88e51ebf5a1fdff37d75ed41d51f5e677cdbeafb0a22dda54747d6e07e",
|
||||
strip_prefix = "buildifier-prebuilt-6.4.0",
|
||||
urls = ["http://github.com/keith/buildifier-prebuilt/archive/6.4.0.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_lint",
|
||||
sha256 = "604666ec7ffd4f5f2636001ae892a0fbc29c77401bb33dd10601504e3ba6e9a7",
|
||||
strip_prefix = "rules_lint-0.6.1",
|
||||
url = "https://github.com/aspect-build/rules_lint/releases/download/v0.6.1/rules_lint-v0.6.1.tar.gz",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_features",
|
||||
sha256 = "1aabce613b3ed83847b47efa69eb5dc9aa3ae02539309792a60e705ca4ab92a5",
|
||||
strip_prefix = "bazel_features-0.2.0",
|
||||
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v0.2.0/bazel_features-v0.2.0.tar.gz",
|
||||
)
|
||||
|
||||
# Register toolchains for tests
|
||||
register_jq_toolchains()
|
||||
register_yq_toolchains()
|
||||
register_coreutils_toolchains()
|
||||
register_tar_toolchains()
|
||||
register_bats_toolchains(
|
||||
libraries = ["@aspect_bazel_lib//lib/tests/bats/bats-custom:custom"],
|
||||
)
|
|
@ -12,10 +12,10 @@ go_library(
|
|||
visibility = ["//visibility:public"],
|
||||
deps = select({
|
||||
"@io_bazel_rules_go//go/platform:darwin": [
|
||||
"@org_golang_x_sys//unix:go_default_library",
|
||||
"@org_golang_x_sys//unix",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:ios": [
|
||||
"@org_golang_x_sys//unix:go_default_library",
|
||||
"@org_golang_x_sys//unix",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
|
|
|
@ -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",
|
||||
)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo "not implemented".
|
||||
exit 1
|
Loading…
Reference in New Issue