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

Migrate to Bazel 7 #67

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
7.0.0
7 changes: 7 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ jobs:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v1
- run: bazel build //... && bazel test //...

build-no-bzlmod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v1
- run: bazel build --noenable_bzlmod //... && bazel test --noenable_bzlmod //...
6 changes: 0 additions & 6 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ buildifier(
name = "buildifier",
)

load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("//:deps.bzl", "rpmtree", "tar2files")
load("//:def.bzl", "bazeldnf")

Expand Down Expand Up @@ -39,11 +38,6 @@ tar2files(
visibility = ["//visibility:public"],
)

pkg_tar(
name = "whatever",
deps = [":something"],
)

cc_library(
name = "bar",
srcs = ["//:something_libs/usr/lib64"],
Expand Down
24 changes: 24 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module(
name = "bazeldnf",
version = "0.6.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a value which we need to bump for releases to match the release tag?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something which we can always set to the tag value in the release script with e.g. buildozer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes so the version is something that gets bumped with a GitHub release and the Bazel central registry (BCR) provided with GitHub workflows to make releasing of new versions trivial, there's a template rule from which every new rule is forking, I need to look into the details and adopt, once we have those hooks a new release for BCR is just a tag in another public GitHub repo

)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_go", version = "0.44.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.35.0", repo_name = "bazel_gazelle")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

use_repo(
Copy link
Owner

@rmohr rmohr Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the optimum would be if by default we woulds still just download the recompiled dependencies, so that while we can cleanly pull in the whole go stack, by default we don't have to. Having said that, an initial stab on this which only works with recompile is fine as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes so rules_go would become a dev dependency, what other rules are doing is having a public directory in our case it would be bazeldnf and in that directory if someone does bazel build @bazeldnf//bazeldnf/... then the entire path should build.

We would choose to use prebuilt or already built during toolchain registration.

Since I started exploring bzlmod for bazeldnf I also wrote/ported some other rules and learned a lot in the process, I need to close this MR and rebuild based on that, we should make lock file support a chance we introduce once we merge bzlmod.

go_deps,
"com_github_bazelbuild_buildtools",
"com_github_crillab_gophersat",
"com_github_onsi_gomega",
"com_github_sassoftware_go_rpmutils",
"com_github_sirupsen_logrus",
"com_github_spf13_cobra",
"io_k8s_sigs_yaml",
"org_golang_x_crypto"
)
25 changes: 12 additions & 13 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "f24ab666394232f834f74d19e2ff142b0af17466ea0c69a3f4c276ee75f6efce",
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
],
)

Expand All @@ -17,10 +17,10 @@ bazel_skylib_workspace()

http_archive(
name = "com_google_protobuf",
sha256 = "930c2c3b5ecc6c9c12615cf5ad93f1cd6e12d0aba862b572e076259970ac3a53",
strip_prefix = "protobuf-3.21.12",
sha256 = "5493a21f5ed3fc502e66fec6b9449c06a551ced63002fa48903c40dfa8de7a4a",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.21.12.tar.gz",
"https://github.com/protocolbuffers/protobuf/releases/download/v21.7/protobuf-all-21.7.zip",
],
)

Expand All @@ -30,19 +30,18 @@ protobuf_deps()

http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
sha256 = "c8035e8ae248b56040a65ad3f0b7434712e2037e5dfdcebfe97576e620422709",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.44.0/rules_go-v0.44.0.zip"
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "efbbba6ac1a4fd342d5122cbdfdb82aeb2cf2862e35022c752eaddffada7c3f3",
sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.27.0/bazel-gazelle-v0.27.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.27.0/bazel-gazelle-v0.27.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
],
)

Expand All @@ -58,7 +57,7 @@ bazeldnf_dependencies()

go_rules_dependencies()

go_register_toolchains(version = "1.19.2")
go_register_toolchains(version = "1.21.1")

gazelle_dependencies()

Expand Down
8 changes: 4 additions & 4 deletions cmd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ go_library(
"//pkg/sat",
"//pkg/xattr",
"@com_github_bazelbuild_buildtools//build:go_default_library",
"@com_github_sassoftware_go_rpmutils//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@org_golang_x_crypto//openpgp:go_default_library",
"@com_github_sassoftware_go_rpmutils//:go-rpmutils",
"@com_github_sirupsen_logrus//:logrus",
"@com_github_spf13_cobra//:cobra",
"@org_golang_x_crypto//openpgp",
],
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ go_test(
deps = [
"//pkg/api",
"//pkg/api/bazeldnf",
"@com_github_onsi_gomega//:go_default_library",
"@com_github_onsi_gomega//:gomega",
],
)
4 changes: 2 additions & 2 deletions pkg/order/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/rpm",
"@com_github_sassoftware_go_rpmutils//cpio:go_default_library",
"@com_github_sassoftware_go_rpmutils//cpio",
],
)

go_test(
name = "order_test",
srcs = ["order_test.go"],
embed = [":order"],
deps = ["@com_github_onsi_gomega//:go_default_library"],
deps = ["@com_github_onsi_gomega//:gomega"],
)
2 changes: 1 addition & 1 deletion pkg/reducer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ go_library(
"//pkg/api",
"//pkg/api/bazeldnf",
"//pkg/repo",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_sirupsen_logrus//:logrus",
],
)
4 changes: 2 additions & 2 deletions pkg/repo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ go_library(
"//pkg/api",
"//pkg/api/bazeldnf",
"//pkg/rpm",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_k8s_sigs_yaml//:go_default_library",
"@com_github_sirupsen_logrus//:logrus",
"@io_k8s_sigs_yaml//:yaml",
],
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/rpm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ go_library(
deps = [
"//pkg/api",
"//pkg/xattr",
"@com_github_sassoftware_go_rpmutils//:go_default_library",
"@com_github_sassoftware_go_rpmutils//cpio:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_sassoftware_go_rpmutils//:go-rpmutils",
"@com_github_sassoftware_go_rpmutils//cpio",
"@com_github_sirupsen_logrus//:logrus",
],
)

Expand All @@ -28,6 +28,6 @@ go_test(
embed = [":rpm"],
deps = [
"//pkg/api",
"@com_github_onsi_gomega//:go_default_library",
"@com_github_onsi_gomega//:gomega",
],
)
10 changes: 5 additions & 5 deletions pkg/sat/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ go_library(
"//pkg/api",
"//pkg/reducer",
"//pkg/rpm",
"@com_github_crillab_gophersat//bf:go_default_library",
"@com_github_crillab_gophersat//explain:go_default_library",
"@com_github_crillab_gophersat//maxsat:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_crillab_gophersat//bf",
"@com_github_crillab_gophersat//explain",
"@com_github_crillab_gophersat//maxsat",
"@com_github_sirupsen_logrus//:logrus",
],
)

Expand All @@ -23,6 +23,6 @@ go_test(
embed = [":sat"],
deps = [
"//pkg/api",
"@com_github_onsi_gomega//:go_default_library",
"@com_github_onsi_gomega//:gomega",
],
)
2 changes: 1 addition & 1 deletion pkg/xattr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ go_test(
srcs = ["xattr_test.go"],
data = glob(["testdata/**"]),
embed = [":xattr"],
deps = ["@com_github_onsi_gomega//:go_default_library"],
deps = ["@com_github_onsi_gomega//:gomega"],
)
Loading