feather-rs / feather

A Minecraft server implementation in Rust
Apache License 2.0
2.58k stars 143 forks source link

Make it easy to test plugins, and Implement test suite for them. #481

Open Miro-Andrin opened 2 years ago

Miro-Andrin commented 2 years ago

Context

Currently there is no automated/easy way to test quill plugins. Making it hard to detect regressions. We need a way of easily compile multiple plugins and run them on a server. We also need a way for plugins to signal if something bad has happened.

I believe there are many layers to this issue, and that a good approach would be to split it up into some smaller improvements, that in them selves probably are a good idea, but that as a whole gives us the desired result.

Here is what i suggest. If you believe this is wrong, and a better approach exists, then do tell.
Is there a different route to a similar solution, or maybe some of this is already partly implemented?

Improve cargo-quill

I suggest adding a command to cargo quill that given a feather server (binary or source code directory) , and one or more plugins (either as a .plugin file or source code). Does the necessary compiling, moves the plugins into the correct spot, and starts the server. The command should support a flag for specifying if a native or wasm plugin should be generated.

Add sport for plugins to stop.

Add an api to plugins for them to signal that they are done . Basically a way for plugins to unload themselves, with a success or error code. Maybe even a short plugin message could be printed to the console.

Add a test mode

Finally we add a flag like --test-plugins to the server binary. If this flag is set, then the server starts every plugin, and runs them until all plugins have unloaded themselves. Finally printing what plugins ended in an error state.

With all of these steps combined it should be straight forward to create a script to automatically test plugins before merges.

ambeeeeee commented 2 years ago

(the main reason I wanted to revert was to fix code quality issues that just pushed me to actually do it instead of doing literally anything else like I had been)

I still agree with the idea!