|
| 1 | +# Contributing |
| 2 | + |
| 3 | +When contributing to this repository, you'll have more luck with getting PRs approved if you come chat with us in the |
| 4 | +Discord server and letting us know about what you are fixing/adding. |
| 5 | + |
| 6 | +## Pull Request Process |
| 7 | + |
| 8 | +1. Make sure all tests and lints pass. PRs that don't pass CI will be rejected if your code is the cause of the failing |
| 9 | +tests/lints. |
| 10 | +2. Make sure all needed files are also included and not using absolute paths. |
| 11 | +3. Include a sufficient explanation of your PR. What is it adding/fixing, why does this feature need to be added/fixed, |
| 12 | +who have you discussed this with, etc. If these questions were answered in a conversation on this Discord, mention who |
| 13 | +you talked with and what consensus was reached. Unexplained PRs will rarely be accepted. |
| 14 | +4. Check again that tests pass. |
| 15 | +5. Check a 3rd time. |
| 16 | +6. Submit PR. |
| 17 | + |
| 18 | +## Project specific guidelines |
| 19 | +Just some rules to try to keep the repo nice and organised |
| 20 | +### Branches |
| 21 | +#### `dev` |
| 22 | +This branch is the main branch. This is where all PRs should be made to. This branch is the most up to |
| 23 | +date and should only be merged into with completed features. |
| 24 | +#### `feature/feature-name` |
| 25 | +This branch is for developing a feature. Once the feature is complete, a PR should be |
| 26 | +made to the dev branch. This branch should be branched off of the dev branch. |
| 27 | +#### `fix/fixed-thing` |
| 28 | +This branch is for fixing a bug. Once the bug is fixed, a PR should be made to the dev |
| 29 | +branch. This branch should be branched off of the dev branch. |
| 30 | +#### `refactor/refactored-thing` |
| 31 | +This branch is for refactoring code. Once the code is refactored, a PR should be made to the dev branch. |
| 32 | +#### `housekeeping` |
| 33 | +This branch is for stuff relating to the repo itself. This could be updating the README, adding |
| 34 | +new CI checks, etc. This branch should be branched off of the dev branch. |
| 35 | +#### `docs` |
| 36 | +This branch is for updating the documentation. This branch should be branched off of the dev branch. |
| 37 | +This is used for stuff that doesn't actually modify the code, but the documentation. |
| 38 | + |
| 39 | +### Project Layout |
| 40 | +```text |
| 41 | ++---.etc | Non-code files |
| 42 | ++---.github | GitHub specific files |
| 43 | ++---assets | Assets for the Readme |
| 44 | ++---src | Source code |
| 45 | +| +---bin | The main binary that stitches everything together |
| 46 | +| +---lib | The libraries that provide the business logic |
| 47 | +| | +---adapters | Adapters and parsers for data formats |
| 48 | +| | +---core | The core logic of the application |
| 49 | +| | +---derive_macros | Derive macros. Split into directories for each macro |
| 50 | +| | +---ecs | The ECS system |
| 51 | +| | +---events | The event system |
| 52 | +| | +---net | Networking code |
| 53 | +| | +---plugins | Plugins interface |
| 54 | +| | +---storage | Storage backend |
| 55 | +| | +---utils | Utility functions |
| 56 | +| | \---world | Code for interacting with the world |
| 57 | +| \---tests | Unit tests |
| 58 | +``` |
| 59 | +If you add a new directory, please add it to the above list along with its purpose. |
| 60 | + |
| 61 | +### Code rules |
| 62 | +1. Tests that only generate/dump data must be `#[ignore]`d. These tests are not useful for CI and should not be run. |
| 63 | +2. No absolute paths. This will break the CI and make it harder to run the code on different machines. |
| 64 | +3. Try to avoid just chaining `../` to get to the root of the project. This makes it harder to move files around and work |
| 65 | +out where a referenced file is. There is a `root!()` macro that can be used to get the root of the project as a string. |
| 66 | +4. Don't be lazy and use `unwrap()`. If you are sure that a value will always be `Some`, use `expect()`. If you are not |
| 67 | +sure, use `match` or `if let`. |
| 68 | +5. New dependencies should be added to the workspace `Cargo.toml` file. This will make it easier to manage dependencies |
| 69 | +and will make sure that all dependencies are of the same version. |
| 70 | +6. If you are adding a new feature that warrants major separation, add it as a new crate and then include it in the |
| 71 | +workspace `Cargo.toml` file. This will make it easier to manage the code and will make sure that the code is well |
| 72 | +separated. |
| 73 | +7. If you are adding an extra sub-crate, you must create a new set of `thiserror` based error types for that crate. This |
| 74 | +will make it easier to understand where an error is coming from and will make it easier to handle errors. |
| 75 | +8. Use `cargo clippy` to check for any issues with the code. This will be checked in CI and will cause the build to fail |
| 76 | +if there are any issues. There is no excuse for *your* code to fail the lints. |
| 77 | +9. Use `#[expect(lint)]` instead of `#[allow(lint)]` if you are sure that the lint is not an issue. This will make it |
| 78 | +easier to find and remove these lints in the future. |
| 79 | +10. Use `#[cfg(test)]` to only include code in tests. This will make the code easier to read and understand. |
| 80 | +11. Where applicable, add doc strings to functions and modules. This will make it easier for others to understand the code. |
| 81 | +Check https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html for more information on how to write good |
| 82 | +documentation. |
| 83 | +12. Unsafe code is ok as long as it is well documented and the reason for the unsafe code is explained. If you are not sure |
| 84 | +if the code is safe, ask in the Discord. |
| 85 | +13. Limit the use of raw instructions as much as possible. This will make the code easier to read and understand. There |
| 86 | +are some cases where raw instructions are needed, but these should be kept to a minimum. |
| 87 | +14. You will be asked to fix your PR if folders like `.vscode` or `.idea` are included in the PR. These folders are |
| 88 | +specific to your IDE and should not be included in the PR. |
| 89 | +15. If you are adding a new feature, make sure to add tests for it. This will make sure that the feature works as expected |
| 90 | +and will help prevent regressions in the future. |
| 91 | +16. If you are fixing a bug, make sure to add a test that reproduces the bug. This will make sure that the bug is fixed |
| 92 | +and will help prevent regressions in the future. |
| 93 | +17. If your code isn't sufficiently documented, you will be asked to add documentation. |
| 94 | +18. If your code doesn't have tests where it should, you will be asked to add tests. |
| 95 | + |
| 96 | +## Code of Conduct |
| 97 | + |
| 98 | +Please note we have a code of conduct, please follow it in all your interactions with the project. |
| 99 | + |
| 100 | +## License |
| 101 | + |
| 102 | +By contributing, you agree that your contributions will be licensed under the project's license. |
| 103 | + |
| 104 | +### [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) |
0 commit comments