runtime: use the fork catalog for stable and preview releases

This commit is contained in:
YXC0915 committed 2026-12-01 11:05:44 +08:00
1 parent 43d793ec36
commit 5f96f4ab08
3 files changed
+35 -108

No files matched your search

+2 -2
View File
@@ -94,7 +94,7 @@ Reims vGPU fork 的 [Preview 工作流](https://github.com/yxc0915/reims-vgpu/bl
> **CI 边界**:GitHub 托管的 Windows Server runner 不提供 WHPX,也无法复现 Windows 10 兼容性问题。CI 只验证可编译与控制面基本可用,实际能否启动 macOS 桌面必须经过第 5 节的真机冒烟。
### 3.3 客户端下载与安装
`internal/runtime` 从 GitHub Releases 查找 `runtime-<commit>`。正式运行时来自 `Nwflower/Reims-Go`,开启内核 Alpha 后同时列出 `yxc0915/reims-vgpu` 的 Preview。下载沿用环境变量与 Windows 系统代理,支持 HTTP `Range` 续传、强制 `SHA256SUMS.txt` 校验、临时目录原子解压与多版本切换。
`internal/runtime` 从 `yxc0915/reims-vgpu` 的 GitHub Releases 查找 `runtime-<commit>`。默认列出正式运行时,开启内核 Alpha 后同时列出 Preview。下载沿用环境变量与 Windows 系统代理,支持 HTTP `Range` 续传、强制 `SHA256SUMS.txt` 校验、临时目录原子解压与多版本切换。
---
@@ -118,7 +118,7 @@ Reims vGPU 和 QEMU 的修改由各自的运行时 fork 维护。客户端仓库
| **`stable`** | 正式发布(Release) | 从 `alpha` 晋升:在真实 Windows 10/11 宿主运行 [`scripts/smoke-runtime.ps1`](../scripts/smoke-runtime.ps1),验证纯净目录 `doctor`、启动至 macOS 桌面、截屏与正常关机,经人工确认后晋升 |
- 客户端默认仅获取 `stable` 通道;`alpha` 需用户在界面开启「接收 Alpha 版」或在 CLI 传入 `--alpha`。
- 晋升 `stable` 时,在 `Nwflower/Reims-Go` 正式 Release 分发已通过冒烟的原始资产及同一份校验清单。客户端以 Release 状态区分通道,包内 `manifest.json` 保留构建时的 `alpha` 标记。
- 晋升 `stable` 时,在运行时仓库将已通过冒烟的 Preview 改为正式 Release,并移除标题中的 Alpha 标记。保留原资产、校验清单和 `manifest.json` 的构建通道。
---
+22 -52
View File
@@ -1,7 +1,8 @@
package runtime
// Online install lists stable packages from Reims-Go and alpha packages from
// the Reims vGPU fork. A runtime release is tagged "runtime-<commit>" and carries:
// Online install reads runtime packages from the Reims vGPU fork's GitHub
// Releases. A runtime release is tagged
// "runtime-<commit>" and carries:
//
// reims-runtime-win-x64-<commit>.tar.zst
// reims-runtime-src-<commit>.tar.zst (matching sources, spec §7)
@@ -33,12 +34,11 @@ import (
)
const (
DefaultReleasesRepo = "Nwflower/reims-go"
DefaultAlphaReleasesRepo = "yxc0915/reims-vgpu"
DefaultAPIBase = "https://api.github.com"
DefaultWebBase = "https://github.com"
runtimeTagPrefix = "runtime-"
sumsAsset = fetch.SumsAsset
DefaultReleasesRepo = "yxc0915/reims-vgpu"
DefaultAPIBase = "https://api.github.com"
DefaultWebBase = "https://github.com"
runtimeTagPrefix = "runtime-"
sumsAsset = fetch.SumsAsset
)
var errRateLimited = errors.New("GitHub API rate limit reached")
@@ -67,31 +67,27 @@ func NormalizeChannel(s string) string {
// app releases and (until pruned) daily alpha runtimes.
const maxReleasePages = 10
// Source lists runtime releases. If AlphaRepo is set, it supplies the previews
// and Repo supplies the stable releases. REIMS_GO_RELEASES_REPO uses one repo
// for both channels (for forks and testing).
// Source is where runtime releases are listed. REIMS_GO_RELEASES_REPO overrides
// the repository (for forks and testing).
type Source struct {
APIBase string
WebBase string
Repo string
AlphaRepo string
Client *http.Client
APIBase string
WebBase string
Repo string
Client *http.Client
}
// DefaultSource returns the default GitHub runtime source.
func DefaultSource() Source {
s := Source{
APIBase: DefaultAPIBase,
WebBase: DefaultWebBase,
Repo: DefaultReleasesRepo,
AlphaRepo: DefaultAlphaReleasesRepo,
Client: netproxy.NewClient(),
repo := os.Getenv("REIMS_GO_RELEASES_REPO")
if repo == "" {
repo = DefaultReleasesRepo
}
if repo := os.Getenv("REIMS_GO_RELEASES_REPO"); repo != "" {
s.Repo = repo
s.AlphaRepo = ""
return Source{
APIBase: DefaultAPIBase,
WebBase: DefaultWebBase,
Repo: repo,
Client: netproxy.NewClient(),
}
return s
}
// Remote is a runtime package published as a release.
@@ -160,32 +156,6 @@ func (s Source) webBase() string {
// ListRemote lists published runtime packages, newest first. Alpha runtimes
// are included only when includeAlpha is set.
func (s Source) ListRemote(ctx context.Context, includeAlpha bool) ([]Remote, error) {
if !includeAlpha || s.AlphaRepo == "" {
return s.listRemote(ctx, includeAlpha)
}
stable, err := s.listRemote(ctx, false)
if err != nil {
return nil, err
}
s.Repo = s.AlphaRepo
previews, err := s.listRemote(ctx, true)
if err != nil {
return nil, err
}
stableCommits := make(map[string]bool, len(stable))
for _, r := range stable {
stableCommits[r.Commit] = true
}
for _, r := range previews {
if r.Channel == ChannelAlpha && !stableCommits[r.Commit] {
stable = append(stable, r)
}
}
sortRemotesNewestFirst(stable)
return stable, nil
}
func (s Source) listRemote(ctx context.Context, includeAlpha bool) ([]Remote, error) {
base := strings.TrimRight(s.APIBase, "/")
url := fmt.Sprintf("%s/repos/%s/releases?per_page=100", base, s.Repo)
var rels []ghRelease
+11 -54
View File
@@ -5,14 +5,12 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strings"
"sync/atomic"
"testing"
"time"
)
@@ -68,6 +66,17 @@ func (g *fakeGitHub) source() Source {
return Source{APIBase: g.srv.URL, Repo: "o/r", Client: g.srv.Client()}
}
func TestDefaultSourceUsesRuntimeFork(t *testing.T) {
t.Setenv("REIMS_GO_RELEASES_REPO", "")
if got := DefaultSource().Repo; got != "yxc0915/reims-vgpu" {
t.Fatalf("default runtime repository = %q", got)
}
t.Setenv("REIMS_GO_RELEASES_REPO", "example/runtime")
if got := DefaultSource().Repo; got != "example/runtime" {
t.Fatalf("overridden runtime repository = %q", got)
}
}
func TestListRemoteFiltersChannelsAndIncompleteReleases(t *testing.T) {
g := newFakeGitHub(t)
stable, err := g.source().ListRemote(context.Background(), false)
@@ -95,58 +104,6 @@ func TestListRemoteFiltersChannelsAndIncompleteReleases(t *testing.T) {
}
}
func TestDefaultSourceListsPreviewsFromRuntimeFork(t *testing.T) {
t.Setenv("REIMS_GO_RELEASES_REPO", "")
release := func(commit, date string, alpha bool) ghRelease {
return ghRelease{
TagName: "runtime-" + commit, PublishedAt: date, Prerelease: alpha,
Assets: []ghAsset{
{Name: "reims-runtime-win-x64-" + commit + ".tar.zst", URL: "archive"},
{Name: "reims-runtime-src-" + commit + ".tar.zst", URL: "source"},
{Name: sumsAsset, URL: "sums"},
},
}
}
var previewRequests atomic.Int32
mux := http.NewServeMux()
mux.HandleFunc("/repos/"+DefaultReleasesRepo+"/releases", func(w http.ResponseWriter, _ *http.Request) {
_ = json.NewEncoder(w).Encode([]ghRelease{
release("official-stable", "2026-11-30T00:00:00Z", false),
release("old-alpha", "2026-11-30T12:00:00Z", true),
})
})
mux.HandleFunc("/repos/"+DefaultAlphaReleasesRepo+"/releases", func(w http.ResponseWriter, _ *http.Request) {
previewRequests.Add(1)
_ = json.NewEncoder(w).Encode([]ghRelease{
release("fork-preview", "2026-12-01T00:00:00Z", true),
release("fork-stable", "2026-12-01T01:00:00Z", false),
release("official-stable", "2026-12-01T02:00:00Z", true),
})
})
srv := httptest.NewServer(mux)
defer srv.Close()
src := DefaultSource()
src.APIBase, src.Client = srv.URL, srv.Client()
stable, err := src.ListRemote(context.Background(), false)
if err != nil || len(stable) != 1 || stable[0].Commit != "official-stable" || previewRequests.Load() != 0 {
t.Fatalf("stable list = %+v, %v, preview requests = %d", stable, err, previewRequests.Load())
}
all, err := src.ListRemote(context.Background(), true)
if err != nil || len(all) != 2 || all[0].Commit != "fork-preview" || all[0].Channel != ChannelAlpha ||
all[1].Commit != "official-stable" || previewRequests.Load() != 1 {
t.Fatalf("alpha list = %+v, %v, preview requests = %d", all, err, previewRequests.Load())
}
t.Setenv("REIMS_GO_RELEASES_REPO", DefaultReleasesRepo)
override := DefaultSource()
override.APIBase, override.Client = srv.URL, srv.Client()
all, err = override.ListRemote(context.Background(), true)
if err != nil || len(all) != 2 || all[0].Commit != "old-alpha" || previewRequests.Load() != 1 {
t.Fatalf("override list = %+v, %v, preview requests = %d", all, err, previewRequests.Load())
}
}
func TestDownloadResumesAndVerifies(t *testing.T) {
g := newFakeGitHub(t)
src := g.source()