Skip to content
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

Merged
merged 3 commits into from
Sep 8, 2021

Conversation

markmandel
Copy link
Member

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

@markmandel markmandel added area/tests Unit tests, integration tests, anything to make sure things don't break kind/cleanup Refactoring code, fixing up documentation, etc area/build-tools Development tooling. labels Sep 2, 2021
@google-cla google-cla bot added the cla: yes label Sep 2, 2021
@github-actions github-actions bot added the size/s label Sep 2, 2021
@@ -47,7 +47,10 @@ version:
@echo $(package_version)

# Run all tests
test: ensure-build-image
test: ensure-build-image test-quilkin test-examples
Copy link
Member Author

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]
Copy link
Member Author

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.

Copy link
Collaborator

@XAMPPRocky XAMPPRocky Sep 2, 2021

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 the members field, which means it will be built as part of cargo build --workspace.
  • exclude = ["examples/quilkin-filter-example", ...], add it to the exclude field, which means it will not be built as part of cargo build --workspace, and you need to build it explicitly yourself.

Copy link
Member Author

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 = "../../" }
Copy link
Member Author

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?

Copy link
Collaborator

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.

})
}
}

Copy link
Member Author

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?

Copy link
Collaborator

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.

Copy link
Member Author

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.

@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 8db477dd-898b-4ca6-8c65-e11d3f8bea13

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/389/head:pr_389 && git checkout pr_389
cargo build

@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: e2d7317c-106c-44ad-acfc-78a3b29ac51c

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/389/head:pr_389 && git checkout pr_389
cargo build

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 = "../../" }
Copy link
Collaborator

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]
Copy link
Collaborator

@XAMPPRocky XAMPPRocky Sep 2, 2021

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 the members field, which means it will be built as part of cargo build --workspace.
  • exclude = ["examples/quilkin-filter-example", ...], add it to the exclude field, which means it will not be built as part of cargo build --workspace, and you need to build it explicitly yourself.

})
}
}

Copy link
Collaborator

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
@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 32bac2b1-18fd-4908-8407-c4482d0a6c5a

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/389/head:pr_389 && git checkout pr_389
cargo build

@markmandel markmandel mentioned this pull request Sep 2, 2021
3 tasks
Comment on lines +66 to +69
let greeting = self
.require_config(args.config)?
.deserialize::<Config, ProtoGreet>(self.name())?;
Ok(Box::new(Greet(greeting.greeting)))
Copy link
Collaborator

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

Copy link
Member Author

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. 👍🏻

@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 1c3df0c3-d462-44cf-a0c9-7546530da149

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/389/head:pr_389 && git checkout pr_389
cargo build

@markmandel markmandel merged commit e412049 into googleforgames:main Sep 8, 2021
@markmandel markmandel deleted the examples/filter-updates branch September 8, 2021 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-tools Development tooling. area/tests Unit tests, integration tests, anything to make sure things don't break cla: yes kind/cleanup Refactoring code, fixing up documentation, etc size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants