chore: 增加 sdk:check 并对齐 Go SDK 版本

This commit is contained in:
Nixevol
2026-09-30 16:24:13 +08:00
parent c6b7b6e798
commit 5f91a7758b
7 changed files with 117 additions and 3 deletions
+8
View File
@@ -67,6 +67,14 @@ tasks:
- task: lint
- task: test
sdk:check:
desc: 四种 SDK 检查(缺工具链则跳过并提示)
cmds:
- cmd: powershell -NoProfile -File taskfiles/sdk-check.ps1
platforms: [windows]
- cmd: sh taskfiles/sdk-check.sh
platforms: [linux, darwin]
itest:
desc: 运行集成测试(含后台网页 Playwright e2e)
cmds:
+9
View File
@@ -1198,6 +1198,15 @@
- 备选方案:沿用异常文本回退与 JS 双重翻倍;否决。
- 影响:仅 sdk/java。
### 复审修复 K-05
- 日期:2026-09-30
- 原条款:issue #62;D30 Go SDK 与服务端 Go 版本相同;TASKS 4.2 Taskfile 由总控维护。
- 实际做法:`Taskfile.yml` 增加 `sdk:check`,Windows 跑 `taskfiles/sdk-check.ps1`、Unix 跑 `taskfiles/sdk-check.sh`(go fmt/vet/test、js tsc+vitest、python unittest、java mvn test);工具链或 paho-mqtt / node_modules 不存在时打印 skip 不失败。内联 PowerShell 会和 Task 的 `function` 语法冲突,故拆成脚本。`sdk/go/go.mod` 的 `go 1.27.1` 改为 `go 1.27`。`docs/RELEASE.md` 与 `docs/TASKS.md` 第 1 节写明发布前跑 `task sdk:check`。未把 `sdk:check` 挂进根 `task check`(避免无 Node/Maven/Python 的机器无法过服务端门禁)。
- 原因:根 `go test ./...` 不含独立模块 sdk/go;四套 SDK 原先不在任何检查里。
- 备选方案:`task check` 强制依赖四套工具链;否决。
- 影响:Taskfile、sdk/go/go.mod、RELEASE/TASKS 各一行。
## SDK 二 S2
### S2-PY/JAVA 1–3 2026-09-30
+1 -1
View File
@@ -134,7 +134,7 @@
- 配置项、备份、升级、证书、时钟、指标:[docs/OPS.md](./OPS.md)
- 配置样例:`deploy/config.example.yaml`、`deploy/config.docker.yaml`
常用入口:`task check` / `task build`,然后 `admin init` + `serve`(见 README)。
常用入口:`task check` / `task sdk:check` / `task build`,然后 `admin init` + `serve`(见 README)。发布前须执行 `task sdk:check`。
## 6. 未发布 SDK 包与镜像的原因
+1 -1
View File
@@ -14,7 +14,7 @@
下面全部满足才算交付:
1. `main` 上 `task check`(构建、代码检查、单元测试)和全部集成测试通过。
1. `main` 上 `task check`(构建、代码检查、单元测试)和全部集成测试通过。发布前另跑 `task sdk:check`(四种 SDK;缺工具链则跳过)。
2. PRD 第 10 节 F01–F23 每条都有验收结果:通过;或未测,写明原因,列进交付说明供负责人事后审阅。
3. 四种 SDK 都通过 DEVELOPMENT 第 9 节的接入清单。
4. DEVELOPMENT 第 13 节的弱网、崩溃、压测、端到端测试做完并有报告。
+1 -1
View File
@@ -1,6 +1,6 @@
module git.asio.asia/nixevol/NixMsg/sdk/go
go 1.27.1
go 1.27
require (
github.com/eclipse/paho.golang v0.23.0
+59
View File
@@ -0,0 +1,59 @@
$Skip = { param($n, $r) Write-Host ("skip " + $n + ": " + $r) }
if (Get-Command go -ErrorAction SilentlyContinue) {
Push-Location sdk/go
$unfmt = gofmt -l .
if ($unfmt) {
Write-Host $unfmt
Pop-Location
exit 1
}
go vet ./...
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
go test ./...
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
Pop-Location
} else {
& $Skip "sdk/go" "no go"
}
if ((Get-Command node -ErrorAction SilentlyContinue) -and (Test-Path "sdk/js/node_modules")) {
Push-Location sdk/js
npx --no-install tsc --noEmit
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
npx --no-install vitest run
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
Pop-Location
} else {
& $Skip "sdk/js" "no node or node_modules"
}
$py = Get-Command python -ErrorAction SilentlyContinue
if (-not $py) {
$py = Get-Command python3 -ErrorAction SilentlyContinue
}
if ($py) {
$env:PYTHONPATH = (Resolve-Path "sdk/python/src").Path
& $py.Source -c "import paho.mqtt.client"
if ($LASTEXITCODE -ne 0) {
& $Skip "sdk/python" "no paho-mqtt"
} else {
& $py.Source -m unittest discover -s sdk/python/tests -t sdk/python
if ($LASTEXITCODE -ne 0) {
Remove-Item Env:PYTHONPATH -ErrorAction SilentlyContinue
exit $LASTEXITCODE
}
}
Remove-Item Env:PYTHONPATH -ErrorAction SilentlyContinue
} else {
& $Skip "sdk/python" "no python"
}
if (Get-Command mvn -ErrorAction SilentlyContinue) {
Push-Location sdk/java
mvn -q test
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
Pop-Location
} else {
& $Skip "sdk/java" "no mvn"
}
+38
View File
@@ -0,0 +1,38 @@
#!/bin/sh
set -e
skip() { echo "skip $1: $2"; }
if command -v go >/dev/null 2>&1; then
(cd sdk/go && test -z "$(gofmt -l .)" && go vet ./... && go test ./...)
else
skip sdk/go "no go"
fi
if command -v node >/dev/null 2>&1 && [ -d sdk/js/node_modules ]; then
(cd sdk/js && npx --no-install tsc --noEmit && npx --no-install vitest run)
else
skip sdk/js "no node or node_modules"
fi
if command -v python3 >/dev/null 2>&1; then
PY=python3
elif command -v python >/dev/null 2>&1; then
PY=python
else
PY=
fi
if [ -n "$PY" ]; then
if PYTHONPATH=sdk/python/src "$PY" -c "import paho.mqtt.client" >/dev/null 2>&1; then
PYTHONPATH=sdk/python/src "$PY" -m unittest discover -s sdk/python/tests -t sdk/python
else
skip sdk/python "no paho-mqtt"
fi
else
skip sdk/python "no python"
fi
if command -v mvn >/dev/null 2>&1; then
(cd sdk/java && mvn -q test)
else
skip sdk/java "no mvn"
fi