From ada3f5f945b1f402be29b70eb0b45b3571004ef8 Mon Sep 17 00:00:00 2001 From: Manuel Naranjo Date: Fri, 22 Dec 2023 16:59:01 +0100 Subject: [PATCH 1/3] bazel: bump to 7.0.0 Starting to bump to 7.0.0 --- .bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelversion b/.bazelversion index 831446c..66ce77b 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -5.1.0 +7.0.0 From 0353ab107978081bbf52b12dcc4cfa6f923292de Mon Sep 17 00:00:00 2001 From: Manuel Naranjo Date: Fri, 22 Dec 2023 17:00:01 +0100 Subject: [PATCH 2/3] bazel: make repo build with bazel 7.0.0 Now the repo buils with bazel 7.0.0 and no bzlmod yet --- .github/workflows/action.yml | 7 +++++++ BUILD.bazel | 6 ------ WORKSPACE | 18 +++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index def1794..aea2493 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -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 //... diff --git a/BUILD.bazel b/BUILD.bazel index c258f99..2cf83a7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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") @@ -39,11 +38,6 @@ tar2files( visibility = ["//visibility:public"], ) -pkg_tar( - name = "whatever", - deps = [":something"], -) - cc_library( name = "bar", srcs = ["//:something_libs/usr/lib64"], diff --git a/WORKSPACE b/WORKSPACE index b0e032a..a015ab6 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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", ], ) @@ -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", ], ) @@ -30,10 +30,10 @@ protobuf_deps() http_archive( name = "io_bazel_rules_go", - sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa", + sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", 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://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", ], ) From e32e42cfa46a84c61ee52d776146416a3721d9b4 Mon Sep 17 00:00:00 2001 From: Manuel Naranjo Date: Fri, 22 Dec 2023 17:32:16 +0100 Subject: [PATCH 3/3] bazel: adding bzlmod Bumping only the needed rules to make the setup work, making sure both bzlmod and non bzlmod still builds and test as expected --- MODULE.bazel | 24 ++++++++++++++++++++++++ WORKSPACE | 13 ++++++------- cmd/BUILD.bazel | 8 ++++---- pkg/bazel/BUILD.bazel | 2 +- pkg/order/BUILD.bazel | 4 ++-- pkg/reducer/BUILD.bazel | 2 +- pkg/repo/BUILD.bazel | 4 ++-- pkg/rpm/BUILD.bazel | 8 ++++---- pkg/sat/BUILD.bazel | 10 +++++----- pkg/xattr/BUILD.bazel | 2 +- 10 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 MODULE.bazel diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..611d6cc --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,24 @@ +module( + name = "bazeldnf", + version = "0.6.0", +) + +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( + 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" +) diff --git a/WORKSPACE b/WORKSPACE index a015ab6..d52cd88 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -30,19 +30,18 @@ protobuf_deps() http_archive( name = "io_bazel_rules_go", - sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", + sha256 = "c8035e8ae248b56040a65ad3f0b7434712e2037e5dfdcebfe97576e620422709", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.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", ], ) @@ -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() diff --git a/cmd/BUILD.bazel b/cmd/BUILD.bazel index 7bd2d60..1451510 100644 --- a/cmd/BUILD.bazel +++ b/cmd/BUILD.bazel @@ -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", ], ) diff --git a/pkg/bazel/BUILD.bazel b/pkg/bazel/BUILD.bazel index a80fd3a..d711570 100644 --- a/pkg/bazel/BUILD.bazel +++ b/pkg/bazel/BUILD.bazel @@ -20,6 +20,6 @@ go_test( deps = [ "//pkg/api", "//pkg/api/bazeldnf", - "@com_github_onsi_gomega//:go_default_library", + "@com_github_onsi_gomega//:gomega", ], ) diff --git a/pkg/order/BUILD.bazel b/pkg/order/BUILD.bazel index 9d62287..18ec87e 100644 --- a/pkg/order/BUILD.bazel +++ b/pkg/order/BUILD.bazel @@ -7,7 +7,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/rpm", - "@com_github_sassoftware_go_rpmutils//cpio:go_default_library", + "@com_github_sassoftware_go_rpmutils//cpio", ], ) @@ -15,5 +15,5 @@ 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"], ) diff --git a/pkg/reducer/BUILD.bazel b/pkg/reducer/BUILD.bazel index 96b24b5..2365db4 100644 --- a/pkg/reducer/BUILD.bazel +++ b/pkg/reducer/BUILD.bazel @@ -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", ], ) diff --git a/pkg/repo/BUILD.bazel b/pkg/repo/BUILD.bazel index d7070fd..1fc9eff 100644 --- a/pkg/repo/BUILD.bazel +++ b/pkg/repo/BUILD.bazel @@ -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", ], ) diff --git a/pkg/rpm/BUILD.bazel b/pkg/rpm/BUILD.bazel index dcadfc7..7391d26 100644 --- a/pkg/rpm/BUILD.bazel +++ b/pkg/rpm/BUILD.bazel @@ -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", ], ) @@ -28,6 +28,6 @@ go_test( embed = [":rpm"], deps = [ "//pkg/api", - "@com_github_onsi_gomega//:go_default_library", + "@com_github_onsi_gomega//:gomega", ], ) diff --git a/pkg/sat/BUILD.bazel b/pkg/sat/BUILD.bazel index 5b3d298..3cf20f9 100644 --- a/pkg/sat/BUILD.bazel +++ b/pkg/sat/BUILD.bazel @@ -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", ], ) @@ -23,6 +23,6 @@ go_test( embed = [":sat"], deps = [ "//pkg/api", - "@com_github_onsi_gomega//:go_default_library", + "@com_github_onsi_gomega//:gomega", ], ) diff --git a/pkg/xattr/BUILD.bazel b/pkg/xattr/BUILD.bazel index de1588c..5e0fed3 100644 --- a/pkg/xattr/BUILD.bazel +++ b/pkg/xattr/BUILD.bazel @@ -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"], )