|
1 | | -# How to contribute |
2 | 1 |
|
3 | | -We welcome contributions from external contributors, and this document |
4 | | -describes how to merge code changes into this CodeEntropy. |
| 2 | +# Contributing to CodeEntropy |
| 3 | + |
| 4 | +We welcome contributions from the community to improve and extend CodeEntropy. This guide outlines how to get started, make changes, and submit them for review. |
| 5 | + |
| 6 | +--- |
5 | 7 |
|
6 | 8 | ## Getting Started |
7 | 9 |
|
8 | | -* Make sure you have a [GitHub account](https://github.com/signup/free). |
9 | | -* [Fork](https://help.github.com/articles/fork-a-repo/) this repository on GitHub. |
10 | | -* On your local machine, |
11 | | - [clone](https://help.github.com/articles/cloning-a-repository/) your fork of |
12 | | - the repository. |
| 10 | +1. **Create a GitHub account**: [Sign up here](https://github.com/signup/free). |
| 11 | +2. **Fork the repository**: [How to fork](https://help.github.com/articles/fork-a-repo/). |
| 12 | +3. **Clone your fork locally**: |
| 13 | + ```bash |
| 14 | + git clone https://github.com/YOUR_USERNAME/CodeEntropy.git |
| 15 | + cd CodeEntropy |
| 16 | + ``` |
| 17 | + |
| 18 | +4. **Create a virtual environment**: |
| 19 | + ```bash |
| 20 | + python -m venv codeentropy-dev |
| 21 | + source codeentropy-dev/bin/activate # Linux/macOS |
| 22 | + codeentropy-dev\Scripts\activate # Windows |
| 23 | + ``` |
| 24 | + |
| 25 | +5. **Install development dependencies**: |
| 26 | + ```bash |
| 27 | + pip install -e ".[testing,docs,pre-commit]" |
| 28 | + pre-commit install |
| 29 | + ``` |
| 30 | + |
| 31 | +--- |
13 | 32 |
|
14 | 33 | ## Making Changes |
15 | 34 |
|
16 | | -* Add some really awesome code to your local fork. It's usually a [good |
17 | | - idea](http://blog.jasonmeridth.com/posts/do-not-issue-pull-requests-from-your-master-branch/) |
18 | | - to make changes on a |
19 | | - [branch](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/) |
20 | | - with the branch name relating to the feature you are going to add. |
21 | | -* When you are ready for others to examine and comment on your new feature, |
22 | | - navigate to your fork of CodeEntropy on GitHub and open a [pull |
23 | | - request](https://help.github.com/articles/using-pull-requests/) (PR). Note that |
24 | | - after you launch a PR from one of your fork's branches, all |
25 | | - subsequent commits to that branch will be added to the open pull request |
26 | | - automatically. Each commit added to the PR will be validated for |
27 | | - mergability, compilation and test suite compliance; the results of these tests |
28 | | - will be visible on the PR page. |
29 | | -* If you're providing a new feature, you must add test cases and documentation. |
30 | | -* When the code is ready to go, make sure you run the test suite using pytest. |
31 | | -* When you're ready to be considered for merging, check the "Ready to go" |
32 | | - box on the PR page to let the CodeEntropy devs know that the changes are complete. |
33 | | - The code will not be merged until this box is checked, the continuous |
34 | | - integration returns checkmarks, |
35 | | - and multiple core developers give "Approved" reviews. |
36 | | - |
37 | | -# Additional Resources |
38 | | - |
39 | | -* [General GitHub documentation](https://help.github.com/) |
40 | | -* [PR best practices](http://codeinthehole.com/writing/pull-requests-and-other-good-practices-for-teams-using-github/) |
41 | | -* [A guide to contributing to software packages](http://www.contribution-guide.org) |
42 | | -* [Thinkful PR example](http://www.thinkful.com/learn/github-pull-request-tutorial/#Time-to-Submit-Your-First-PR) |
| 35 | +- **Use a feature branch**: |
| 36 | + ```bash |
| 37 | + git checkout -b 123-fix-levels |
| 38 | + ``` |
| 39 | + You cannot commit directly to `main` as this is a protected branch. |
| 40 | + |
| 41 | +- **Add your code**, documentation, and tests. All new features must include: |
| 42 | + - Unit tests |
| 43 | + - Documentation updates |
| 44 | + - Compliance with coding standards |
| 45 | + |
| 46 | +- **Run tests**: |
| 47 | + ```bash |
| 48 | + pytest -v |
| 49 | + pytest --cov CodeEntropy --cov-report=term-missing |
| 50 | + ``` |
| 51 | + |
| 52 | +- **Run pre-commit checks**: |
| 53 | + These ensure formatting, linting, and basic validations. |
| 54 | + ```bash |
| 55 | + pre-commit run --all-files |
| 56 | + ``` |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Submitting a Pull Request (PR) |
| 61 | + |
| 62 | +1. Push your branch to GitHub. |
| 63 | +2. Open a [pull request](https://help.github.com/articles/using-pull-requests/). |
| 64 | +3. Use the templated Pull Request template to fill out: |
| 65 | + - A summary of what the PR is doing |
| 66 | + - List all the changes that the PR is proposing |
| 67 | + - Add how these changes will impact the repository |
| 68 | +4. Ensure: |
| 69 | + - All tests pass |
| 70 | + - Pre-commit checks pass |
| 71 | + - Documentation is updated |
| 72 | + |
| 73 | +5. Your PR will be reviewed by core developers. At least one approval is required before merging. |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Running Tests |
| 78 | + |
| 79 | +- Full suite: |
| 80 | + ```bash |
| 81 | + pytest -v |
| 82 | + ``` |
| 83 | +- With coverage: |
| 84 | + ```bash |
| 85 | + pytest --cov CodeEntropy --cov-report=term-missing |
| 86 | + ``` |
| 87 | +- Specific module: |
| 88 | + ```bash |
| 89 | + pytest CodeEntropy/tests/test_CodeEntropy/test_levels.py |
| 90 | + ``` |
| 91 | +- Specific test: |
| 92 | + ```bash |
| 93 | + pytest CodeEntropy/tests/test_CodeEntropy/test_levels.py::test_select_levels |
| 94 | + ``` |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## Coding Standards |
| 99 | + |
| 100 | +We use **pre-commit hooks** to enforce style and quality: |
| 101 | + |
| 102 | +- **Black** for formatting |
| 103 | +- **Isort** for import sorting |
| 104 | +- **Flake8** for linting |
| 105 | +- **Pre-commit-hooks** for: |
| 106 | + - Large file detection |
| 107 | + - AST validity |
| 108 | + - Merge conflict detection |
| 109 | + - YAML/TOML syntax checks |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Continuous Integration (CI) |
| 114 | + |
| 115 | +All PRs trigger GitHub Actions to: |
| 116 | + |
| 117 | +- Run tests |
| 118 | +- Check style |
| 119 | +- Build documentation |
| 120 | +- Validate versioning |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Building Documentation |
| 125 | + |
| 126 | +Build locally: |
| 127 | +```bash |
| 128 | +cd docs |
| 129 | +make html |
| 130 | +``` |
| 131 | + |
| 132 | +View in browser: |
| 133 | +``` |
| 134 | +docs/build/html/index.html |
| 135 | +``` |
| 136 | +
|
| 137 | +Edit docs in: |
| 138 | +- `docs/science.rst` |
| 139 | +- `docs/developer_guide.rst` |
| 140 | +
|
| 141 | +--- |
| 142 | +
|
| 143 | +## Reporting Issues |
| 144 | +
|
| 145 | +Found a bug or want a feature? |
| 146 | +
|
| 147 | +1. Open an issue on GitHub. |
| 148 | +2. Include a clear description and input files if relevant. |
| 149 | +
|
| 150 | +--- |
| 151 | +
|
| 152 | +## Additional Resources |
| 153 | +
|
| 154 | +- [GitHub Docs](https://help.github.com/) |
| 155 | +- [PR Best Practices](http://codeinthehole.com/writing/pull-requests-and-other-good-practices-for-teams-using-github/) |
| 156 | +- [Contribution Guide](http://www.contribution-guide.org) |
| 157 | +- [Thinkful PR Tutorial](http://www.thinkful.com/learn/github-pull-request-tutorial/#Time-to-Submit-Your-First-PR) |
0 commit comments