Skip to content

Commit 0523988

Browse files
authored
Merge pull request #98 from kellyma2/cleanup-bzlmod
Clean up use of WORKSPACE.bzlmod so we can move fully to bzlmod
2 parents a3c7663 + 4921c80 commit 0523988

File tree

10 files changed

+107
-78
lines changed

10 files changed

+107
-78
lines changed

.github/workflows/action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
e2e-bzlmod-matrix:
6767
strategy:
6868
matrix:
69-
version: [6.x, 7.x]
69+
version: [7.x]
7070
path:
7171
- bazel-bzlmod
7272
- bazel-bzlmod-non-legacy-mode
@@ -93,8 +93,6 @@ jobs:
9393
strategy:
9494
matrix:
9595
config:
96-
- version: 6.x
97-
flags:
9896
- version: 7.x
9997
flags: --incompatible_enable_proto_toolchain_resolution
10098

BUILD.bazel

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ bazeldnf(
5757
rpmtree(
5858
name = "something",
5959
rpms = [
60-
"@libvirt-libs-11.0.0-1.fc42.x86_64.rpm//rpm",
61-
"@libvirt-devel-11.0.0-1.fc42.x86_64.rpm//rpm",
60+
"@bazeldnf_internal_libvirt-libs//rpm",
61+
"@bazeldnf_internal_libvirt-devel//rpm",
6262
],
6363
)
6464

@@ -107,10 +107,3 @@ bzl_library(
107107
"@bazeldnf//bazeldnf:deps",
108108
],
109109
)
110-
111-
bzl_library(
112-
name = "test_deps",
113-
srcs = ["test_deps.bzl"],
114-
visibility = ["//visibility:public"],
115-
deps = ["@bazeldnf//bazeldnf:defs"],
116-
)

MODULE.bazel

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,34 @@ module(
88

99
bazeldnf = use_extension("//bazeldnf:extensions.bzl", "bazeldnf")
1010
bazeldnf.toolchain()
11-
use_repo(bazeldnf, "bazeldnf_toolchains")
11+
bazeldnf.rpm(
12+
name = "bazeldnf_internal_abseil-cpp-devel",
13+
sha256 = "1393c28f5a3f3029769bbe3436b3eec58c7b11761c4ad6695c309b21474d9804",
14+
urls = [
15+
"https://kojipkgs.fedoraproject.org//packages/abseil-cpp/20240722.1/1.fc42/x86_64/abseil-cpp-devel-20240722.1-1.fc42.x86_64.rpm",
16+
],
17+
)
18+
bazeldnf.rpm(
19+
name = "bazeldnf_internal_libvirt-devel",
20+
sha256 = "dba37bbe57903afe49b5666f1781eb50001baa81af4584b355db0b6a2afad9fa",
21+
urls = [
22+
"https://kojipkgs.fedoraproject.org//packages/libvirt/11.0.0/1.fc42/x86_64/libvirt-devel-11.0.0-1.fc42.x86_64.rpm",
23+
],
24+
)
25+
bazeldnf.rpm(
26+
name = "bazeldnf_internal_libvirt-libs",
27+
sha256 = "aac272a2ace134b5ef60a41e6624deb24331e79c76699ef6cef0dca22d94ac7e",
28+
urls = [
29+
"https://kojipkgs.fedoraproject.org//packages/libvirt/11.0.0/1.fc42/x86_64/libvirt-libs-11.0.0-1.fc42.x86_64.rpm",
30+
],
31+
)
32+
use_repo(
33+
bazeldnf,
34+
"bazeldnf_internal_abseil-cpp-devel",
35+
"bazeldnf_internal_libvirt-devel",
36+
"bazeldnf_internal_libvirt-libs",
37+
"bazeldnf_toolchains",
38+
)
1239

1340
# registers toolchain for consumers of the repo
1441
register_toolchains("@bazeldnf_toolchains//:all")
@@ -18,8 +45,11 @@ bazel_dep(name = "platforms", version = "0.0.10")
1845
bazel_dep(name = "bazel_features", version = "1.14.0")
1946

2047
# dependenices for building bazeldnf
21-
bazel_dep(name = "gazelle", version = "0.41.0")
22-
bazel_dep(name = "rules_go", version = "0.51.0")
48+
bazel_dep(name = "gazelle", version = "0.42.0")
49+
bazel_dep(name = "rules_go", version = "0.52.0")
50+
51+
bazel_dep(name = "protobuf", version = "27.3", dev_dependency = True)
52+
bazel_dep(name = "toolchains_protoc", version = "0.3.2", dev_dependency = True)
2353

2454
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
2555
go_deps.from_file(go_mod = "//:go.mod")
@@ -42,11 +72,17 @@ bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.7.1", dev_dependenc
4272
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1", dev_dependency = True)
4373
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
4474
bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True)
45-
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True)
75+
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)
4676
bazel_dep(name = "rules_proto", version = "6.0.0", dev_dependency = True)
4777
bazel_dep(name = "rules_java", version = "7.9.0", dev_dependency = True)
48-
bazel_dep(name = "protobuf", version = "27.3", dev_dependency = True)
49-
bazel_dep(name = "toolchains_protoc", version = "0.3.2", dev_dependency = True)
78+
79+
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
80+
81+
http_jar(
82+
name = "protobuf-java",
83+
integrity = "sha256-0C+GOpCj/8d9Xu7AMcGOV58wx8uY8/OoFP6LiMQ9O8g=",
84+
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.3/protobuf-java-4.27.3.jar"],
85+
)
5086

