Download the PHP package mottaviani-dev/laravel-reductor without Composer
On this page you can find all versions of the php package mottaviani-dev/laravel-reductor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mottaviani-dev/laravel-reductor
More information about mottaviani-dev/laravel-reductor
Files in mottaviani-dev/laravel-reductor
Package laravel-reductor
Short Description ML-powered test suite optimization for Laravel - Reduce CI/CD time by identifying redundant tests
License MIT
Homepage https://github.com/mottaviani-dev/laravel-reductor
Informations about the package laravel-reductor
Laravel Reductor
A powerful Laravel package for detecting and reducing test redundancy using machine learning clustering algorithms. Reductor analyzes your test suite to identify similar tests that provide overlapping coverage, helping you maintain a leaner, more efficient test suite.
Features
- ML-Powered Analysis: Uses advanced clustering algorithms (DBSCAN, Hierarchical, K-means) to identify redundant tests
- Coverage-Based Detection: Analyzes code coverage patterns to find tests with similar execution paths
- Semantic Understanding: Combines coverage analysis with semantic similarity of test code
- Safety Validation: Prevents merging of semantically opposing tests (e.g., success vs failure tests)
- Multiple Output Formats: Markdown (default), JSON, YAML, and HTML reports
- IDF-Weighted Coverage: Uses Inverse Document Frequency to emphasize unique coverage patterns
- Configurable Thresholds: Adjust similarity thresholds to control reduction aggressiveness
Installation
-
Install the package via Composer:
-
Publish the configuration file:
-
Run migrations to create the necessary database tables:
- Ensure Python 3.8+ is installed with required packages (alpine based images):
Quick Start
1. Generate Coverage Data
First, generate PHPUnit coverage in text format:
2. Ingest Coverage Data
Import the coverage data into Reductor:
This will output a test run ID that you'll use for analysis.
3. Analyze for Redundancy
Run the redundancy detection (K-Means algorithm and Markdown output are defaults):
Usage Examples
Basic Usage with Different Algorithms
Output Formats
Adjusting Similarity Thresholds
Combined Options
Configuration
Edit config/reductor.php to customize default settings:
Understanding the Algorithms
K-means (Default)
- Centroid-based clustering that automatically finds optimal number of clusters
- Most validated algorithm in research literature (35% of studies)
- Fast and deterministic with consistent results across runs
- Works well when test clusters have similar sizes
DBSCAN
- Density-based clustering that can identify noise points and outliers
- Good for varied density when test clusters have very different sizes
- Adaptive parameters based on dataset characteristics
Hierarchical Clustering
- Structure-aware clustering that builds a tree of clusters
- Useful for understanding hierarchical relationships between test groups
- Good alternative when you need dendrogram visualization
Interpreting Results
Redundancy Scores
- 95-100%: Nearly identical tests - safe to remove
- 85-95%: Very similar tests - review recommended
- 70-85%: Related tests - manual review required
- Below 70%: Different tests - keep both
Priority Levels
- High: Tests with >90% similarity in large clusters
- Medium: Tests with 70-90% similarity
- Low: Tests with <70% similarity or small clusters
Coverage Overlap
- Shows percentage of shared code coverage between tests
- 100% overlap doesn't always mean redundant (different assertions possible)
- Combined with semantic similarity for accurate detection
Advanced Features
Safety Validation
Reductor automatically prevents merging tests with opposing semantics:
- Success vs Failure tests
- Valid vs Invalid tests
- Create vs Delete operations
- Authorized vs Unauthorized tests
IDF-Weighted Coverage
Lines covered by many tests are weighted less than unique coverage patterns, improving discrimination between tests that share common initialization code.
Dimensionality Reduction
Automatically reduces high-dimensional vectors (640D) to manageable size (128D) while preserving 95%+ variance for accurate clustering.
Troubleshooting
"Pipeline failed" Error
- Check Python is installed:
python3 --version - Verify ML dependencies:
pip list | grep -E "scikit-learn|numpy" - Check logs:
tail -50 storage/logs/laravel.log
Poor Clustering Results
- Ensure coverage data is comprehensive
- Try different algorithms (DBSCAN or Hierarchical)
- Adjust threshold based on your needs
- Check for semantic vector issues (all zeros)
Example Output (Markdown)
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-reductor with dependencies
illuminate/support Version ^9.0|^10.0|^11.0
illuminate/console Version ^9.0|^10.0|^11.0
illuminate/database Version ^9.0|^10.0|^11.0
phpunit/php-code-coverage Version ^10.1|^11.0
czproject/git-php Version ^4.2
symfony/process Version ^6.0|^7.0
symfony/yaml Version ^6.0|^7.0