We welcome new contributions to xDEM that is still very much in expansion! Below is a guide to contributing to xDEM step by step, ensuring tests are passing and the documentation is updated.
The technical steps to contributing to xDEM are:
- Fork
GlacioHack/xdem
and clone your fork repository locally. - Set up the development environment (see section "Setup" below),
- Create a branch for the new feature or bug fix,
- Make your changes,
- Add or modify related tests in
tests/
(see section "Tests" below), - Add or modify related documentation in
doc/
(see section "Documentation" below), - Commit your changes,
- Run
pre-commit
separately if not installed as git hook (see section "Linting" below), - Push to your fork,
- Open a pull request from GitHub to discuss and eventually merge.
xDEM currently supports Python versions of 3.9 to 3.11 (see dev-environment.yml
for detailed dependencies), which are
tested in a continuous integration (CI) workflow running on GitHub Actions.
When you open a PR on xDEM, a single linting action and 9 test actions will automatically start, corresponding to all supported Python versions (3.9, 3.10 and 3.11) and OS (Ubuntu, Mac, Windows). The coverage change of the tests will also be reported by CoverAlls.
Clone the git repo and create a mamba
environment (see how to install mamba
in the mamba documentation):
git clone https://github.com/GlacioHack/xdem.git
cd xdem
mamba env create -f dev-environment.yml # Add '-n custom_name' if you want.
mamba activate xdem-dev # Or any other name specified above
At least one test per feature (in the associated tests/test_*.py
file) should be included in the PR, using pytest
(see existing tests for examples).
The structure of test modules and functions in tests/
largely mirrors that of the package modules and functions in xdem/
.
To run the entire test suite, run pytest
from the root of the repository:
pytest
Running pytest
will trigger a script that automatically downloads test data from https://github.com/GlacioHack/xdem-data used to run all tests.
If your changes need to be reflected in the documentation, update the related pages located in doc/source/
. The documentation is written in MyST markdown syntax, similar to GitHub's default Markdown (see MyST-NB for details).
To ensure that the documentation is building properly after your changes, if you are on Linux, you can run pytest tests/test_doc.py
, which is equivalent to building directly calling sphinx-build source/ build/html/
from the doc/
folder. On Windows and Mac, the documentation is not maintained, so you can wait to open the PR for it to be checked on Linux by the CI.
Install and run pre-commit
from the root of the repository (such as with mamba install pre-commit
, see pre-commit documentation for details),
which will use .pre-commit-config.yaml
to verify spelling errors, import sorting, type checking, formatting and linting:
pre-commit run --all
You can then commit and push those changes.
Optionally, pre-commit
can be installed as a git hook to ensure checks have to pass before committing.
That's it! If the tests and documentation are passing, or if you need help to make those work, you can open a PR.
We'll receive word of your PR as soon as it is opened, and should follow up shortly to discuss the changes, and eventually give approval to merge. Thank you so much for contributing!
The license (see LICENSE) applies to all contributions.