Skip to content

Commit fb19e8a

Browse files
authored
use bazel 8 (bzlmod migration) (#134)
* set bazel version 7.x * . * . * . * . * . * . * . * . * . * . * add go.mod * replace huandu/go-clone * go_deps.from_file(go_mod = "//:go.mod") * building * bazel mod tidy * rename rules_go * rename bazel_gazelle * . * working * fix python * . * use python 3.12 * . * remove rules_proto * fix perf py_proto_library * . * Revert "." This reverts commit 6c130f3. * add graph_proto * add go.sum * . * fix so run gazelle works
1 parent e25f4f1 commit fb19e8a

15 files changed

+4021
-262
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.x
1+
8.x

BUILD

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
2-
load("@bazel_gazelle//:def.bzl", "gazelle")
1+
load("@rules_go//go:def.bzl", "go_binary", "go_library")
2+
load("@gazelle//:def.bzl", "gazelle")
33

44
# gazelle:prefix github.com/fizzbee-io/fizzbee
55
gazelle(name = "gazelle")
@@ -29,9 +29,9 @@ go_library(
2929
deps = [
3030
"//lib",
3131
"//modelchecker",
32-
"//proto",
33-
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
34-
"@org_golang_google_protobuf//proto:go_default_library",
32+
"//proto:proto_go_proto",
33+
"@org_golang_google_protobuf//encoding/protojson",
34+
"@org_golang_google_protobuf//proto",
3535
],
3636
)
3737

MODULE.bazel

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
1-
###############################################################################
2-
# Bazel now uses Bzlmod by default to manage external dependencies.
3-
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
4-
#
5-
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
6-
###############################################################################
1+
module(name = "fizzbee")
2+
3+
# Go with gazelle see https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md
4+
bazel_dep(name = "rules_go", version = "0.46.0")
5+
bazel_dep(name = "gazelle", version = "0.34.0")
6+
7+
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
8+
go_sdk.download(version = "1.22.4")
9+
10+
# External go deps
11+
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
12+
go_deps.from_file(go_mod = "//:go.mod")
13+
14+
# run "bazel mod tidy" to update these after updating go.mod
15+
use_repo(
16+
go_deps,
17+
"com_github_golang_glog",
18+
"com_github_huandu_go_clone",
19+
"com_github_stretchr_testify",
20+
"in_gopkg_yaml_v3",
21+
"net_starlark_go",
22+
"org_golang_google_protobuf",
23+
"org_golang_x_sys",
24+
)
25+
26+
# Proto
27+
bazel_dep(name = "protobuf", version = "26.0")
28+
29+
# Python
30+
bazel_dep(name = "rules_python", version = "1.0.0")
31+
32+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
33+
python.toolchain(python_version = "3.12", is_default = True)
34+
35+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
36+
pip.parse(
37+
hub_name = "pypi",
38+
python_version = "3.12",
39+
requirements_lock = "//third_party:requirements_lock.txt",
40+
)
41+
use_repo(pip, "pypi")

MODULE.bazel.lock

Lines changed: 3880 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE

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

go.mod

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
module github.com/fizzbee-io/fizzbee
22

3-
go 1.22
3+
go 1.22.4
4+
5+
require (
6+
github.com/golang/glog v1.2.0
7+
github.com/huandu/go-clone v0.0.0
8+
github.com/stretchr/testify v1.8.4
9+
go.starlark.net v0.0.0-20231121155337-90ade8b19d09
10+
golang.org/x/sys v0.17.0
11+
google.golang.org/protobuf v1.32.0
12+
gopkg.in/yaml.v3 v3.0.1
13+
)
14+
15+
require (
16+
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/pmezard/go-difflib v1.0.0 // indirect
18+
)
19+
20+
replace github.com/huandu/go-clone => github.com/jayaprabhakar/go-clone v0.0.0-20240501195431-177708839df4

go.sum

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
5+
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
6+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
7+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
8+
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
9+
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
10+
github.com/jayaprabhakar/go-clone v0.0.0-20240501195431-177708839df4 h1:uMCO3aPy9IB0JJ6+T6WMZjSmvoAchQl2wvzO8VXa7iw=
11+
github.com/jayaprabhakar/go-clone v0.0.0-20240501195431-177708839df4/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE=
12+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
13+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
14+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
15+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
16+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
17+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
18+
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 h1:hzy3LFnSN8kuQK8h9tHl4ndF6UruMj47OqwqsS+/Ai4=
19+
go.starlark.net v0.0.0-20231121155337-90ade8b19d09/go.mod h1:LcLNIzVOMp4oV+uusnpk+VU+SzXaJakUuBjoCSWH5dM=
20+
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
21+
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
22+
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
23+
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
24+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
25+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
26+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
27+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
28+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

lib/BUILD.bazel

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "lib",
@@ -19,16 +19,16 @@ go_library(
1919
importpath = "github.com/fizzbee-io/fizzbee/lib",
2020
visibility = ["//visibility:public"],
2121
deps = [
22-
"//proto",
23-
"@com_github_jayaprabhakar_go_clone//:go-clone",
22+
"//proto:proto_go_proto",
23+
"@com_github_huandu_go_clone//:go-clone",
2424
"@in_gopkg_yaml_v3//:yaml_v3",
2525
"@net_starlark_go//lib/math",
2626
"@net_starlark_go//starlark",
2727
"@net_starlark_go//starlarkstruct",
2828
"@net_starlark_go//syntax",
29-
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
30-
"@org_golang_google_protobuf//proto:go_default_library",
31-
"@org_golang_x_sys//cpu:go_default_library",
29+
"@org_golang_google_protobuf//encoding/protojson",
30+
"@org_golang_google_protobuf//proto",
31+
"@org_golang_x_sys//cpu",
3232
],
3333
)
3434

lib/stack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package lib
22

33
import (
44
"encoding/json"
5-
"github.com/jayaprabhakar/go-clone"
65
"sync"
6+
7+
"github.com/huandu/go-clone"
78
)
89

910
type Stack[T any] struct {
@@ -132,6 +133,5 @@ func (s *Stack[T]) MarshalJSON() ([]byte, error) {
132133
return json.Marshal(s.s)
133134
}
134135

135-
136136
// Ensures Queue implements LinearCollection
137137
var _ LinearCollection[interface{}] = (*(Stack[interface{}]))(nil)

modelchecker/BUILD.bazel

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "modelchecker",
@@ -22,15 +22,13 @@ go_library(
2222
visibility = ["//visibility:public"],
2323
deps = [
2424
"//lib",
25-
"//proto",
26-
"//proto:options",
25+
"//proto:proto_go_proto",
2726
"@com_github_golang_glog//:glog",
28-
"@com_github_jayaprabhakar_go_clone//:go-clone",
29-
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
30-
"@org_golang_google_protobuf//proto:go_default_library",
27+
"@com_github_huandu_go_clone//:go-clone",
3128
"@net_starlark_go//starlark",
3229
"@net_starlark_go//starlarkstruct",
3330
"@net_starlark_go//syntax",
31+
"@org_golang_google_protobuf//proto",
3432
],
3533
)
3634

@@ -53,11 +51,11 @@ go_test(
5351
embed = [":modelchecker"],
5452
deps = [
5553
"//lib",
56-
"//proto",
54+
"//proto:proto_go_proto",
5755
"@com_github_stretchr_testify//assert",
5856
"@com_github_stretchr_testify//require",
5957
"@net_starlark_go//starlark",
6058
"@net_starlark_go//syntax",
61-
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
59+
"@org_golang_google_protobuf//encoding/protojson",
6260
],
6361
)

modelchecker/clonehelper.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package modelchecker
22

33
import (
4-
"github.com/fizzbee-io/fizzbee/lib"
5-
"github.com/jayaprabhakar/go-clone"
6-
"go.starlark.net/starlark"
74
"reflect"
85
"unsafe"
6+
7+
"github.com/fizzbee-io/fizzbee/lib"
8+
"github.com/huandu/go-clone"
9+
"go.starlark.net/starlark"
910
)
1011

1112
func init() {
@@ -29,6 +30,7 @@ func init() {
2930
}
3031

3132
const sizeOfPointers = unsafe.Sizeof((interface{})(0)) / unsafe.Sizeof(uintptr(0))
33+
3234
// interfaceData is the underlying data of an interface.
3335
// As the reflect.Value's interfaceData method is deprecated,
3436
// it may be broken in any Go release.
@@ -42,6 +44,7 @@ type interfaceData struct {
4244
}
4345

4446
var typeOfInterface = reflect.TypeOf((*interface{})(nil)).Elem()
47+
4548
// forceClearROFlag clears all RO flags in v to make v accessible.
4649
// It's a hack based on the fact that InterfaceData is always available on RO data.
4750
// This hack can be broken in any Go version.
@@ -79,7 +82,6 @@ func parseReflectValue(v reflect.Value) interfaceData {
7982
return *(*interfaceData)(ptr)
8083
}
8184

82-
8385
func roleResolveCloneFn(refs map[string]*lib.Role, permutations map[lib.SymmetricValue][]lib.SymmetricValue, alt int) func(allocator *clone.Allocator, old reflect.Value, new reflect.Value) {
8486
return func(allocator *clone.Allocator, old, new reflect.Value) {
8587

0 commit comments

Comments
 (0)