Skip to content

CONTRIBUTING.md adding coding guidelines #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 49 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,44 @@ And you ready to start development!

<!-- TODO: Provide environment.yml file for conda env -->

## Coding guidelines

Several tools are used to ensure a coherent coding style.
You need to make sure that your code satisfy those requirements
or the automated tests will fail.

- [black code formatter](https://github.com/psf/black)
- [flake8 style enforcement](https://flake8.pycqa.org/en/latest/index.html)
- [mypy static type checker](http://mypy-lang.org/)
- [isort to sort imports alphabetically](https://isort.readthedocs.io/en/stable/)

On Linux or MacOS, you can fix and check your code style by running
the Makefile command `make check` (this is also checked by running
the automated tests with tox but it is much faster with make)

In addition to the above checks, it is asked that:

- [type hints are used](https://docs.python.org/3/library/typing.html)
- tests are added to ensure complete code coverage

## Running tests

After developing, the full test suite can be evaluated by running:

```sh
pytest tests --cov=gql -vv
pytest tests --cov=gql --cov-report=term-missing -vv
```

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.
Please note that some tests which require external online resources are not
done in the automated tests. You can run those tests by running:

```sh
pytest tests --cov=gql --cov-report=term-missing --run-online -vv
```

If you are using Linux or MacOS, you can make use of Makefile commands
`make tests` and `make all_tests`, which are shortcuts for the above
python commands.

You can also test on several python environments by using tox.

Expand All @@ -91,7 +119,24 @@ conda install -c conda-forge tox-conda

This install tox underneath so no need to install it before.

Then uncomment the `requires = tox-conda` line on `tox.ini` file.
Then add the line `requires = tox-conda` in the `tox.ini` file under `[tox]`.

Run `tox` and you will see all the environments being created
and all passing tests. :rocket:

## How to create a good Pull Request

1. Make a fork of the master branch on github
2. Clone your forked repo on your computer
3. Create a feature branch `git checkout -b feature_my_awesome_feature`
4. Modify the code
5. Verify that the [Coding guidelines](#coding-guidelines) are respected
6. Verify that the [automated tests](#running-tests) are passing
7. Make a commit and push it to your fork
8. From github, create the pull request. Automated tests from travis
and coveralls will then automatically run the tests and check the code coverage
9. If other modifications are needed, you are free to create more commits and
push them on your branch. They'll get added to the PR automatically.

Once the Pull Request is accepted and merged, you can safely
delete the branch (and the forked repo if no more development is needed).