oportunidades 6
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-10 21:17:46 +02:00
parent 01405cbf8a
commit 20971d523f
126 changed files with 44362 additions and 3496 deletions
@@ -12,6 +12,34 @@ $target = portalQaEnvironment();
$app = require dirname(__DIR__).'/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
portalQaAssertTarget($target);
$directory = null;
// Laravel's CLI exception renderer may otherwise leave an unsuccessful harness at exit 0.
// Keep the last verified proof intact and invalidate only the QA readiness receipt.
set_exception_handler(static function (Throwable $error) use (&$directory, $target): void {
if (is_string($directory) && is_file($directory.'/command-failure.json')) {
$readiness = config('portal_profiles.proof_directory').'/readiness.json';
if (is_file($readiness)) {
copy($readiness, $directory.'/previous-readiness.json');
}
$failure = ['verified_at' => gmdate('c'), 'target' => $target,
'restore_verified' => false, 'files_verified' => false, 'qa_passed' => false,
'compatibility_verified' => false, 'active_writes' => 0,
'reason' => 'Latest QA backup/restore command failed; previous dated verified backups remain historical.',
'diagnostic' => $directory.'/command-failure.json'];
file_put_contents($readiness, json_encode($failure, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
file_put_contents(storage_path('app/private/investmoz-v2/portal-audit/profile-installation-backup-failure-qa.json'), json_encode($failure, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
}
try {
$pdo = DB::connection()->getPdo();
if ($pdo->inTransaction()) {
$pdo->rollBack();
}
} catch (Throwable) {
// Preserve the original failure, without connection strings or exception bodies.
}
fwrite(STDERR, 'QA backup/restore not verified; diagnostic retained privately. Active environment untouched.'.PHP_EOL);
exit(1);
});
$code = app(PortalProfileInstallation::class)->fingerprint();
$tests = json_decode(file_get_contents(storage_path('app/private/investmoz-v2/portal-audit/profile-installation-checks-qa.json')), true, 512, JSON_THROW_ON_ERROR);
throw_unless(($tests['result'] ?? null) === 'passed' && ($tests['code_hash'] ?? null) === $code, RuntimeException::class, 'Current installation QA checks required.');
@@ -23,11 +51,22 @@ $restoreName = 'profile_restore_'.gmdate('Ymd_His').'_test';
$directory = storage_path('app/private/investmoz-v2/portal-profile-installation/'.$restoreName);
mkdir($directory, 0700, true);
$dump = $directory.'/database.dump';
$run = function (array $args, string $password): void {
$run = function (array $args, string $password) use ($directory): void {
$process = new Process($args, null, ['PGPASSWORD' => $password]);
$process->setTimeout(300);
$process->run();
throw_unless($process->isSuccessful(), RuntimeException::class, 'QA backup/restore command failed; output withheld.');
if (! $process->isSuccessful()) {
// Keep diagnostic output private; never expose connection secrets or dump content.
$stderr = $process->getErrorOutput();
if ($password !== '') {
$stderr = str_replace($password, '[REDACTED]', $stderr);
}
file_put_contents($directory.'/command-failure.json', json_encode([
'tool' => basename($args[0]), 'exit_code' => $process->getExitCode(),
'stderr' => $stderr, 'target_port' => 55441, 'active_access' => false,
], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
throw new RuntimeException('QA backup/restore command failed; diagnostic retained privately.');
}
};
$bin = 'C:/Program Files/PostgreSQL/17/bin/';
$snapshot = $source->query('SELECT pg_export_snapshot()')->fetchColumn();