Major refactoring cleanup: - Add new controller architecture (class-controller-*.php) - Add new settings-v2 UI (views/settings-v2/) - Add new CSS architecture (agentic-sidebar.css, tokens) - Add esbuild build pipeline (scripts/build.js, package.json) - Add composer dependencies (vendor/) - Add frontend src directory (assets/js/src/index.jsx) - Add documentation files - Remove old/obsolete files (class-settings.php, old CSS) This commits all pending changes from previous refactoring efforts.
32 lines
1.0 KiB
PHP
Executable File
32 lines
1.0 KiB
PHP
Executable File
<?php
|
|
// based on https://ocramius.github.io/blog/automated-code-coverage-check-for-github-pull-requests-with-travis/
|
|
$inputFile = __DIR__ . '/../build/logs/clover.xml';
|
|
$percentage = min(100, max(0, (int) $argv[1]));
|
|
|
|
if (!file_exists($inputFile)) {
|
|
throw new InvalidArgumentException('Invalid input file provided');
|
|
}
|
|
|
|
if (!$percentage) {
|
|
throw new InvalidArgumentException('An integer checked percentage must be given as parameter');
|
|
}
|
|
|
|
$xml = new SimpleXMLElement(file_get_contents($inputFile));
|
|
$metrics = $xml->xpath('//metrics');
|
|
$totalElements = 0;
|
|
$checkedElements = 0;
|
|
|
|
foreach ($metrics as $metric) {
|
|
$totalElements += (int) $metric['elements'];
|
|
$checkedElements += (int) $metric['coveredelements'];
|
|
}
|
|
|
|
$coverage = ($checkedElements / $totalElements) * 100;
|
|
|
|
if ($coverage < $percentage) {
|
|
echo 'Code coverage is ' . $coverage . '%, which is below the accepted ' . $percentage . '%' . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
echo 'Code coverage is ' . $coverage . '% - OK!' . PHP_EOL;
|