-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add bazel macros for protobuf_rules_gen #29
Conversation
Hmm, I guess the CI is using an even older version of Bazel than I am. Should I update the rules to work with Bazel 0.9.0, or update the CI to use a newer version? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The emulators are versioned, check here: https://github.com/firebase/firebase-tools/blob/master/src/emulator/constants.js#L27 (although let's do that in another PR)
Can we also move all the *.bzl
files into a bazel
directory?
- firestore_rules_binary combines multiple .rules files (e.g. the auto | ||
generated rules with your ACLs that use them) | ||
- firestore_rules_library wraps up one or more .rules files so that a | ||
firestore_rules_binary can depend on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this doesn't format nicely. Try s/-/*/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping - these still aren't printing nicely.
I've been trying to write a test using the firestore emulator, but I'm having lots of problems with it. It seems flaky. The same test case will sometimes pass, sometimes time out, or sometimes return a permission denied error. |
Happy to take a look at a version that your experiencing flakiness with. The emulator should be robust! |
- Move bazel definitions to a subdirectory. - Update readme formatting.
https://github.com/ribrdb/protobuf-rules-gen/blob/emulator/example/rules_test.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! A few comments mostly on style. I'll try playing with the emulator tests when I can - hopefully after we merge this PR.
Last nit: can you add newlines to all these files you've added?
WORKSPACE
Outdated
@@ -1,17 +1,5 @@ | |||
workspace(name = "proto_gen_firebase_rules") | |||
|
|||
protobuf_commit = "099d99759101c295244c24d8954ec85b8ac65ce3" | |||
load(":bazel/repositories.bzl", "protobuf_rules_gen_repositories") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//bazel:repositories.bzl
should work and be a more canonical style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
firebase_rules_generator/BUILD
Outdated
@@ -37,5 +38,6 @@ cc_binary( | |||
|
|||
cc_proto_library( | |||
name = "firebase_rules_options", | |||
visibility = ["//visibility:public"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this libraries need to be public? If anything this should be restricted to this project only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of my workaround for #25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead do: package(default_visibility = ["//visibility:public"])
bazel/repositories.bzl
Outdated
url = "https://github.com/google/protobuf/archive/" + protobuf_commit + ".tar.gz", | ||
) | ||
|
||
native.new_http_archive( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? Can we depend on we'll know protos from above?
If we can't please leave a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird I couldn't get that to work before, but it seems to be fine now.
"google/protobuf/wrappers.proto", | ||
] | ||
|
||
def protobuf_rules_gen_repositories(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good pattern for deps is to allow someone to override them. See an example here: https://github.com/grpc/grpc/blob/master/bazel/grpc_deps.bzl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good almost there! Thanks for working through this with me.
BUILD
Outdated
"$(locations :testdata)", | ||
], | ||
data = [ | ||
"//example:testdata/golden.rules", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "//example/testdata:golden.rules",
BUILD
Outdated
@@ -15,9 +15,13 @@ py_test( | |||
"$(location @com_google_protobuf//:protoc)", | |||
"$(location //proto:firebase_rules_options_proto_file)", | |||
"$(location @com_google_protobuf//:descriptor_proto)", | |||
"$(location //example:example.rules)", | |||
"$(location //example:testdata/golden.rules)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"$(location //example/testdata:golden.rules)",
firebase_rules_generator/BUILD
Outdated
@@ -37,5 +38,6 @@ cc_binary( | |||
|
|||
cc_proto_library( | |||
name = "firebase_rules_options", | |||
visibility = ["//visibility:public"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead do: package(default_visibility = ["//visibility:public"])
- firestore_rules_binary combines multiple .rules files (e.g. the auto | ||
generated rules with your ACLs that use them) | ||
- firestore_rules_library wraps up one or more .rules files so that a | ||
firestore_rules_binary can depend on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping - these still aren't printing nicely.
Thank you for your contribution! |
Here's a first stab at adding the BUILD rules.
I'm not sure if you'd want to update the integration test to build using these rules or keep it completely separate.
I didn't include using the firestore emulator here. There's two reasons for that:
(https://firebase.google.com/docs/firestore/downloads/cloud-firestore-emulator.jar)
isn't versioned, so it would be problematic to download it in the WORKSPACE file.
Once the emulator jar is available I basically just use a jasmine_node_test and add this to start the emulator: