-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example that reproduces proto issue
- Loading branch information
Showing
8 changed files
with
222 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/cloneable/rules_ent | ||
|
||
go 1.19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
||
proto_library( | ||
name = "user_settings_proto", | ||
srcs = ["user_settings.proto"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_proto_library( | ||
name = "user_settings_go_proto", | ||
importpath = "github.com/cloneable/rules_ent/example/protos", | ||
proto = ":user_settings_proto", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_library( | ||
name = "proto", | ||
embed = [":user_settings_go_proto"], | ||
importpath = "github.com/cloneable/rules_ent/example/protos", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
|
||
package user_settings; | ||
|
||
message UserSettings { | ||
bool color_blind = 1; | ||
AppLanguage lang = 2; | ||
} | ||
|
||
enum AppLanguage { | ||
ENGLISH = 0; | ||
FRENCH = 1; | ||
PORTUGUESE = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("//:defs.bzl", "go_ent_library") | ||
|
||
go_library( | ||
name = "schema", | ||
srcs = ["user.go"], | ||
importpath = "github.com/cloneable/rules_ent/example/schema", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//example/protos:proto", | ||
"@com_github_google_uuid//:uuid", | ||
"@io_entgo_ent//:ent", | ||
"@io_entgo_ent//schema/field", | ||
"@io_entgo_ent//schema/mixin", | ||
], | ||
) | ||
|
||
go_ent_library( | ||
name = "db", | ||
entities = [ | ||
"user", | ||
], | ||
gomod = "//:go_mod", | ||
importpath = "github.com/cloneable/rules_ent/example/db", | ||
schema = ":schema", | ||
visibility = ["//:__subpackages__"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package schema | ||
|
||
import ( | ||
"entgo.io/ent" | ||
"entgo.io/ent/schema/field" | ||
"entgo.io/ent/schema/mixin" | ||
"github.com/cloneable/rules_ent/example/protos" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type User struct { | ||
ent.Schema | ||
} | ||
|
||
func (User) Fields() []ent.Field { | ||
return []ent.Field{ | ||
field.UUID("id", uuid.UUID{}).Default(uuid.New), | ||
field.String("email").Unique(), | ||
field.Bytes("preferences").GoType(&protos.UserSettings{}), | ||
} | ||
} | ||
|
||
func (User) Mixin() []ent.Mixin { | ||
return []ent.Mixin{ | ||
mixin.Time{}, | ||
} | ||
} | ||
|
||
func (User) Edges() []ent.Edge { | ||
return []ent.Edge{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
""" Morf workspace dependencies """ | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
|
||
def install_workspace_dependencies(): | ||
""" Defines repositories for core rules sets | ||
""" | ||
|
||
# Open source license validations | ||
http_archive( | ||
name = "rules_license", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.3/rules_license-0.0.3.tar.gz", | ||
"https://github.com/bazelbuild/rules_license/releases/download/0.0.3/rules_license-0.0.3.tar.gz", | ||
], | ||
sha256 = "00ccc0df21312c127ac4b12880ab0f9a26c1cff99442dc6c5a331750360de3c3", | ||
) | ||
|
||
# Protobuf-related rules | ||
http_archive( | ||
name = "com_google_protobuf", | ||
sha256 = "9c0fd39c7a08dff543c643f0f4baf081988129a411b977a07c46221793605638", | ||
strip_prefix = "protobuf-3.20.3", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.20.3.tar.gz", | ||
"https://github.com/protocolbuffers/protobuf/archive/v3.20.3.tar.gz", | ||
], | ||
) | ||
|
||
http_archive( | ||
name = "rules_proto", | ||
sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d", | ||
strip_prefix = "rules_proto-4.0.0-3.20.0", | ||
urls = [ | ||
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0-3.20.0.tar.gz", | ||
], | ||
) | ||
|
||
# go-related rules | ||
http_archive( | ||
name = "io_bazel_rules_go", | ||
sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip", | ||
"https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip", | ||
], | ||
) | ||
|
||
http_archive( | ||
name = "bazel_skylib", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", | ||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", | ||
], | ||
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", | ||
) | ||
|
||
# gazelle | ||
http_archive( | ||
name = "bazel_gazelle", | ||
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz", | ||
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz", | ||
], | ||
) | ||
|
||
# buildifier | ||
http_archive( | ||
name = "com_github_bazelbuild_buildtools", | ||
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3", | ||
strip_prefix = "buildtools-4.2.2", | ||
urls = [ | ||
"https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz", | ||
], | ||
) |