5187
register_toolchains(
5288
"//tools/toolchains:all",

WORKSPACE.bzlmod

Lines changed: 0 additions & 13 deletions
This file was deleted.

e2e/bazel-workspace/WORKSPACE

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ local_repository(
33
path = "../../",
44
)
55

6+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
7+
8+
http_archive(
9+
name = "bazel_skylib",
10+
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
11+
urls = [
12+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
13+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
14+
],
15+
)
16+
17+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
18+
19+
bazel_skylib_workspace()
20+
21+
load("@bazeldnf//bazeldnf:defs.bzl", "rpm")
622
load(
723
"@bazeldnf//bazeldnf:repositories.bzl",
824
"bazeldnf_dependencies",
@@ -15,12 +31,21 @@ bazeldnf_register_toolchains(
1531
name = "bazeldnf_prebuilt",
1632
)
1733

18-
# dependencies for integration tests
19-
load("@bazeldnf//:test_deps.bzl", "bazeldnf_test_dependencies")
20-
21-
bazeldnf_test_dependencies()
34+
rpm(
35+
name = "libvirt-devel-11.0.0-1.fc42.x86_64.rpm",
36+
sha256 = "dba37bbe57903afe49b5666f1781eb50001baa81af4584b355db0b6a2afad9fa",
37+
urls = [
38+
"https://kojipkgs.fedoraproject.org//packages/libvirt/11.0.0/1.fc42/x86_64/libvirt-devel-11.0.0-1.fc42.x86_64.rpm",
39+
],
40+
)
2241

23-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
42+
rpm(
43+
name = "libvirt-libs-11.0.0-1.fc42.x86_64.rpm",
44+
sha256 = "aac272a2ace134b5ef60a41e6624deb24331e79c76699ef6cef0dca22d94ac7e",
45+
urls = [
46+
"https://kojipkgs.fedoraproject.org//packages/libvirt/11.0.0/1.fc42/x86_64/libvirt-libs-11.0.0-1.fc42.x86_64.rpm",
47+
],
48+
)
2449

2550
http_archive(
2651
name = "rules_pkg",

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ require (
1515
sigs.k8s.io/yaml v1.4.0
1616
)
1717

18+
require github.com/bazelbuild/rules_go v0.52.0
19+
1820
require (
1921
github.com/adrg/xdg v0.5.3
20-
github.com/golang/protobuf v1.5.2 // indirect
22+
github.com/golang/protobuf v1.5.3 // indirect
2123
github.com/google/go-cmp v0.6.0 // indirect
2224
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2325
github.com/klauspost/compress v1.11.1 // indirect

go.sum

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=
22
github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
3-
github.com/bazelbuild/buildtools v0.0.0-20240823132350-3488089d3661 h1:acJJwAuD2t36RHnvxf3oh9lhg5LISUYXunx+om2ONZw=
4-
github.com/bazelbuild/buildtools v0.0.0-20240823132350-3488089d3661/go.mod h1:yBQGNvRAGhcBTxe4MHiW3Ul7DwoBim4XsKUaXnW1LWc=
53
github.com/bazelbuild/buildtools v0.0.0-20250110114635-13fa61383b99 h1:3Wvirn7fGxAk5XMO5OV9goElw2ZKya/erxxHChPSPQM=
64
github.com/bazelbuild/buildtools v0.0.0-20250110114635-13fa61383b99/go.mod h1:PLNUetjLa77TCCziPsz0EI8a6CUxgC+1jgmWv0H25tg=
5+
github.com/bazelbuild/rules_go v0.52.0 h1:+ozpngVAW67pCAwfhepaXSSrG3yHcj8K9hNAxSYBno4=
6+
github.com/bazelbuild/rules_go v0.52.0/go.mod h1:M+YrupNArA7OiTlv++rFUgQ6Sm+ZXbQ5HPUj0cGa0us=
77
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
88
github.com/crillab/gophersat v1.4.0 h1:irf9ajKmNnEURjgPU4oz+ouqIXXLQ59ZNd3NC+hULMc=
99
github.com/crillab/gophersat v1.4.0/go.mod h1:gDzeMEBrqJR20IL9JW25tFHNGLU5+GDeJzr0zpi3mxs=
@@ -15,8 +15,8 @@ github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ4
1515
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
1616
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
1717
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
18-
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
19-
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
18+
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
19+
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
2020
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
2121
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
2222
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
@@ -43,9 +43,9 @@ github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3k
4343
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
4444
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
4545
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
46-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
4746
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
4847
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
48+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4949
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
5050
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
5151
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -65,9 +65,8 @@ golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
6565
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
6666
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
6767
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
68-
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
69-
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
7068
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
69+
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
7170
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7271
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
7372
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=

pkg/rpm/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ go_test(
2525
"tar_test.go",
2626
],
2727
data = [
28-
"@abseil-cpp-devel-20240722.1-1.fc42.x86_64.rpm//rpm",
29-
"@libvirt-libs-11.0.0-1.fc42.x86_64.rpm//rpm",
28+
"@bazeldnf_internal_abseil-cpp-devel//rpm",
29+
"@bazeldnf_internal_libvirt-libs//rpm",
3030
],
3131
embed = [":rpm"],
3232
deps = [
3333
"//pkg/api",
3434
"@com_github_onsi_gomega//:gomega",
35+
"@rules_go//go/runfiles",
3536
],
3637
)

pkg/rpm/tar_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ import (
88
"path/filepath"
99
"testing"
1010

11+
"github.com/bazelbuild/rules_go/go/runfiles"
1112
. "github.com/onsi/gomega"
1213
)
1314

1415
func TestRPMToTar(t *testing.T) {
16+
libvirtLibsRpm, err := runfiles.Rlocation("bazeldnf_internal_libvirt-libs/rpm/downloaded")
17+
if err != nil {
18+
panic(err)
19+
}
20+
1521
tests := []struct {
1622
name string
1723
rpm string
@@ -23,7 +29,7 @@ func TestRPMToTar(t *testing.T) {
2329
}{
2430
{
2531
name: "should convert a RPM to tar and keep all entries",
26-
rpm: filepath.Join(os.Getenv("TEST_SRCDIR"), "libvirt-libs-11.0.0-1.fc42.x86_64.rpm/rpm/downloaded"),
32+
rpm: libvirtLibsRpm,
2733
wantErr: false,
2834
expectedHeaders: []*tar.Header{
2935
{Name: "./etc/libvirt/libvirt-admin.conf", Size: 450, Mode: 33188},
@@ -83,6 +89,16 @@ func TestRPMToTar(t *testing.T) {
8389
}
8490

8591
func TestTar2Files(t *testing.T) {
92+
abseilCppDevelRpm, err := runfiles.Rlocation("bazeldnf_internal_abseil-cpp-devel/rpm/downloaded")
93+
if err != nil {
94+
panic(err)
95+
}
96+
97+
libvirtLibsRpm, err := runfiles.Rlocation("bazeldnf_internal_libvirt-libs/rpm/downloaded")
98+
if err != nil {
99+
panic(err)
100+
}
101+
86102
tests := []struct {
87103
name string
88104
rpm string
@@ -93,7 +109,7 @@ func TestTar2Files(t *testing.T) {
93109
}{
94110
{
95111
name: "should extract a symlink from a tar archive",
96-
rpm: filepath.Join(os.Getenv("TEST_SRCDIR"), "libvirt-libs-11.0.0-1.fc42.x86_64.rpm/rpm/downloaded"),
112+
rpm: libvirtLibsRpm,
97113
wantErr: false,
98114
files: []string{"/usr/lib64/libvirt.so.0"},
99115
expected: []fileInfo{
@@ -107,7 +123,7 @@ func TestTar2Files(t *testing.T) {
107123
},
108124
{
109125
name: "should extract multiple files from a tar archive",
110-
rpm: filepath.Join(os.Getenv("TEST_SRCDIR"), "libvirt-libs-11.0.0-1.fc42.x86_64.rpm/rpm/downloaded"),
126+
rpm: libvirtLibsRpm,
111127
wantErr: false,
112128
files: []string{
113129
"/etc/libvirt/libvirt-admin.conf",
@@ -125,7 +141,7 @@ func TestTar2Files(t *testing.T) {
125141
},
126142
{
127143
name: "should extract multiple files with the same name from a tar archive",
128-
rpm: filepath.Join(os.Getenv("TEST_SRCDIR"), "abseil-cpp-devel-20240722.1-1.fc42.x86_64.rpm/rpm/downloaded"),
144+
rpm: abseilCppDevelRpm,
129145
wantErr: false,
130146
files: []string{
131147
"/usr/include/absl/log/globals.h",

test_deps.bzl

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)