2024-03-27 21:49:44 +00:00
Contributions
=============
2020-11-05 16:51:59 +00:00
Contributions are welcome!
2023-03-10 08:24:16 +00:00
The repository is hosted at `gitlab.com/yaal/canaille <https://gitlab.com/yaal/canaille> `_ .
2023-07-17 14:57:54 +00:00
Discuss
-------
If you want to implement a feature or a bugfix, please start by discussing it with us on
the `bugtracker <https://gitlab.com/yaal/canaille/-/issues> `_ or the `matrix room
<https://matrix.to/#/#canaille-discuss:yaal.coop> `_.
2023-03-10 08:24:16 +00:00
Development environment
-----------------------
2024-11-07 11:02:02 +00:00
You can either run the demo locally or with Docker.
2024-11-07 10:59:00 +00:00
The only tool required for local development is `uv` .
Make sure to have uv `installed on your computer <https://docs.astral.sh/uv/getting-started/installation/> `_
to be able to hack Canaille.
2024-11-13 08:59:00 +00:00
Initialize your development environment with `` uv sync --all-extras `` .
2024-11-07 11:02:02 +00:00
Some dependencies of Canaille might need to be compiled, so you probably want to check that `GCC` and `cargo` are available on your computer.
2023-03-11 23:45:57 +00:00
After having launched the demo you have access to several services:
- A canaille server at `localhost:5000 <http://localhost:5000> `_
- A dummy client at `localhost:5001 <http://localhost:5001> `_
- Another dummy client at `localhost:5002 <http://localhost:5002> `_
The canaille server has some default users:
- A regular user which login and password are **user** ;
- A moderator user which login and password are **moderator** ;
- An admin user which admin and password are **admin** ;
- A new user which login is **james** . This user has no password yet,
and his first attempt to log-in would result in sending a password initialization
2024-03-28 13:24:35 +00:00
email (if a smtp server is configured).
2023-03-11 23:45:57 +00:00
2023-04-15 11:00:02 +00:00
Backends
~~~~~~~~
2023-11-15 15:37:06 +00:00
Canaille comes with several backends:
2023-04-15 11:00:02 +00:00
- a lightweight test purpose `memory` backend
2023-11-15 15:37:06 +00:00
- a `sql` backend, based on sqlalchemy
2023-04-15 11:00:02 +00:00
- a production-ready `LDAP` backend
2023-03-11 23:45:57 +00:00
Docker environment
~~~~~~~~~~~~~~~~~~
2023-04-15 11:00:02 +00:00
If you want to develop with docker, your browser needs to be able to reach the `canaille` container.
The docker-compose file exposes the right ports, but front requests are from outside the docker network:
the `canaille` url that makes sense for docker, points nowhere from your browser.
As exposed ports are on `localhost` , you need to tell your computer that `canaille` url means `localhost` .
2023-04-12 14:27:46 +00:00
To do that, you can add the following line to your `/etc/hosts` :
.. code-block :: console
127.0.0.1 canaille
To launch containers, use:
2023-03-11 23:45:57 +00:00
2023-03-10 08:24:16 +00:00
.. code-block :: console
2023-04-15 11:00:02 +00:00
cd demo
2023-11-15 15:37:06 +00:00
# To run the demo with the sql backend:
2023-04-15 11:00:02 +00:00
docker compose up
2023-11-15 15:37:06 +00:00
# To run the demo with the memory backend:
docker compose --file docker-compose-memory.yml up
2023-04-15 11:00:02 +00:00
# To run the demo with the LDAP backend:
docker compose --file docker-compose-ldap.yml up
2023-03-11 23:45:57 +00:00
Local environment
~~~~~~~~~~~~~~~~~
.. code-block :: console
2023-11-15 15:37:06 +00:00
# To run the demo with the sql backend:
2023-03-11 23:45:57 +00:00
./demo/run.sh
2022-11-21 16:45:11 +00:00
2023-11-15 15:37:06 +00:00
# To run the demo with the memory backend:
./demo/run.sh --backend memory
2023-04-15 11:00:02 +00:00
# To run the demo with the LDAP backend:
./demo/run.sh --backend ldap
2023-11-15 15:37:06 +00:00
.. note ::
If you want to run the demo locally with the LDAP backend, you need to have
2024-03-28 13:26:45 +00:00
`OpenLDAP <https://www.openldap.org/> `_ installed on your system.
It is generally shipped under the `` slapd `` or `` openldap `` package name.
2022-11-14 17:32:31 +00:00
2023-11-15 15:37:06 +00:00
.. warning ::
2022-11-15 14:15:16 +00:00
On Debian or Ubuntu systems, the OpenLDAP `slapd` binary usage might be restricted by apparmor,
and thus makes the tests and the demo fail. This can be mitigated by removing apparmor restrictions
on `slapd` .
2022-11-14 17:32:31 +00:00
.. code-block :: console
sudo apt install --yes apparmor-utils
sudo aa-complain /usr/sbin/slapd
2023-03-11 23:45:57 +00:00
Populate the database
~~~~~~~~~~~~~~~~~~~~~
2022-11-15 14:15:16 +00:00
2023-07-17 14:57:54 +00:00
The demo database comes populated with some random users and groups. If you need more, you can generate
users and groups with the `` populate `` command:
2022-11-15 14:15:16 +00:00
2023-03-11 23:45:57 +00:00
.. code-block :: console
2023-03-01 14:46:00 +00:00
2023-04-12 15:30:51 +00:00
# If using docker:
2024-10-28 08:01:52 +00:00
docker compose exec canaille env CONFIG=conf-docker/canaille-ldap.toml uv run canaille populate --nb 100 users # or docker-compose
2023-04-12 15:30:51 +00:00
# If running in local environment
2024-10-28 08:01:52 +00:00
env CONFIG=conf/canaille-ldap.toml uv run canaille populate --nb 100 users
2023-04-15 11:00:02 +00:00
2023-11-15 15:37:06 +00:00
Adapt to use either the `ldap` or the `sql` configuration file. Note that this will not work with the memory backend.
2020-11-06 10:44:25 +00:00
2023-03-10 08:24:16 +00:00
Unit tests
----------
2020-11-05 16:51:59 +00:00
2024-10-28 08:01:52 +00:00
To run the tests, you just can run `uv run pytest` and/or `uv run tox` to test all the supported python environments.
2023-04-15 11:00:02 +00:00
Everything must be green before patches get merged.
2023-11-15 15:37:06 +00:00
To test a specific backend you can pass `` --backend memory `` , `` --backend sql `` or `` --backend ldap `` to pytest and tox.
2020-11-06 10:44:25 +00:00
2023-03-10 08:24:16 +00:00
The test coverage is 100%, patches won't be accepted if not entirely covered. You can check the
2024-11-07 10:59:00 +00:00
test coverage with `` uv run pytest --cov --cov-report=html `` or `` uv run tox -e coverage -- --cov-report=html `` .
2023-08-17 12:39:50 +00:00
You can check the HTML coverage report in the newly created `htmlcov` directory.
2020-11-06 10:44:25 +00:00
2023-03-10 08:24:16 +00:00
Code style
----------
2020-11-12 08:30:39 +00:00
2024-03-28 11:03:20 +00:00
We use `ruff <https://docs.astral.sh/ruff/> `_ along with other tools to format our code.
2024-11-07 10:59:00 +00:00
Please run `` uv run tox -e style `` on your patches before submitting them.
2023-03-10 08:24:16 +00:00
In order to perform a style check and correction at each commit you can use our
2024-11-07 10:59:00 +00:00
`pre-commit <https://pre-commit.com/> `_ configuration with `` uv run pre-commit install `` .
2020-11-12 08:30:39 +00:00
2023-03-10 08:24:16 +00:00
Front
-----
2020-11-12 08:30:39 +00:00
2023-03-10 08:24:16 +00:00
The interface is built upon the `Fomantic UI <https://fomantic-ui.com/> `_ CSS framework.
The dynamical parts of the interface use `htmx <https://htmx.org/> `_ .
2020-11-12 08:30:39 +00:00
2023-03-10 08:24:16 +00:00
- Using Javascript in the interface is tolerated, but the whole website MUST be accessible
2023-04-15 11:00:02 +00:00
for browsers without Javascript support, and without any feature loss.
2023-03-10 08:24:16 +00:00
- Because of Fomantic UI we have a dependency to jQuery, however new contributions should
not depend on jQuery at all.
See the `related issue <https://gitlab.com/yaal/canaille/-/issues/130> `_ .
2024-03-28 13:22:07 +00:00
Translations
------------
2022-05-06 15:00:32 +00:00
2024-05-13 14:44:02 +00:00
.. include :: ../../canaille/translations/README.rst
2022-05-06 15:00:32 +00:00
Documentation
-------------
The documentation is generated when the tests run:
2024-03-28 13:24:21 +00:00
.. code-block :: bash
2022-05-06 15:00:32 +00:00
2022-11-15 14:15:16 +00:00
tox -e doc
2022-05-06 15:00:32 +00:00
2024-03-28 13:24:21 +00:00
You can also run sphinx by hand, that should be faster since it avoids the tox environment initialization:
.. code-block :: bash
sphinx-build doc build/sphinx/html
The generated documentation is located at `` build/sphinx/html `` .
2024-03-29 10:25:15 +00:00
Publish a new release
---------------------
2024-11-13 09:04:58 +00:00
1. Check that dependencies are up to date with `` uv sync --upgrade `` and update dependencies accordingly in separated commits;
2. Check that tests are still green for every supported python version, and that coverage is still at 100%, by running `` uv run tox `` ;
3. Check that the demo environments are still working, both the local and the Docker one;
4. Check that the :ref: `development/changelog:Release notes` section is correctly filled up;
5. Increase the version number in `` pyproject.toml `` ;
6. Commit with `` git commit `` ;
7. Build with `` uv build `` ;
8. Publish on test PyPI with `` uv publish --publish-url https://test.pypi.org/legacy/ `` ;
9. Install the test package somewhere with `` pip install --extra-index-url https://test.pypi.org/simple --upgrade canaille `` . Check that everything looks fine;
10. Publish on production PyPI `` uv publish `` ;
11. Tag the commit with `` git tag XX.YY.ZZ `` ;
12. Push the release commit and the new tag on the repository with `` git push --tags `` .