test(M00): 增加README配置一致性检查

This commit is contained in:
Codex
2026-06-16 20:22:53 +08:00
parent 3106fa80ca
commit b44f447630
8 changed files with 10228 additions and 10 deletions
+101
View File
@@ -0,0 +1,101 @@
$ErrorActionPreference = "Stop"
$readmePath = "README.md"
$configPath = "docs/configuration.md"
$baselinePath = "docs/current-baseline.md"
$expectedSpec = "V5.2.md"
$expectedOrigin = "ssh://git@git.txyundm.cn:2222/panda/qipai.git"
foreach ($path in @($readmePath, $configPath, $baselinePath, $expectedSpec)) {
if (-not (Test-Path $path)) {
throw "Required README/config baseline file missing: $path"
}
}
$versionFiles = Get-ChildItem -File -Filter "V*.md" | Sort-Object Name
$currentSpec = $versionFiles[-1].Name
if ($currentSpec -ne $expectedSpec) {
throw "Current highest V*.md must be $expectedSpec, actual: $currentSpec"
}
$readme = Get-Content -Raw -Encoding UTF8 $readmePath
$config = Get-Content -Raw -Encoding UTF8 $configPath
$spec = Get-Content -Raw -Encoding UTF8 $expectedSpec
$baseline = Get-Content -Raw -Encoding UTF8 $baselinePath
$recentEngineeringLabel = [regex]::Unescape("\u6700\u8fd1\u5de5\u7a0b\u63d0\u4ea4")
$nextEngineeringLabel = [regex]::Unescape("\u4e0b\u4e00\u5de5\u7a0b\u76ee\u6807")
$pendingWord = [regex]::Unescape("\u5f85")
$requiredSharedValues = @(
"V5.2.md",
"D:\qipai",
"/mnt/d/qipai",
$expectedOrigin,
"https://api.txyundm.cn",
"https://api.txyundm.cn/app-api",
"https://api.txyundm.cn/admin-api",
"101.42.38.246:1883",
"admin123",
"EMQX",
"5.8.9",
"MQTTX",
"1.13.0"
)
foreach ($value in $requiredSharedValues) {
if (-not $readme.Contains($value)) {
throw "README missing required value: $value"
}
if (-not $spec.Contains($value)) {
throw "V5.2 missing required value: $value"
}
}
foreach ($value in @("V5.2.md", $expectedOrigin, "admin123", "101.42.38.246:1883")) {
if (-not $config.Contains($value)) {
throw "configuration.md missing required value: $value"
}
}
$readmeLines = Get-Content -Encoding UTF8 $readmePath
$recentLine = $readmeLines | Where-Object { $_.Contains($recentEngineeringLabel) } | Select-Object -First 1
$nextLine = $readmeLines | Where-Object { $_.Contains($nextEngineeringLabel) } | Select-Object -First 1
if (-not $recentLine) {
throw "README missing recent engineering commit line"
}
if (-not $nextLine) {
throw "README missing next engineering target line"
}
if ($recentLine.Contains($pendingWord)) {
throw "README recent engineering commit is still a placeholder"
}
if ($nextLine.Contains($pendingWord)) {
throw "README next engineering target is still a placeholder"
}
$latestEngineeringCommit = $null
$logLines = & git log --format="%h %s" -40
foreach ($line in $logLines) {
if ($line -notmatch "^[0-9a-f]+ docs\(") {
$latestEngineeringCommit = ($line -split "\s+", 2)[0]
break
}
}
if (-not $latestEngineeringCommit) {
throw "Could not find a recent engineering commit"
}
if ($readme -notmatch [regex]::Escape($latestEngineeringCommit)) {
throw "README recent engineering commit must reference latest engineering commit $latestEngineeringCommit"
}
if ($baseline -notmatch '(?m)^>\s*audited_commit:\s*`?[0-9a-f]{7,40}`?') {
throw "current-baseline.md must record audited_commit"
}
if ($baseline -notmatch '(?m)^>\s*next_engineering_target:\s*\S') {
throw "current-baseline.md must record next_engineering_target"
}
Write-Host "PASS: README, V5.2 and configuration index are consistent."