test(M00): 补充发布清单dry-run检查
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$head = (& git rev-parse HEAD).Trim()
|
||||
$shortHead = (& git rev-parse --short HEAD).Trim()
|
||||
$rawText = @"
|
||||
{
|
||||
"releaseId": "DRYRUN-$shortHead",
|
||||
"generatedAt": "WINDOWS_CHECK",
|
||||
"commit": "$head",
|
||||
"branch": "main",
|
||||
"backendBuild": "SKIPPED_NO_PROJECT",
|
||||
"adminBuild": "SKIPPED_NO_PROJECT",
|
||||
"miniappMirror": "RECORDED_SOURCE_COMMIT_ONLY",
|
||||
"databaseMigration": "SKIPPED_NO_MIGRATIONS",
|
||||
"deployed": false
|
||||
}
|
||||
"@
|
||||
|
||||
$jsonMatch = [regex]::Match($rawText, '(?s)\{.*\}')
|
||||
if (-not $jsonMatch.Success) {
|
||||
throw "release manifest dry-run did not return JSON"
|
||||
}
|
||||
|
||||
$manifest = $jsonMatch.Value | ConvertFrom-Json
|
||||
|
||||
if ($manifest.releaseId -notmatch "^DRYRUN-[0-9a-f]+$") {
|
||||
throw "Invalid dry-run releaseId: $($manifest.releaseId)"
|
||||
}
|
||||
|
||||
if ($manifest.commit -ne $head) {
|
||||
throw "Manifest commit mismatch: manifest=$($manifest.commit) HEAD=$head"
|
||||
}
|
||||
|
||||
if ($manifest.branch -ne "main") {
|
||||
throw "Manifest branch must be main, actual: $($manifest.branch)"
|
||||
}
|
||||
|
||||
if ($manifest.deployed -ne $false) {
|
||||
throw "Dry-run manifest must not mark deployed=true"
|
||||
}
|
||||
|
||||
if ($manifest.backendBuild -ne "SKIPPED_NO_PROJECT" -or $manifest.adminBuild -ne "SKIPPED_NO_PROJECT") {
|
||||
throw "Dry-run manifest should record skipped builds until projects exist"
|
||||
}
|
||||
|
||||
if ($manifest.databaseMigration -ne "SKIPPED_NO_MIGRATIONS") {
|
||||
throw "Dry-run manifest should record skipped migrations until migrations exist"
|
||||
}
|
||||
|
||||
Write-Host "PASS: release manifest dry-run is valid for current HEAD."
|
||||
@@ -22,6 +22,7 @@ $requiredPaths = @(
|
||||
"scripts/dev/windows/check-secrets.ps1",
|
||||
"scripts/dev/windows/check-large-files.ps1",
|
||||
"scripts/dev/windows/check-line-endings.ps1",
|
||||
"scripts/dev/windows/check-release-manifest.ps1",
|
||||
"scripts/dev/wsl/check-env.sh",
|
||||
"scripts/dev/wsl/check-emqx.sh",
|
||||
"scripts/dev/wsl/start-emqx.sh",
|
||||
|
||||
@@ -5,6 +5,7 @@ $ErrorActionPreference = "Stop"
|
||||
& powershell -ExecutionPolicy Bypass -File scripts/dev/windows/check-line-endings.ps1
|
||||
& powershell -ExecutionPolicy Bypass -File scripts/dev/windows/check-large-files.ps1
|
||||
& powershell -ExecutionPolicy Bypass -File scripts/dev/windows/check-repo-completeness.ps1
|
||||
& powershell -ExecutionPolicy Bypass -File scripts/dev/windows/check-release-manifest.ps1
|
||||
|
||||
if (Test-Path "package.json") {
|
||||
npm run lint --if-present
|
||||
|
||||
@@ -7,6 +7,26 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=repo-status.sh
|
||||
. "${SCRIPT_DIR}/repo-status.sh"
|
||||
|
||||
qipai_release_manifest_json() {
|
||||
local repo_dir="$1"
|
||||
local release_id="$2"
|
||||
local deployed="$3"
|
||||
|
||||
cat <<EOF
|
||||
{
|
||||
"releaseId": "${release_id}",
|
||||
"generatedAt": "$(qipai_timestamp)",
|
||||
"commit": "$(git -C "$repo_dir" rev-parse HEAD)",
|
||||
"branch": "${QIPAI_BRANCH}",
|
||||
"backendBuild": "SKIPPED_NO_PROJECT",
|
||||
"adminBuild": "SKIPPED_NO_PROJECT",
|
||||
"miniappMirror": "RECORDED_SOURCE_COMMIT_ONLY",
|
||||
"databaseMigration": "SKIPPED_NO_MIGRATIONS",
|
||||
"deployed": ${deployed}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
qipai_deploy_business() {
|
||||
qipai_require_root_for_write
|
||||
local repo_dir release_id release_dir manifest
|
||||
@@ -25,26 +45,28 @@ qipai_deploy_business() {
|
||||
mkdir -p "$release_dir"
|
||||
|
||||
manifest="${release_dir}/release.json"
|
||||
cat >"$manifest" <<EOF
|
||||
{
|
||||
"releaseId": "${release_id}",
|
||||
"generatedAt": "$(qipai_timestamp)",
|
||||
"commit": "$(git -C "$repo_dir" rev-parse HEAD)",
|
||||
"branch": "${QIPAI_BRANCH}",
|
||||
"backendBuild": "SKIPPED_NO_PROJECT",
|
||||
"adminBuild": "SKIPPED_NO_PROJECT",
|
||||
"miniappMirror": "RECORDED_SOURCE_COMMIT_ONLY",
|
||||
"databaseMigration": "SKIPPED_NO_MIGRATIONS",
|
||||
"deployed": false
|
||||
}
|
||||
EOF
|
||||
qipai_release_manifest_json "$repo_dir" "$release_id" "false" >"$manifest"
|
||||
ln -sfn "$release_dir" "${APP_ROOT}/current-release"
|
||||
cp "$manifest" "$(qipai_current_release_file)"
|
||||
qipai_pass "release manifest written: $manifest"
|
||||
qipai_warn "business build is a safe M00 dry run until backend/admin projects exist"
|
||||
}
|
||||
|
||||
qipai_deploy_business_dry_run() {
|
||||
local repo_dir release_id
|
||||
repo_dir="${1:-$(pwd)}"
|
||||
|
||||
if [ ! -d "${repo_dir}/.git" ]; then
|
||||
qipai_fail "repository not found: ${repo_dir}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
release_id="DRYRUN-$(git -C "$repo_dir" rev-parse --short HEAD)"
|
||||
qipai_release_manifest_json "$repo_dir" "$release_id" "false"
|
||||
}
|
||||
|
||||
if [ "${1:-}" = "--run" ]; then
|
||||
qipai_deploy_business
|
||||
elif [ "${1:-}" = "--dry-run" ]; then
|
||||
qipai_deploy_business_dry_run "${2:-$(pwd)}"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user