34 lines
915 B
PHP
34 lines
915 B
PHP
<?php
|
|
|
|
namespace App\Support\Release;
|
|
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
final class ReleaseReadinessGate
|
|
{
|
|
public function evaluate(): array
|
|
{
|
|
$required = config('release_readiness.required_artifacts', []);
|
|
$missing = [];
|
|
|
|
foreach ($required as $path) {
|
|
if (! File::exists(base_path($path))) {
|
|
$missing[] = $path;
|
|
}
|
|
}
|
|
|
|
$expiredFlags = [];
|
|
foreach ((new FeatureFlagRegistry())->all() as $flag) {
|
|
if ($flag->removalTarget !== null && strtotime($flag->removalTarget) !== false && strtotime($flag->removalTarget) < time()) {
|
|
$expiredFlags[] = $flag->key;
|
|
}
|
|
}
|
|
|
|
return [
|
|
'status' => empty($missing) && empty($expiredFlags) ? 'pass' : 'fail',
|
|
'missing_artifacts' => $missing,
|
|
'expired_flags' => $expiredFlags,
|
|
];
|
|
}
|
|
}
|