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.
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.
Looks like this doesn't format nicely. Try s/-/*/?
There was a problem hiding this comment.
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 |
rockwotj
left a comment
There was a problem hiding this comment.
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
| workspace(name = "proto_gen_firebase_rules") | ||
|
|
||
| protobuf_commit = "099d99759101c295244c24d8954ec85b8ac65ce3" | ||
| load(":bazel/repositories.bzl", "protobuf_rules_gen_repositories") |
There was a problem hiding this comment.
//bazel:repositories.bzl should work and be a more canonical style
firebase_rules_generator/BUILD
Outdated
|
|
||
| cc_proto_library( | ||
| name = "firebase_rules_options", | ||
| visibility = ["//visibility:public"], |
There was a problem hiding this comment.
Do this libraries need to be public? If anything this should be restricted to this project only.
There was a problem hiding this comment.
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.
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.
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.
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
rockwotj
left a comment
There was a problem hiding this comment.
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.
nit: "//example/testdata:golden.rules",
BUILD
Outdated
| "$(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.
"$(location //example/testdata:golden.rules)",
firebase_rules_generator/BUILD
Outdated
|
|
||
| cc_proto_library( | ||
| name = "firebase_rules_options", | ||
| visibility = ["//visibility:public"], |
There was a problem hiding this comment.
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.
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: