mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-24 19:08:10 +00:00
fix(release): .hmap 纳入发布产物白名单 + 路径解析
## 白名单(真问题) `upload_assets.py` 的 ARTIFACT_SUFFIXES 只有 .tar.gz/.zip/.deb/.rpm/.pkg/_win64.exe, **没有 .hmap** —— 即使插件包已经构建好放在 dist/ 下,上传时也会被静默跳过。 这正是「release 里一个插件包都没有」的直接原因之一。 补 `.hmap` 与 `SHA256SUMS.plugins`(插件包的汇总校验和,与内核包的 SHA256SUMS 分开, 避免混用)。实测 is_artifact() 现能正确识别两者、仍跳过 README.md。 ## 测试路径解析 `HMAP_BUNDLE_DIR=dist/plugins` 这种相对仓根的写法原先会失败:测试的 cwd 是包目录 (internal/plugins/pluginmgr),相对路径解析到包内,报 "no such file or directory", 看起来像产物不存在。改为相对路径按仓根解析(向上找含 go.mod 的目录)。 实测三种调用都正确:相对路径、绝对路径、不设时 skip。
This commit is contained in:
@ -23,9 +23,17 @@ func TestBuildPluginBundlesInstallable(t *testing.T) {
|
||||
if dir == "" {
|
||||
t.Skip("未设 HMAP_BUNDLE_DIR(指向 build_plugin_bundles.sh 的产出目录)")
|
||||
}
|
||||
// 相对路径按**仓根**而非本包目录解析:测试的 cwd 是包目录,
|
||||
// 而调用方通常写 `HMAP_BUNDLE_DIR=dist/plugins`(相对仓根),不修正就会
|
||||
// 报 “no such file or directory”,看起来像产物不存在。
|
||||
if !filepath.IsAbs(dir) {
|
||||
if abs, err := filepath.Abs(filepath.Join(repoRoot(), dir)); err == nil {
|
||||
dir = abs
|
||||
}
|
||||
}
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("读产物目录: %v", err)
|
||||
t.Fatalf("读产物目录 %s: %v", dir, err)
|
||||
}
|
||||
|
||||
n := 0
|
||||
@ -105,6 +113,25 @@ func TestBuildPluginBundlesInstallable(t *testing.T) {
|
||||
t.Logf("共 %d 个插件包通过内核解包校验", n)
|
||||
}
|
||||
|
||||
// repoRoot 从本文件位置向上找到仓根(含 go.mod 的目录)。
|
||||
func repoRoot() string {
|
||||
d, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "."
|
||||
}
|
||||
for i := 0; i < 8; i++ {
|
||||
if _, err := os.Stat(filepath.Join(d, "go.mod")); err == nil {
|
||||
return d
|
||||
}
|
||||
parent := filepath.Dir(d)
|
||||
if parent == d {
|
||||
break
|
||||
}
|
||||
d = parent
|
||||
}
|
||||
return "."
|
||||
}
|
||||
|
||||
// extractField 从 JSON 文本里取一个字符串字段(本文件不想为此引 encoding/json)。
|
||||
func extractField(js, key string) string {
|
||||
pat := `"` + key + `"`
|
||||
|
||||
Reference in New Issue
Block a user