CaiWuXiTong/tests/Unit/Deployment/ReleaseAncestryManifestTest.php
苏木 b2aed36706 fix(发布): 识别已审查的 Squash 热修复集成 (#1567)
Co-authored-by: 苏木 <594326199@qq.com>
Co-committed-by: 苏木 <594326199@qq.com>
2026-11-30 14:20:44 +08:00

32 lines
1.3 KiB
PHP

<?php
namespace Tests\Unit\Deployment;
use Tests\TestCase;
class ReleaseAncestryManifestTest extends TestCase
{
public function test_release_script_only_accepts_reviewed_squashed_integrations(): void
{
$manifestPath = base_path('deploy/release-ancestry.json');
$manifest = json_decode((string) file_get_contents($manifestPath), true, 32, JSON_THROW_ON_ERROR);
$entries = $manifest['squashed_integrations'] ?? [];
$this->assertIsArray($entries);
$this->assertNotEmpty($entries);
foreach ($entries as $entry) {
$this->assertMatchesRegularExpression('/^[0-9a-f]{40}$/', (string) ($entry['previous_sha'] ?? ''));
$this->assertMatchesRegularExpression('/^[0-9a-f]{40}$/', (string) ($entry['integrated_sha'] ?? ''));
$this->assertNotSame('', trim((string) ($entry['reason'] ?? '')));
}
$script = (string) file_get_contents(base_path('scripts/deploy-from-workstation.ps1'));
$this->assertStringContainsString('deploy/release-ancestry.json', $script);
$this->assertStringContainsString('$ancestryManifest.squashed_integrations', $script);
$this->assertStringContainsString(
'git merge-base --is-ancestor $entry.integrated_sha $ReleaseSha',
$script,
);
}
}