|
1 | 1 | # Contributing
|
2 | 2 |
|
3 | 3 | Welcome! As a [Jupyter](https://jupyter.org) project, we follow the [Jupyter contributor guide](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html).
|
| 4 | + |
| 5 | +Make sure to also follow [Project Jupyter's Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md) |
| 6 | +for a friendly and welcoming collaborative environment. |
| 7 | + |
| 8 | +This guide was adapted from the [contributing guide in the main `jupyterhub` repo.](https://github.com/jupyterhub/jupyterhub/blob/master/CONTRIBUTING.md) |
| 9 | + |
| 10 | +## Setting up a development environment |
| 11 | + |
| 12 | +JupyterHub requires Python >= 3.5. |
| 13 | + |
| 14 | +As a Python project, a development install of JupyterHub follows standard practices for installation and testing. |
| 15 | + |
| 16 | +Note: if you have Docker installed locally, you can run all of the subsequent commands inside of a container after you run the following initial commands: |
| 17 | + |
| 18 | +``` |
| 19 | +./ci/docker-ldap.sh |
| 20 | +docker run -v $PWD:/usr/local/src --workdir /usr/local/src --net=host --rm -it python:3.6 bash |
| 21 | +``` |
| 22 | + |
| 23 | +1. Do a development install with pip |
| 24 | + |
| 25 | + ```bash |
| 26 | + cd ldapauthenticator |
| 27 | + python3 -m pip install --editable . |
| 28 | + ``` |
| 29 | + |
| 30 | +1. Install the development requirements, |
| 31 | + which include things like testing tools |
| 32 | + |
| 33 | + ```bash |
| 34 | + python3 -m pip install -r dev-requirements.txt |
| 35 | + ``` |
| 36 | +1. Set up pre-commit hooks for automatic code formatting, etc. |
| 37 | + |
| 38 | + ```bash |
| 39 | + pre-commit install |
| 40 | + ``` |
| 41 | + |
| 42 | + You can also invoke the pre-commit hook manually at any time with |
| 43 | + |
| 44 | + ```bash |
| 45 | + pre-commit run |
| 46 | + ``` |
| 47 | + |
| 48 | +To clean up your development LDAP deployment, run: |
| 49 | +``` |
| 50 | +docker rm -f ldap |
| 51 | +``` |
| 52 | +
|
| 53 | +## Contributing |
| 54 | +
|
| 55 | +JupyterHub has adopted automatic code formatting so you shouldn't |
| 56 | +need to worry too much about your code style. |
| 57 | +As long as your code is valid, |
| 58 | +the pre-commit hook should take care of how it should look. |
| 59 | +You can invoke the pre-commit hook by hand at any time with: |
| 60 | +
|
| 61 | +```bash |
| 62 | +pre-commit run |
| 63 | +``` |
| 64 | + |
| 65 | +which should run any autoformatting on your code |
| 66 | +and tell you about any errors it couldn't fix automatically. |
| 67 | +You may also install [black integration](https://github.com/ambv/black#editor-integration) |
| 68 | +into your text editor to format code automatically. |
| 69 | + |
| 70 | +If you have already committed files before setting up the pre-commit |
| 71 | +hook with `pre-commit install`, you can fix everything up using |
| 72 | +`pre-commit run --all-files`. You need to make the fixing commit |
| 73 | +yourself after that. |
| 74 | + |
| 75 | +## Testing |
| 76 | + |
| 77 | +It's a good idea to write tests to exercise any new features, |
| 78 | +or that trigger any bugs that you have fixed to catch regressions. |
| 79 | + |
| 80 | +You can run the tests with: |
| 81 | + |
| 82 | +```bash |
| 83 | +pytest -v |
| 84 | +``` |
| 85 | + |
| 86 | +The tests live in `ldapauthenticator/tests`. |
| 87 | + |
| 88 | +When writing a new test, there should usually be a test of |
| 89 | +similar functionality already written and related tests should |
| 90 | +be added nearby. |
| 91 | + |
| 92 | +When in doubt, feel free to ask. |
0 commit comments