Governance & Quality Gates
Relevant source files
The following files were used as context for generating this wiki page:
- README.md
- pyproject.toml
- src/flext_tests/_validator/_orchestration_parts/validator_part_02.py
- src/flext_tests/_validator/_markdown_parts/markdown_part_01.py
- src/flext_tests/_validator/tests.py
- src/flext_tests/_utilities/_make_parts/make_rendering_part_02.py
- src/flext_tests/_utilities/_make_parts/make_parsing_part_01.py
Governance and Quality Gates within the flext-tests infrastructure establish the canonical standards for code integrity, architectural boundaries, and ecosystem-wide validation. These gates are implemented through a combination of automated static analysis (validators), managed project configuration, and standardized make verbs that enforce thresholds for testing and documentation.
The system ensures that all contributions adhere to the "Engineering Law" defined in the project's orchestration layer, specifically targeting architectural layer hierarchy, forbidden testing patterns, and documentation accuracy.
Sources: README.md:28-31, src/flext_tests/_validator/_orchestration_parts/validator_part_02.py:28-111
Validation Infrastructure
The core of the quality gate system is the FlextTestsValidator, a facade that orchestrates multiple specialized scanners. It provides a unified interface to validate imports, types, architectural layers, and bypass pragmas across the codebase.
Orchestration Flow
The following diagram illustrates how the all validation method aggregates results from specific sub-validators:
The orchestration layer ensures that a failure in any single gate results in a global failure for the scan.
Sources: src/flext_tests/_validator/_orchestration_parts/validator_part_02.py:40-101
Quality Gate Selectors
The project uses make contract verbs to trigger specific quality gates.
| Verb | Purpose | Source Reference |
|---|---|---|
check | Static analysis and linting | README.md:31 |
test | Unit and integration execution | README.md:31 |
val | Architectural and ecosystem validation | README.md:31 |
docs | Documentation integrity and rendering | README.md:31 |
Architectural & Test Governance
Specific validators enforce strict rules regarding how code is written and how tests are implemented.
Test Pattern Restrictions
The FlextValidatorTests class detects violations of the FLEXT testing philosophy, specifically targeting "brittle" patterns that complicate long-term maintenance.
- TEST-001 (Monkeypatch): Flags usage of the
monkeypatchfixture in function parameters or attribute access. - TEST-002 (Mock Usage): Restricts the direct import and usage of
MockorMagicMockfromunittest.mock. - TEST-003 (Patch Decorator): Prohibits the use of the
@patchdecorator for function-level mocking.
Sources: src/flext_tests/_validator/tests.py:24-150
Markdown & Documentation Quality
Quality gates extend to documentation files to ensure that Python code blocks in Markdown remain valid and follow typing standards.
Documentation validation includes checking for from typing import Optional (forbidden in favor of modern syntax) and the usage of object as a type annotation.
Sources: src/flext_tests/_validator/_markdown_parts/markdown_part_01.py:38-154
Managed Project Configuration
Governance is enforced at the project level through managed sections in pyproject.toml. These sections are strictly controlled by flext_infra tools to ensure standardization across the ecosystem.
Enforced Tools & Thresholds
The project defines specific thresholds in pyproject.toml that must be met to pass quality gates:
- Coverage Threshold: The
fail_undervalue is set to 25% (as per the dev stage of the current module). - Linting (Ruff): All rules are selected (
select = ["ALL"]) with specific ignores for architectural compatibility. - Type Checking (Pyright/Mypy): Strict mode is enabled for the
srcdirectory. - Security (Bandit): Configured to scan
srcwhile excluding tests, with aMEDIUMseverity threshold.
Sources: pyproject.toml:132-135, pyproject.toml:340-348, pyproject.toml:500-505
Command Metadata Governance
The make system utilizes TOML headers inside Python files to promote them to executable commands. These headers are validated for structure and required fields.
The system requires specific keys in the TOML header (e.g., verb, what, summary) and validates that no executable Python body exists unless specifically intended for promoted scripts.
Sources: src/flext_tests/_utilities/_make_parts/make_parsing_part_01.py:20-65
Summary
The Governance & Quality Gates of flext-tests serve as the primary defensive layer for the codebase. By orchestrating architectural scanners, enforcing strict testing patterns (prohibiting mocks and monkeypatches), and managing project configurations through centralized infrastructure, the project maintains a "zero-debt baseline." This rigorous enforcement ensures that all extensions and utilities provided by the test infrastructure remain consistent and technically sound.