-
Notifications
You must be signed in to change notification settings - Fork 12
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
Protobuf validation #130
Protobuf validation #130
Conversation
Note to self: we discussed this today. The idea is to get this to a state where it can be merged. The differential validation (comparing changes between two versions of packages) will not be finished or used. Instead, we will first focus on doing the simple validation (validating properties of the current candidate package). This should give us a lot of bang for our buck. The action plan here is as follows:
|
c7f0cc6
to
994fc83
Compare
For the time being, this will only be used to build informative lints.
Okay so my understanding for the required actions to merge this are:
So 4 & 5 are the most important "blockers" for me; The rest is more style oriented but i would be happy if they are equally adressed. Thank you! 😊 |
I wrote the documentation in #153 – feel free to specify (i added rule codes by the way, and now we have linkable urls to use in the violation reports). Also can we print the violations to stderr? |
In this PR, I am introducing the
validation
crate, which allows for validating some properties of protobuf files (and this, of buffrs packages).Functionality
Specifically, I am trying to validate:
lib.rs
(if library) ormain.rs
(if binary), and files with names matching those of the modules they represent.my_lib
, you'd expect the protobuf to publish types formy_lib
ormy_lib.submodule
.Implementation
The way this works is that I am using an existing protocol buffer parser, the
protobuf_parse
crate. I am then loading the parsed data into some custom types. This is a partially lossy operation, because there is some information that we do not care about (does not affect the validation process). I can do some simple validation based on this information already.Additionally, I am able to pull a previous version and run it through the same process and compare the previous version's parsed information with this version's parsed information. To do this, I am using the
diff-struct
crate, which allows me to generate a set of differences between two structs. With this information, I am then (somewhat easily) able to decide if there has been breaking changes.Samples
For example, currently (not all functionality is implemented) the file
books.proto
which looks like this:Will parse as this:
If I make some changes to the
Book
message, I can generate a diff output like this. It only includes things that are removed or changed (insertion counts as change).Try it out
You can play with it yourself. There are two CLI tools in the
validation
crate at the moment, which allow you to parse and diff arbitrary protocol buffer files. Note that not all functionality is implemented. Run these from within thevalidation
folder.Further ideas
This is a draft PR, feel free to look at it but understand that it is not quite ready for review.