|
| 1 | +Developer Guide |
| 2 | +=============== |
| 3 | + |
| 4 | +CodeEntropy is open-source, and we welcome contributions from the wider community to help improve and extend its functionality. This guide walks you through setting up a development environment, running tests, submitting contributions, and maintaining coding standards. |
| 5 | + |
| 6 | +Getting Started for Developers |
| 7 | +------------------------------ |
| 8 | + |
| 9 | +Create a virtual environment:: |
| 10 | + |
| 11 | + python -m venv codeentropy-dev |
| 12 | + source codeentropy-dev/bin/activate # Linux/macOS |
| 13 | + codeentropy-dev\Scripts\activate # Windows |
| 14 | + |
| 15 | +Clone the repository:: |
| 16 | + |
| 17 | + git clone https://github.com/CCPBioSim/CodeEntropy.git |
| 18 | + cd CodeEntropy |
| 19 | + |
| 20 | +Install development dependencies:: |
| 21 | + |
| 22 | + pip install -e .[testing,docs,pre-commit] |
| 23 | + |
| 24 | +Running Tests |
| 25 | +------------- |
| 26 | + |
| 27 | +Run the full test suite:: |
| 28 | + |
| 29 | + pytest -v |
| 30 | + |
| 31 | +Run tests with code coverage:: |
| 32 | + |
| 33 | + pytest --cov CodeEntropy --cov-report=term-missing |
| 34 | + |
| 35 | +Run tests for a specific module:: |
| 36 | + |
| 37 | + pytest CodeEntropy/tests/test_CodeEntropy/test_levels.py |
| 38 | + |
| 39 | +Run a specific test:: |
| 40 | + |
| 41 | + pytest CodeEntropy/tests/test_CodeEntropy/test_levels.py::test_select_levels |
| 42 | + |
| 43 | +Coding Standards |
| 44 | +---------------- |
| 45 | + |
| 46 | +We use **pre-commit hooks** to maintain code quality and consistent style. To enable these hooks:: |
| 47 | + |
| 48 | + pre-commit install |
| 49 | + |
| 50 | +This ensures: |
| 51 | + |
| 52 | +- **Formatting** via ``black`` (`psf/black`) |
| 53 | +- **Import sorting** via ``isort`` with the ``black`` profile |
| 54 | +- **Linting** via ``flake8`` with ``flake8-pyproject`` |
| 55 | +- **Basic checks** via ``pre-commit-hooks``, including: |
| 56 | + |
| 57 | + - Detection of large added files |
| 58 | + - AST validity checks |
| 59 | + - Case conflict detection |
| 60 | + - Executable shebang verification |
| 61 | + - Merge conflict detection |
| 62 | + - TOML and YAML syntax validation |
| 63 | + |
| 64 | +To skip pre-commit checks for a commit:: |
| 65 | + |
| 66 | + git commit -n |
| 67 | + |
| 68 | +.. note:: |
| 69 | + |
| 70 | + Pull requests must pass all pre-commit checks before being merged. |
| 71 | + |
| 72 | +Continuous Integration (CI) |
| 73 | +--------------------------- |
| 74 | + |
| 75 | +CodeEntropy uses **GitHub Actions** to automatically: |
| 76 | + |
| 77 | +- Run all tests |
| 78 | +- Check coding style |
| 79 | +- Build documentation |
| 80 | +- Validate versioning |
| 81 | + |
| 82 | +Every pull request will trigger these checks to ensure quality and stability. |
| 83 | + |
| 84 | +Building Documentation |
| 85 | +---------------------- |
| 86 | + |
| 87 | +Build locally:: |
| 88 | + |
| 89 | + cd docs |
| 90 | + make html |
| 91 | + |
| 92 | +The generated HTML files will be in ``docs/build/html/``. Open ``index.html`` in your browser to view the documentation. |
| 93 | + |
| 94 | +Edit docs in the following directories: |
| 95 | + |
| 96 | +- ``docs/user_guide/`` |
| 97 | +- ``docs/developer_guide/`` |
| 98 | + |
| 99 | +Contributing Code |
| 100 | +----------------- |
| 101 | + |
| 102 | +Creating an Issue |
| 103 | +^^^^^^^^^^^^^^^^^ |
| 104 | + |
| 105 | +If you encounter bugs or want to request features: |
| 106 | + |
| 107 | +1. Open an issue on GitHub. |
| 108 | +2. Provide a clear description and input files if applicable. |
| 109 | + |
| 110 | +Branching |
| 111 | +^^^^^^^^^ |
| 112 | + |
| 113 | +- Never commit directly to ``main``. |
| 114 | +- Create a branch named after the issue:: |
| 115 | + |
| 116 | + git checkout -b 123-fix-levels |
| 117 | + |
| 118 | +Pull Requests |
| 119 | +^^^^^^^^^^^^^ |
| 120 | + |
| 121 | +1. Make your changes in a branch. |
| 122 | +2. Ensure tests and pre-commit checks pass. |
| 123 | +3. Submit a pull request. |
| 124 | +4. At least one core developer will review it. |
| 125 | +5. Include updated documentation and tests for new code. |
| 126 | + |
| 127 | +Summary |
| 128 | +------- |
| 129 | + |
| 130 | +Full developer setup:: |
| 131 | + |
| 132 | + git clone https://github.com/CCPBioSim/CodeEntropy.git |
| 133 | + cd CodeEntropy |
| 134 | + pip install -e .[testing,docs,pre-commit] |
| 135 | + pre-commit install |
| 136 | + pytest --cov CodeEntropy --cov-report=term-missing |
0 commit comments