refactor(pages): 公开部署源任务并默认每日扫描

移除 Pages 部署源任务的 InternalOnly 限制,任务管理可查看与调度;
将 scanner cron 与 GitHub latest 默认检查间隔调整为每天一次,
并优化部署历史列表展示。
This commit is contained in:
ryan
2026-07-19 20:41:09 +08:00
parent 20249d917c
commit 4481677ef3
12 changed files with 269 additions and 160 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ const (
defaultRemoteAssetLabel = "pages-package"
defaultGitHubAssetName = "dist.zip"
defaultCheckInterval = 60
defaultCheckInterval = 1440
minimumCheckInterval = 5
maximumCheckInterval = 1440
)
@@ -27,8 +27,7 @@ const (
pagesSourceScanBatchSize = 20
)
// PagesSourceScanMeta is available to the scheduler registry but hidden from
// generic Admin task dispatch and schedule mutation APIs.
// PagesSourceScanMeta describes the periodic Pages source scanner schedule.
var PagesSourceScanMeta = task.TaskMeta{
Type: TaskTypePagesSourceScan,
AsynqTask: PagesSourceScanTask,
@@ -38,7 +37,6 @@ var PagesSourceScanMeta = task.TaskMeta{
MaxRetry: 0,
Queue: task.QueueDefault,
Retryable: false,
InternalOnly: true,
}
type pagesSourceScanPayload struct{}
@@ -477,7 +477,7 @@ func TestPagesSourceScannerIncludesOrphanCleanupSummary(t *testing.T) {
}
}
func TestPagesSourceScanPayloadAndMetaAreInternalOnly(t *testing.T) {
func TestPagesSourceScanPayloadAndMeta(t *testing.T) {
handler := &SourceScanHandler{}
if normalized, err := handler.ValidatePayload(nil); err != nil || string(normalized) != "{}" {
t.Errorf("ValidatePayload(nil) = %s, %v; want {}, nil", normalized, err)
@@ -485,9 +485,9 @@ func TestPagesSourceScanPayloadAndMetaAreInternalOnly(t *testing.T) {
if _, err := handler.ValidatePayload([]byte(`{"unexpected":true}`)); err == nil {
t.Error("ValidatePayload(unknown field) error = nil, want non-nil")
}
if !PagesSourceScanMeta.InternalOnly || PagesSourceScanMeta.Type != TaskTypePagesSourceScan ||
if PagesSourceScanMeta.InternalOnly || PagesSourceScanMeta.Type != TaskTypePagesSourceScan ||
PagesSourceScanMeta.AsynqTask != PagesSourceScanTask || PagesSourceScanMeta.MaxRetry != 0 {
t.Errorf("PagesSourceScanMeta = %+v, want internal bounded scheduled scanner", PagesSourceScanMeta)
t.Errorf("PagesSourceScanMeta = %+v, want public bounded scheduled scanner", PagesSourceScanMeta)
}
if PagesSourceScanMeta.SupportsTime {
t.Error("PagesSourceScanMeta.SupportsTime = true, want empty scanner payload")
@@ -32,7 +32,7 @@ const (
var errUnexpectedJSONTrailingValue = errors.New("unexpected trailing JSON value")
// PagesSourceActionMeta is intentionally hidden from generic Admin task APIs.
// PagesSourceActionMeta describes check/sync work for Pages deployment sources.
var PagesSourceActionMeta = task.TaskMeta{
Type: TaskTypePagesSourceAction,
AsynqTask: PagesSourceActionTask,
@@ -42,7 +42,6 @@ var PagesSourceActionMeta = task.TaskMeta{
MaxRetry: 2,
Queue: task.QueueDefault,
Retryable: false,
InternalOnly: true,
}
// SourceActionPayload is the credential-free internal queue contract.
@@ -165,9 +165,9 @@ func TestRemoteCheckActionIsPermanentWithoutExposingURL(t *testing.T) {
}
}
func TestPagesSourceActionMetaIsInternalOnly(t *testing.T) {
if !PagesSourceActionMeta.InternalOnly {
t.Error("PagesSourceActionMeta.InternalOnly = false, want true")
func TestPagesSourceActionMeta(t *testing.T) {
if PagesSourceActionMeta.InternalOnly {
t.Error("PagesSourceActionMeta.InternalOnly = true, want false")
}
if PagesSourceActionMeta.Type != TaskTypePagesSourceAction {
t.Errorf("PagesSourceActionMeta.Type = %q, want %q", PagesSourceActionMeta.Type, TaskTypePagesSourceAction)