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 5fac227
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 230 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
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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_toolchains", "zstd_toolchains")

register_toolchains(
"@copy_directory_toolchains//:all",
Expand Down 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)
100 changes: 0 additions & 100 deletions WORKSPACE

This file was deleted.

21 changes: 21 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -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 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
16 changes: 13 additions & 3 deletions e2e/copy_to_directory/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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()
21 changes: 16 additions & 5 deletions e2e/external_copy_to_directory/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
21 changes: 16 additions & 5 deletions e2e/external_copy_to_directory/app/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
16 changes: 12 additions & 4 deletions e2e/smoke/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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()
Loading

0 comments on commit 5fac227

Please sign in to comment.