Tests and quality checks
Ce contenu n’est pas encore disponible dans votre langue.
The CI runs these checks on every merge request that touches the code they cover. Run them on your machine first: a failure is quicker to fix before the push. The CI reference lists the jobs.
Pre-commit hooks
Section titled “Pre-commit hooks”The repository defines pre-commit hooks that run most of the checks below on the files of each commit: migrations, ruff, ESLint, the icon map, pixi.lock, safety and bandit. With pre-commit installed, set up the hooks once, from the root of the repository:
pre-commit installFrom api/:
# The whole suite, in parallel and in a random orderpixi run test
# One modulepixi run test madbot_api.core.tests.functional.workspaces
# In series, when a parallel failure is hard to readpixi run test-serialThe tests run in the dev environment, on an in-memory SQLite database. A production instance runs PostgreSQL: check raw SQL on PostgreSQL by hand.
Coverage
Section titled “Coverage”# Run the suite under coverage, then compare with the thresholdpixi run test-cov && pixi run cov-report
# Line-by-line report in htmlcov/pixi run test-cov && pixi run cov-htmlThe CI fails when the coverage drops below the threshold held in api/pyproject.toml ([tool.coverage.report] fail_under). The threshold only goes up. api/docs/test-coverage-plan.md describes the measured perimeter, the exclusions and the state of the effort.
Lint and format
Section titled “Lint and format”pixi run lintpixi run formatpixi run format-checkformat rewrites the files; format-check only reports, as the CI does. Run both lint and format-check: they are different checks, and the CI runs both.
Security
Section titled “Security”# Known vulnerabilities in the dependenciespixi run safety
# Insecure patterns in the codepixi run banditpixi run quality-check runs lint, format-check, bandit and safety in one go.
plugins_api
Section titled “plugins_api”plugin_api/ has its own pixi project and the same tasks. From plugin_api/:
pixi run lintpixi run format-checkpixi run safetypixi run banditClient
Section titled “Client”From client/:
# Unit tests (Jest)pnpm test
# End-to-end tests (Playwright), with or without the interfacepnpm e2epnpm e2e:ui
# Lint, with or without the automatic fixespnpm lintpnpm lint:fix
# Check that the icon map lists every icon in usepnpm icons:check
# Known vulnerabilities in the dependenciespnpm audit --audit-level=highThe client shows Material Design icons from a generated list, client/utils/mdiIcons.ts. An mdi-* icon missing from it is shown as a question mark: after adding an icon, run pnpm icons and commit the regenerated file.
Supply-chain protections
Section titled “Supply-chain protections”pnpm-workspace.yaml (in client/, at the root and in documentation/) sets pnpm’s supply-chain protections. Keep the copies in line.
- Release quarantine (
minimumReleaseAge): a version published less than a day ago is not installed. For an urgent security fix, add a commentedminimumReleaseAgeExcludeentry. - Trust policy (
trustPolicy: no-downgrade): an install fails when the trust evidence of a package weakens compared with its earlier releases. - Build scripts allow-list (
allowBuilds,strictDepBuilds): the install scripts of dependencies only run for the packages listed. When you add a dependency that needs one, approve it withpnpm approve-buildsand commit the configuration. - No exotic sub-dependencies (
blockExoticSubdeps): transitive dependencies come from the registry, not from Git or tarball URLs.
Never use dangerouslyAllowAllBuilds.
Documentation
Section titled “Documentation”From documentation/:
pnpm buildThe build fails on a broken internal link. See Write documentation.

