-
Notifications
You must be signed in to change notification settings - Fork 94
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
Update custom filter example and add CI #389
Update custom filter example and add CI #389
Conversation
@@ -47,7 +47,10 @@ version: | |||
@echo $(package_version) | |||
|
|||
# Run all tests | |||
test: ensure-build-image | |||
test: ensure-build-image test-quilkin test-examples |
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.
Split up quilkin tests from examples tests here into separate targets, in case someone only wants to test one at a time.
prost-build = "0.7" | ||
prost-build = "0.8" | ||
|
||
[workspace] |
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.
Had to add this [workspace]
field here, otherwise I would get the error:
Error during execution of
cargo metadata: error: current package believes it's in a workspace when it's not:
-- I'm not sure I really get cargo workspaces tbh, so if you have any feedback here, I would appreciate 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.
All cargo projects (even ones with one crate) are workspaces, starting from the Cargo.toml
and recursively throughout the directory. So if you have a project with multiple crates, cargo needs to figure out if it's part of the parent workspace, or if it's in a new workspace (this will determine what crates to build, where the target directory is, etc). One way to do that is to add [workspace]
in the Cargo.toml
, which is explicitly saying "This is the start of a new workspace". The other option is using the members
and exclude
fields in the parent Cargo.toml
's [workspace]
. I would probably add one of those fields to the parent instead, depending on how you want to build.
members = ["examples/quilkin-filter-example", ...]
, add it to themembers
field, which means it will be built as part ofcargo build --workspace
.exclude = ["examples/quilkin-filter-example", ...]
, add it to theexclude
field, which means it will not be built as part ofcargo build --workspace
, and you need to build it explicitly yourself.
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.
Thanks for the detailed explanation - that helped a lot!
I'm definitely leaning towards having it be seperate, and that way if you are developing against quilkin you don't have to process the example of every build and test.
I just tried using exclude
in quilkin/Cargo.toml
, and I'm still getting the error:
Error during execution of `cargo metadata`: error: current package believes it's in a workspace when it's not:
current: /home/markmandel/workspace/quilkin/examples/quilkin-filter-example/Cargo.toml
workspace: /home/markmandel/workspace/quilkin/Cargo.toml
this may be fixable by adding `examples/quilkin-filter-example` to the `workspace.members` array of the manifest located at: /home/markmandel/workspace/quilkin/Cargo.toml
Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
Seems like leaving [workspace]
in the example Cargo.toml
is the only way.
prost-types = "0.7" | ||
# If lifting this example, you will want to be explicit abou the Quilkin version, e.g. | ||
# quilkin = "0.2.0" | ||
quilkin = { path = "../../" } |
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 was the best way I could think of to ensure that the code stayed in sync. Is there a better way?
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.
I think this is reasonable. This code is never being published to crates.io, so using paths is totally fine.
}) | ||
} | ||
} | ||
|
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.
Should/could we using include_proto!
here instead? I tried it, and it wanted me to have tonic as a dependency, so I'm assuming that's why we avoided it in the example?
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.
I've no issue with using tonic
, if you depend on quilkin
, you already depend on tonic
indirectly.
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.
Agreed! Got it to work! Update coming soon.
cb6afde
to
57c27f9
Compare
Build Succeeded 🥳 Build Id: 8db477dd-898b-4ca6-8c65-e11d3f8bea13 To build this version:
|
Build Succeeded 🥳 Build Id: e2d7317c-106c-44ad-acfc-78a3b29ac51c To build this version:
|
prost-types = "0.7" | ||
# If lifting this example, you will want to be explicit abou the Quilkin version, e.g. | ||
# quilkin = "0.2.0" | ||
quilkin = { path = "../../" } |
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.
I think this is reasonable. This code is never being published to crates.io, so using paths is totally fine.
prost-build = "0.7" | ||
prost-build = "0.8" | ||
|
||
[workspace] |
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.
All cargo projects (even ones with one crate) are workspaces, starting from the Cargo.toml
and recursively throughout the directory. So if you have a project with multiple crates, cargo needs to figure out if it's part of the parent workspace, or if it's in a new workspace (this will determine what crates to build, where the target directory is, etc). One way to do that is to add [workspace]
in the Cargo.toml
, which is explicitly saying "This is the start of a new workspace". The other option is using the members
and exclude
fields in the parent Cargo.toml
's [workspace]
. I would probably add one of those fields to the parent instead, depending on how you want to build.
members = ["examples/quilkin-filter-example", ...]
, add it to themembers
field, which means it will be built as part ofcargo build --workspace
.exclude = ["examples/quilkin-filter-example", ...]
, add it to theexclude
field, which means it will not be built as part ofcargo build --workspace
, and you need to build it explicitly yourself.
}) | ||
} | ||
} | ||
|
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.
I've no issue with using tonic
, if you depend on quilkin
, you already depend on tonic
indirectly.
Update the custom filter example to the new API surface, and also setup CI so that it ensures that it always compiles against dev Quilkin, and therefore will stay in sync going forward. Next I want to block out pieces of code and inject them into our docs via mdbook when updating https://googleforgames.github.io/quilkin/main/book/filters/writing_custom_filters.html as well, rather than have them copy pasted. Work on googleforgames#373
57c27f9
to
c2b92b0
Compare
Build Succeeded 🥳 Build Id: 32bac2b1-18fd-4908-8407-c4482d0a6c5a To build this version:
|
let greeting = self | ||
.require_config(args.config)? | ||
.deserialize::<Config, ProtoGreet>(self.name())?; | ||
Ok(Box::new(Greet(greeting.greeting))) |
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 now out of sync with the doc, we'll need to update that to match
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.
That'll be my next job! I'll take a stab at pulling the code samples from this code directly as well via mdbook. 👍🏻
Build Succeeded 🥳 Build Id: 1c3df0c3-d462-44cf-a0c9-7546530da149 To build this version:
|
Update the custom filter example to the new API surface, and also setup CI so that it ensures that it always compiles against dev Quilkin, and therefore will stay in sync going forward.
Next I want to block out pieces of code and inject them into our docs via mdbook when updating https://googleforgames.github.io/quilkin/main/book/filters/writing_custom_filters.html as well, rather than have them copy pasted.
Work on #373