2026-09-22 21:15:34 +08:00
|
|
|
|
[CmdletBinding()]
|
2026-08-10 11:42:45 +08:00
|
|
|
|
param(
|
|
|
|
|
|
[switch]$SkipVet
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
$workspaceRoot = Split-Path -Parent $PSScriptRoot
|
|
|
|
|
|
Push-Location $workspaceRoot
|
|
|
|
|
|
try {
|
2026-09-22 21:15:34 +08:00
|
|
|
|
# 本地开发前提:go.work 把共享 SDK 替换为工作区外的相对路径,缺少该目录时整个工作区都无法解析。
|
|
|
|
|
|
$sdkDir = [System.IO.Path]::GetFullPath((Join-Path $workspaceRoot "..\..\bsm-sdk\core"))
|
|
|
|
|
|
if (-not (Test-Path -Path $sdkDir -PathType Container)) {
|
|
|
|
|
|
throw "未找到共享 SDK 目录: $sdkDir`n本地开发前提不满足:请先将 bsm-sdk/core 检出到工作区上一级目录的同级路径,即 $sdkDir"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$unformatted = @(gofmt -l pkgs module scripts)
|
2026-08-10 11:42:45 +08:00
|
|
|
|
if ($unformatted.Count -gt 0) {
|
|
|
|
|
|
throw ("gofmt required:" + [Environment]::NewLine + ($unformatted -join [Environment]::NewLine))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$modules = @(go list -m -f '{{.Dir}}')
|
2026-09-22 21:15:34 +08:00
|
|
|
|
if ($LASTEXITCODE -ne 0 -or $modules.Count -eq 0) {
|
|
|
|
|
|
throw "未解析到任何工作区模块,go list -m 可能失败或返回空列表"
|
|
|
|
|
|
}
|
2026-08-10 11:42:45 +08:00
|
|
|
|
foreach ($module in $modules) {
|
|
|
|
|
|
Write-Host "==> $module"
|
|
|
|
|
|
Push-Location $module
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (-not $SkipVet) {
|
|
|
|
|
|
go vet ./...
|
|
|
|
|
|
if ($LASTEXITCODE -ne 0) { throw "go vet failed: $module" }
|
|
|
|
|
|
}
|
|
|
|
|
|
go test ./...
|
|
|
|
|
|
if ($LASTEXITCODE -ne 0) { throw "go test failed: $module" }
|
|
|
|
|
|
}
|
|
|
|
|
|
finally {
|
|
|
|
|
|
Pop-Location
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
finally {
|
|
|
|
|
|
Pop-Location
|
|
|
|
|
|
}
|