You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.4 KiB

9 months ago
  1. .. _contributing:
  2. The Contributor Guide
  3. ========================
  4. Welcome to the Python Keycloak contributing guidelines. We are all more than happy to receive
  5. any contributions to the repository and want to thank you in advance for your contributions!
  6. This document outlines the process and the guidelines on how contributions work for this repository.
  7. Setting up the dev environment
  8. -------------------------------
  9. The development environment is mainly up to the developer. Our recommendations are to create a python
  10. virtual environment and install the necessary requirements. Example
  11. .. code-block:: console
  12. # Install and upgrade pip & poetry
  13. python -m pip install --upgrade pip poetry
  14. # Create virtualenv
  15. python -m poetry env use <PATH_TO_PYTHON_VERSION>
  16. # install package dependencies including dev dependencies
  17. python -m poetry install
  18. # Activate virtualenv
  19. python -m poetry shell
  20. Running checks and tests
  21. ---------------------------
  22. We're utilizing `tox` for most of the testing workflows. However we also have an external dependency on `docker`.
  23. We're using docker to spin up a local keycloak instance which we run our test cases against. This is to avoid
  24. a lot of unnecessary mocking and yet have immediate feedback from the actual Keycloak instance. All of the setup
  25. is done for you with the tox environments, all you need is to have both tox and docker installed
  26. (`tox` is included in the `dev-requirements.txt`).
  27. To run the unit tests, simply run
  28. .. code-block:: console
  29. tox -e tests
  30. The project is also adhering to strict linting (flake8) and formatting (black + isort). You can always check that
  31. your code changes adhere to the format by running
  32. .. code-block:: console
  33. tox -e check
  34. If the check fails, you'll see an error message specifying what went wrong. To simplify things, you can also run
  35. .. code-block:: console
  36. tox -e apply-check
  37. which will apply isort and black formatting for you in the repository. The flake8 problems however need to be resolved
  38. manually by the developer.
  39. Additionally we require that the documentation pages are built without warnings. This check is also run via tox, using
  40. the command
  41. .. code-block:: console
  42. tox -e docs
  43. The check is also run in the CICD pipelines. We require that the documentation pages built from the code docstrings
  44. do not create visually "bad" pages.
  45. Conventional commits
  46. ----------------------
  47. Commits to this project must adhere to the [Conventional Commits
  48. specification](https://www.conventionalcommits.org/en/v1.0.0/) that will allow
  49. us to automate version bumps and changelog entry creation.
  50. After cloning this repository, you must install the pre-commit hook for
  51. conventional commits (this is included in the `dev-requirements.txt`)
  52. .. code-block:: console
  53. # Create virtualenv
  54. python -m poetry env use <PATH_TO_PYTHON_VERSION>
  55. # Activate virtualenv
  56. python -m poetry shell
  57. pre-commit install --install-hooks -t pre-commit -t pre-push -t commit-msg
  58. How to contribute
  59. -------------------
  60. 1. Fork this repository, develop and test your changes
  61. 2. Make sure that your changes do not decrease the test coverage
  62. 3. Make sure you're commits follow the conventional commits
  63. 4. Submit a pull request
  64. How to release
  65. -------------------
  66. The CICD pipelines are set up for the repository. When a PR is merged, a new version of the library
  67. will be automatically deployed to the PyPi server, meaning you'll be able to see your changes immediately.