Skip to content

maykinmedia/config-checks

Repository files navigation

Version:0.1.0
Source:https://github.com/maykinmedia/config-checks
Keywords:Django, Maykin, health checks
PythonVersion:3.12, 3.13

Build status Code quality checks Ruff Coverage status Documentation Status

python-versions django-versions pypi-version

This library aims to standardise how health checks for Maykin Django applications are run. The checks are meant to validate that the configuration that is normally performed in the Admin or via django-setup-configuration is correct.

  • Python 3.12 or above
  • Django 4.2 or newer
pip install maykin-config-checks

Add maykin_config_checks to the Django INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "maykin_config_checks",
    ...
]

To have an API view that returns the results of the performed health checks, add the following to the urlpatterns:

from django.urls import path

from maykin_config_checks.api.views import HealthChecksView

urlpatterns = [
    ...
    path(
        "health-checks",
        HealthChecksView.as_view(
            checks_collector=my_checks_collector_fn
        ),
        name="health-checks",
    ),
]

Where my_checks_collector_fn is a Callable[[], Iterable[HealthCheck]]. It is used to retrieve which health checks should be performed by the view. You can also add the view multiple times to the urlpatters with different checks_collector arguments if you want to have multiple health check views that run different checks.

There is also a management command that can be used to run health checks from the CLI.

django-admin config_checks --checks-collector dotted.path.to.my_checks_collector_fn

To develop the library locally, use:

uv pip install -r pyproject.toml --all-extras

To run the test app, in the root of the repository run:

export DJANGO_SETTINGS_MODULE=testapp.settings
export PYTHONPATH=$PYTHONPATH:`pwd`

Then, you can run:

django-admin runserver

To run the tests without tox, you can do the following (from the root of the repository):

export DJANGO_SETTINGS_MODULE=testapp.settings
export PYTHONPATH=$PYTHONPATH:`pwd`
pytest tests

About

Library to help setup and run application configuration checks in Maykin projects

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors