|
| 1 | +# Contributing to KVM Serial |
| 2 | + |
| 3 | +Firstly, thank you for taking the time to contribute! I really appreciate it. ❤️ |
| 4 | + |
| 5 | +This guide outlines how to contribute to the KVM Serial project, and helps ensure a smooth experience for everyone involved. |
| 6 | + |
| 7 | +If this project has been useful to you, please consider giving it a star. ⭐️ |
| 8 | + |
| 9 | +## Table of Contents |
| 10 | + |
| 11 | +- [Code of Conduct](#code-of-conduct) |
| 12 | +- [I Have a Question](#i-have-a-question) |
| 13 | +- [Getting Started](#getting-started) |
| 14 | +- [Development Setup](#development-setup) |
| 15 | +- [How to Contribute](#how-to-contribute) |
| 16 | +- [Reporting Bugs](#reporting-bugs) |
| 17 | +- [Pull Requests](#pull-requests) |
| 18 | +- [Testing](#testing) |
| 19 | +- [Documentation](#documentation) |
| 20 | + |
| 21 | +## Code of Conduct |
| 22 | + |
| 23 | +This project is committed to providing a welcoming and inclusive environment for all contributors. In summary: be decent to others in this space, act in good faith and assume good faith on others' parts, and conduct onself in a way which would be acceptable in the workplace. |
| 24 | + |
| 25 | +All participants should: |
| 26 | + |
| 27 | +- Be respectful and considerate in communications |
| 28 | +- Show empathy towards other community members |
| 29 | +- Accept constructive criticism gracefully |
| 30 | +- Focus on what is best for the project |
| 31 | + |
| 32 | +Unacceptable behavior includes: |
| 33 | + |
| 34 | +- Any conduct that would be inappropriate in a professional setting |
| 35 | +- Harassment of any kind |
| 36 | +- Discriminatory jokes and language |
| 37 | +- Personal or political attacks |
| 38 | +- Publishing others' private information |
| 39 | +- Trolling or insulting comments |
| 40 | + |
| 41 | +Violations should be reported to the project maintainer(s), who will take appropriate action. |
| 42 | + |
| 43 | +## I Have a Question |
| 44 | + |
| 45 | +Before asking a question: |
| 46 | + |
| 47 | +1. Read the [Home](index.md) page and any available documentation |
| 48 | +2. Search existing [Issues](https://github.com/sjmf/kvm-serial/issues) to see if your question has already been answered |
| 49 | +3. Search the internet for answers first: putting errors from the console into a search engine is a great place to start. |
| 50 | + |
| 51 | +If you still need clarification, please: |
| 52 | + |
| 53 | +- Open a [new issue](https://github.com/sjmf/kvm-serial/issues/new) |
| 54 | +- Provide as much context as possible: issues saying "it doesn't work", without further detail, will be closed saying "yes, it does". |
| 55 | +- Include relevant system information (OS, Python version, hardware details) |
| 56 | + |
| 57 | +## Getting Started |
| 58 | + |
| 59 | +### Forking the Repository |
| 60 | + |
| 61 | +You will need to fork the repository if you want to contribute via [Pull Request](#pull-requests). |
| 62 | +If that's you, read on! |
| 63 | + |
| 64 | +1. Fork the repository on GitHub |
| 65 | +2. Clone your fork locally: |
| 66 | + ```bash |
| 67 | + git clone https://github.com/your-username/kvm-serial.git |
| 68 | + cd kvm-serial |
| 69 | + ``` |
| 70 | +3. Add the canonical repository to pull upstream changes: |
| 71 | + ```bash |
| 72 | + git remote add upstream https://github.com/sjmf/kvm-serial.git |
| 73 | + ``` |
| 74 | + |
| 75 | +## Development Setup |
| 76 | + |
| 77 | +To develop the code, there's a few steps to get set up: |
| 78 | + |
| 79 | +1. **Python Environment**: Ensure you have Python 3.8+ installed |
| 80 | +2. **Install Dependencies and Dev Dependencies**: |
| 81 | + ```bash |
| 82 | + pip install -e . |
| 83 | + pip install '.[dev]' |
| 84 | + ``` |
| 85 | +3. **Install Pre-commit Hooks**: |
| 86 | + ```bash |
| 87 | + pre-commit install |
| 88 | + pre-commit run --all-files # Run pre-commit on all files (optional) |
| 89 | + ``` |
| 90 | + |
| 91 | +Pre-commit hooks help to ensure that any code contributed follows the code style (`black`). |
| 92 | + |
| 93 | +## How to Contribute |
| 94 | + |
| 95 | +Contributions are fab! I really appreciate your being interested in this project. A contribution might be a bug report, a suggestion for a feature enhancement, addressing an oversight in the documentation or test suite, or just a well-structured question about how to use this project e.g. in a way we've not seen before. |
| 96 | + |
| 97 | +If you're considering giving back in the form of a contribution, here's the best way to do that: |
| 98 | + |
| 99 | +### Reporting Bugs |
| 100 | + |
| 101 | +#### Before Submitting a Bug Report |
| 102 | + |
| 103 | +Please ensure you're using the latest version of the software and verify that the issue is actually a bug rather than a configuration problem or user error. Search through existing [bug reports](https://github.com/sjmf/kvm-serial/issues?q=is%3Aissue+label%3Abug) to see if someone else has already encountered the same problem. |
| 104 | + |
| 105 | +When preparing your bug report, collect comprehensive information about your system environment. This should include your Python version and operating system, details about your hardware setup (particularly the CH9329 device and any connected cameras), your serial port configuration, complete error messages with stack traces, and clear steps that reliably reproduce the issue. |
| 106 | + |
| 107 | +#### How to Submit a Bug Report |
| 108 | + |
| 109 | +Open a [new issue](https://github.com/sjmf/kvm-serial/issues/new) with a clear, descriptive title that summarizes the problem. Describe both what behavior you expected to see and what actually happened. The most valuable bug reports include step-by-step reproduction instructions that allow maintainers to recreate the issue on their own systems. Include all the system and configuration information you collected, as this context is often crucial for diagnosing the root cause. |
| 110 | + |
| 111 | +### Pull Requests |
| 112 | + |
| 113 | +#### Before Creating a Pull Request |
| 114 | + |
| 115 | +1. **Create an Issue First**: For significant changes, create an issue to discuss the approach |
| 116 | +2. **Fork and Branch**: Create a feature branch from `main` |
| 117 | +3. **Stay Updated**: Regularly sync with upstream: |
| 118 | + ```bash |
| 119 | + git fetch upstream |
| 120 | + git rebase upstream/main |
| 121 | + ``` |
| 122 | + |
| 123 | +#### Pull Request Guidelines |
| 124 | + |
| 125 | +1. **One Change Per PR**: Submit separate PRs for different features/fixes |
| 126 | +2. **Clear Description**: Explain what your PR does and why |
| 127 | +3. **Reference Issues**: Link to related issues with "Fixes #123" |
| 128 | +4. **Test Your Changes**: Ensure all tests pass |
| 129 | +5. **Follow Code Standards**: Use pre-commit hooks and linting |
| 130 | + |
| 131 | +### Commit Message Guidelines |
| 132 | + |
| 133 | +Examples: |
| 134 | + |
| 135 | +- `feat(video): add support for USB 3.0 cameras` |
| 136 | +- `fix(serial): handle port disconnection gracefully` |
| 137 | +- `docs(readme): update installation instructions` |
| 138 | + |
| 139 | +## Testing |
| 140 | + |
| 141 | +### Running Tests |
| 142 | + |
| 143 | +```bash |
| 144 | +# Run all tests |
| 145 | +python -m pytest |
| 146 | + |
| 147 | +# Run with coverage |
| 148 | +python -m pytest --cov=kvm_serial |
| 149 | + |
| 150 | +# Run specific test categories, e.g.: |
| 151 | +python -m pytest tests/kvm |
| 152 | +python -m pytest tests/backend |
| 153 | +``` |
| 154 | + |
| 155 | +### Writing Tests |
| 156 | + |
| 157 | +Tests should be placed in the `tests/` directory. When writing new tests, focus on covering both successful operations and error conditions, ensuring that external dependencies like hardware devices are properly mocked to prevent actual device access during testing. |
| 158 | + |
| 159 | +Follow established patterns in the existing test suite, particularly around the use of context managers for patching and the helper methods provided by the base test class. The test structure emphasizes isolation and repeatability, so each test should be able to run independently without relying on state from other tests. |
| 160 | + |
| 161 | +Always check that tests pass in concert with other tests: tests can modify the global import state of the test environment, which can result in interference for example where a test accidentally makes an import which can then no longer be patched. I've gone to some lengths to check that tests don't interfere with each other (or skip them where they do), but it's far too easy to write a test where this can occur! |
| 162 | + |
| 163 | +## Documentation |
| 164 | + |
| 165 | +Documentation improvements are always welcome. Good documentation contributions focus on the user experience, and often come from people who have recently worked through setup or usage scenarios themselves. |
| 166 | + |
| 167 | +When updating documentation, prioritise clarity and accuracy over comprehensiveness. Include practical examples where they help illustrate concepts, and always test any instructions or code examples you add to ensure they work as described. If you're documenting new features, consider including both basic usage examples and more advanced scenarios. |
| 168 | + |
| 169 | +Documentation should be updated whenever functionality changes. This includes not just user-facing features, but also development processes, testing procedures, and troubleshooting information. The goal is to reduce friction for both users and future contributors. |
| 170 | + |
| 171 | +## Legal Notice |
| 172 | + |
| 173 | +By contributing to this project, you agree that: |
| 174 | + |
| 175 | +- You have authored 100% of the contributed content |
| 176 | +- You have the necessary rights to the content |
| 177 | +- Your contribution may be provided under the project license |
| 178 | + |
| 179 | +## Questions? |
| 180 | + |
| 181 | +If you have questions about contributing, feel free to: |
| 182 | + |
| 183 | +- Open an [issue](https://github.com/sjmf/kvm-serial/issues/new) |
| 184 | +- Contact the maintainers |
| 185 | + |
| 186 | +Thank you for contributing to KVM Serial! 🎉 |
0 commit comments