|
1 |
| -# Contributing |
| 1 | +# Contributing to `graphql-server` |
2 | 2 |
|
3 |
| -Thanks for helping to make graphql-server awesome! |
| 3 | +First off, thanks for taking the time to contribute! |
4 | 4 |
|
5 |
| -We welcome all kinds of contributions: |
| 5 | +The following is a set of guidelines for contributing to `graphql-server` on GitHub. |
| 6 | +These are mostly guidelines, not rules. Use your best judgment, and feel free |
| 7 | +to propose changes to this document in a pull request. |
6 | 8 |
|
7 |
| -- Bug fixes |
8 |
| -- Documentation improvements |
9 |
| -- New features |
10 |
| -- Refactoring & tidying |
| 9 | +#### Table of contents |
11 | 10 |
|
| 11 | +[How to contribute](#how-to-contribute) |
12 | 12 |
|
13 |
| -## Getting started |
| 13 | +- [Reporting bugs](#reporting-bugs) |
| 14 | +- [Suggesting enhancements](#suggesting-enhancements) |
| 15 | +- [Contributing to code](#contributing-to-code) |
14 | 16 |
|
15 |
| -If you have a specific contribution in mind, be sure to check the [issues](https://github.com/graphql-python/graphql-server/issues) and [pull requests](https://github.com/graphql-python/graphql-server/pulls) in progress - someone could already be working on something similar and you can help out. |
| 17 | +## How to contribute |
16 | 18 |
|
| 19 | +### Reporting bugs |
17 | 20 |
|
18 |
| -## Project setup |
| 21 | +This section guides you through submitting a bug report for `graphql-server`. |
| 22 | +Following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports. |
19 | 23 |
|
20 |
| -### Development with virtualenv (recommended) |
| 24 | +Before creating bug reports, please check |
| 25 | +[this list](#before-submitting-a-bug-report) to be sure that you need to create |
| 26 | +one. When you are creating a bug report, please include as many details as |
| 27 | +possible. Make sure you include the Python and `graphql-server` versions. |
21 | 28 |
|
22 |
| -After cloning this repo, create a virtualenv: |
| 29 | +> **Note:** If you find a **Closed** issue that seems like it is the same thing |
| 30 | +> that you're experiencing, open a new issue and include a link to the original |
| 31 | +> issue in the body of your new one. |
23 | 32 |
|
24 |
| -```console |
25 |
| -virtualenv graphql-server-dev |
26 |
| -``` |
| 33 | +#### Before submitting a bug report |
27 | 34 |
|
28 |
| -Activate the virtualenv and install dependencies by running: |
| 35 | +- Check that your issue does not already exist in the issue tracker on GitHub. |
29 | 36 |
|
30 |
| -```console |
31 |
| -python pip install -e ".[test]" |
32 |
| -``` |
| 37 | +#### How do I submit a bug report? |
33 | 38 |
|
34 |
| -If you are using Linux or MacOS, you can make use of Makefile command `make dev-setup`, which is a shortcut for the above python command. |
| 39 | +Bugs are tracked on the issue tracker on GitHub where you can create a new one. |
35 | 40 |
|
36 |
| -### Development on Conda |
| 41 | +Explain the problem and include additional details to help maintainers reproduce |
| 42 | +the problem: |
37 | 43 |
|
38 |
| -You must create a new env (e.g. `graphql-sc-dev`) with the following command: |
| 44 | +- **Use a clear and descriptive title** for the issue to identify the problem. |
| 45 | +- **Describe the exact steps which reproduce the problem** in as many details as |
| 46 | + possible. |
| 47 | +- **Provide specific examples to demonstrate the steps to reproduce the issue**. |
| 48 | + Include links to files or GitHub projects, or copy-paste-able snippets, which you use in those examples. |
| 49 | +- **Describe the behavior you observed after following the steps** and point out |
| 50 | + what exactly is the problem with that behavior. |
| 51 | +- **Explain which behavior you expected to see instead and why.** |
39 | 52 |
|
40 |
| -```sh |
41 |
| -conda create -n graphql-sc-dev python=3.8 |
42 |
| -``` |
| 53 | +Provide more context by answering these questions: |
43 | 54 |
|
44 |
| -Then activate the environment with `conda activate graphql-sc-dev`. |
| 55 | +- **Did the problem start happening recently** (e.g. after updating to a new version of `graphql-server`) or was this always a problem? |
| 56 | +- If the problem started happening recently, **can you reproduce the problem in |
| 57 | + an older version of `graphql-server`?** What's the most recent version in which the problem doesn't happen? |
| 58 | +- **Can you reliably reproduce the issue?** If not, provide details about how |
| 59 | + often the problem happens and under which conditions it normally happens. |
45 | 60 |
|
46 |
| -Proceed to install all dependencies by running: |
| 61 | +Include details about your configuration and environment: |
47 | 62 |
|
48 |
| -```console |
49 |
| -pip install -e ".[dev]" |
50 |
| -``` |
| 63 | +- **Which version of `graphql-server` are you using?** |
| 64 | +- **Which Python version `graphql-server` has been installed for?** |
| 65 | +- **What's the name and version of the OS you're using?** |
51 | 66 |
|
52 |
| -And you ready to start development! |
| 67 | +### Suggesting enhancements |
53 | 68 |
|
54 |
| -## Running tests |
| 69 | +This section guides you through submitting an enhancement suggestion for |
| 70 | +`graphql-server`, including completely new features and minor improvements to existing |
| 71 | +functionality. Following these guidelines helps maintainers and the community |
| 72 | +understand your suggestion and find related suggestions. |
55 | 73 |
|
56 |
| -After developing, the full test suite can be evaluated by running: |
| 74 | +Before creating enhancement suggestions, please check |
| 75 | +[this list](#before-submitting-an-enhancement-suggestion) as you might find out |
| 76 | +that you don't need to create one. When you are creating an enhancement |
| 77 | +suggestion, please |
| 78 | +[include as many details as possible](#how-do-i-submit-an-enhancement-suggestion). |
57 | 79 |
|
58 |
| -```sh |
59 |
| -pytest tests --cov=graphql-server -vv |
60 |
| -``` |
| 80 | +#### Before submitting an enhancement suggestion |
| 81 | + |
| 82 | +- Check that your issue does not already exist in the issue tracker on GitHub. |
61 | 83 |
|
62 |
| -If you are using Linux or MacOS, you can make use of Makefile command `make tests`, which is a shortcut for the above python command. |
| 84 | +#### How do I submit an enhancement suggestion? |
63 | 85 |
|
64 |
| -You can also test on several python environments by using tox. |
| 86 | +Enhancement suggestions are tracked on the project's issue tracker on GitHub |
| 87 | +where you can create a new one and provide the following information: |
65 | 88 |
|
66 |
| -### Running tox on virtualenv |
| 89 | +- **Use a clear and descriptive title** for the issue to identify the |
| 90 | + suggestion. |
| 91 | +- **Provide a step-by-step description of the suggested enhancement** in as many |
| 92 | + details as possible. |
| 93 | +- **Provide specific examples to demonstrate the steps**. |
| 94 | +- **Describe the current behavior** and **explain which behavior you expected to |
| 95 | + see instead** and why. |
67 | 96 |
|
68 |
| -Install tox: |
| 97 | +### Contributing to code |
69 | 98 |
|
70 |
| -```console |
71 |
| -pip install tox |
| 99 | +> This section is about contributing to |
| 100 | +[`graphql-server`](https://github.com/graphql-python/`graphql-server`). |
| 101 | + |
| 102 | +#### Local development |
| 103 | + |
| 104 | +You will need `uv` to start contributing to `graphql-server`. Refer to the |
| 105 | +[documentation](https://docs.astral.sh/uv/) to start using `uv`. |
| 106 | + |
| 107 | +You will first need to clone the repository using `git` and place yourself in |
| 108 | +its directory: |
| 109 | + |
| 110 | +```shell |
| 111 | +$ git clone [email protected]:graphql-python/ `graphql-server`.git |
| 112 | +$ cd `graphql-server` |
72 | 113 | ```
|
73 | 114 |
|
74 |
| -Run `tox` on your virtualenv (do not forget to activate it!) and that's it! |
| 115 | +Now, you will need to install the required dependencies for ``graphql-server`` and be sure |
| 116 | +that the current tests are passing on your machine: |
75 | 117 |
|
76 |
| -### Running tox on Conda |
| 118 | +```shell |
| 119 | +$ uv sync --group integrations |
| 120 | +``` |
77 | 121 |
|
78 |
| -In order to run `tox` command on conda, install |
79 |
| -[tox-conda](https://github.com/tox-dev/tox-conda): |
| 122 | +Some tests are known to be inconsistent. (The fix is in progress.) These tests are marked with the `pytest.mark.flaky` marker. |
80 | 123 |
|
81 |
| -```sh |
82 |
| -conda install -c conda-forge tox-conda |
| 124 | +`graphql-server` uses the [black](https://github.com/ambv/black) coding style and you |
| 125 | +must ensure that your code follows it. If not, the CI will fail and your Pull Request will not be merged. |
| 126 | + |
| 127 | +To make sure that you don't accidentally commit code that does not follow the |
| 128 | +coding style, you can install a pre-commit hook that will check that everything |
| 129 | +is in order: |
| 130 | + |
| 131 | +```shell |
| 132 | +$ uv run pre-commit install |
83 | 133 | ```
|
84 | 134 |
|
85 |
| -This install tox underneath so no need to install it before. |
| 135 | +Your code must always be accompanied by corresponding tests. If tests are not |
| 136 | +present, your code will not be merged. |
| 137 | + |
| 138 | +#### Pull requests |
| 139 | + |
| 140 | +- Be sure that your pull request contains tests that cover the changed or added |
| 141 | + code. |
| 142 | +- If your changes warrant a documentation change, the pull request must also |
| 143 | + update the documentation. |
| 144 | + |
| 145 | +##### RELEASE.md files |
86 | 146 |
|
87 |
| -Then uncomment the `requires = tox-conda` line on `tox.ini` file. |
| 147 | +When you submit a PR, make sure to include a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI! |
| 148 | + |
| 149 | +So as soon as your PR is merged, a release will be made. |
| 150 | + |
| 151 | +Here's an example of RELEASE.md: |
| 152 | + |
| 153 | +```text |
| 154 | +Release type: patch |
| 155 | +
|
| 156 | +Description of the changes, ideally with some examples, if adding a new feature. |
| 157 | +``` |
88 | 158 |
|
89 |
| -Run `tox` and you will see all the environments being created and all passing tests. :rocket: |
| 159 | +Release type can be one of patch, minor or major. We use [semver](https://semver.org/), so make sure to pick the appropriate type. If in doubt feel free to ask :) |
0 commit comments