Skip to content

use bazel 8 (bzlmod migration) #134

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

Merged
merged 33 commits into from
Dec 16, 2024
Merged
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 @@
7.x
8.x
10 changes: 5 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "go_binary", "go_library")
load("@gazelle//:def.bzl", "gazelle")

# gazelle:prefix github.com/fizzbee-io/fizzbee
gazelle(name = "gazelle")
Expand Down Expand Up @@ -29,9 +29,9 @@ go_library(
deps = [
"//lib",
"//modelchecker",
"//proto",
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"//proto:proto_go_proto",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//proto",
],
)

Expand Down
47 changes: 41 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
module(name = "fizzbee")

# Go with gazelle see https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md
bazel_dep(name = "rules_go", version = "0.46.0")
bazel_dep(name = "gazelle", version = "0.34.0")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.22.4")

# External go deps
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

# run "bazel mod tidy" to update these after updating go.mod
use_repo(
go_deps,
"com_github_golang_glog",
"com_github_huandu_go_clone",
"com_github_stretchr_testify",
"in_gopkg_yaml_v3",
"net_starlark_go",
"org_golang_google_protobuf",
"org_golang_x_sys",
)

# Proto
bazel_dep(name = "protobuf", version = "26.0")

# Python
bazel_dep(name = "rules_python", version = "1.0.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.12", is_default = True)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pypi",
python_version = "3.12",
requirements_lock = "//third_party:requirements_lock.txt",
)
use_repo(pip, "pypi")
3,918 changes: 3,880 additions & 38 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

143 changes: 0 additions & 143 deletions WORKSPACE

This file was deleted.

19 changes: 18 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
module github.com/fizzbee-io/fizzbee

go 1.22
go 1.22.4

require (
github.com/golang/glog v1.2.0
github.com/huandu/go-clone v0.0.0
github.com/stretchr/testify v1.8.4
go.starlark.net v0.0.0-20231121155337-90ade8b19d09
golang.org/x/sys v0.17.0
google.golang.org/protobuf v1.32.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
)

replace github.com/huandu/go-clone => github.com/jayaprabhakar/go-clone v0.0.0-20240501195431-177708839df4
28 changes: 28 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/jayaprabhakar/go-clone v0.0.0-20240501195431-177708839df4 h1:uMCO3aPy9IB0JJ6+T6WMZjSmvoAchQl2wvzO8VXa7iw=
github.com/jayaprabhakar/go-clone v0.0.0-20240501195431-177708839df4/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 h1:hzy3LFnSN8kuQK8h9tHl4ndF6UruMj47OqwqsS+/Ai4=
go.starlark.net v0.0.0-20231121155337-90ade8b19d09/go.mod h1:LcLNIzVOMp4oV+uusnpk+VU+SzXaJakUuBjoCSWH5dM=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
12 changes: 6 additions & 6 deletions lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "lib",
Expand All @@ -19,16 +19,16 @@ go_library(
importpath = "github.com/fizzbee-io/fizzbee/lib",
visibility = ["//visibility:public"],
deps = [
"//proto",
"@com_github_jayaprabhakar_go_clone//:go-clone",
"//proto:proto_go_proto",
"@com_github_huandu_go_clone//:go-clone",
"@in_gopkg_yaml_v3//:yaml_v3",
"@net_starlark_go//lib/math",
"@net_starlark_go//starlark",
"@net_starlark_go//starlarkstruct",
"@net_starlark_go//syntax",
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@org_golang_x_sys//cpu:go_default_library",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//proto",
"@org_golang_x_sys//cpu",
],
)

Expand Down
4 changes: 2 additions & 2 deletions lib/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package lib

import (
"encoding/json"
"github.com/jayaprabhakar/go-clone"
"sync"

"github.com/huandu/go-clone"
)

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


// Ensures Queue implements LinearCollection
var _ LinearCollection[interface{}] = (*(Stack[interface{}]))(nil)
14 changes: 6 additions & 8 deletions modelchecker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "modelchecker",
Expand All @@ -22,15 +22,13 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//lib",
"//proto",
"//proto:options",
"//proto:proto_go_proto",
"@com_github_golang_glog//:glog",
"@com_github_jayaprabhakar_go_clone//:go-clone",
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@com_github_huandu_go_clone//:go-clone",
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tekumara One reason I had to fork the cloning library was it was missing a feature to override pointer references.
huandu/go-clone#23

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still using your fork - see the replace statement in go.mod

I had to do it like this to make go.mod work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm assuming bazel honours this but admittedly I haven't tested this - is there a way to test this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it. Thanks.

"@net_starlark_go//starlark",
"@net_starlark_go//starlarkstruct",
"@net_starlark_go//syntax",
"@org_golang_google_protobuf//proto",
],
)

Expand All @@ -53,11 +51,11 @@ go_test(
embed = [":modelchecker"],
deps = [
"//lib",
"//proto",
"//proto:proto_go_proto",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
"@net_starlark_go//starlark",
"@net_starlark_go//syntax",
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
"@org_golang_google_protobuf//encoding/protojson",
],
)
10 changes: 6 additions & 4 deletions modelchecker/clonehelper.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package modelchecker

import (
"github.com/fizzbee-io/fizzbee/lib"
"github.com/jayaprabhakar/go-clone"
"go.starlark.net/starlark"
"reflect"
"unsafe"

"github.com/fizzbee-io/fizzbee/lib"
"github.com/huandu/go-clone"
"go.starlark.net/starlark"
)

func init() {
Expand All @@ -29,6 +30,7 @@ func init() {
}

const sizeOfPointers = unsafe.Sizeof((interface{})(0)) / unsafe.Sizeof(uintptr(0))

// interfaceData is the underlying data of an interface.
// As the reflect.Value's interfaceData method is deprecated,
// it may be broken in any Go release.
Expand All @@ -42,6 +44,7 @@ type interfaceData struct {
}

var typeOfInterface = reflect.TypeOf((*interface{})(nil)).Elem()

// forceClearROFlag clears all RO flags in v to make v accessible.
// It's a hack based on the fact that InterfaceData is always available on RO data.
// This hack can be broken in any Go version.
Expand Down Expand Up @@ -79,7 +82,6 @@ func parseReflectValue(v reflect.Value) interfaceData {
return *(*interfaceData)(ptr)
}


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) {
return func(allocator *clone.Allocator, old, new reflect.Value) {

Expand Down
Loading