feat(actions): add build queue view (#38585)

Adds a read-only Actions job queue: running jobs first, then waiting
jobs in the order a runner picks them up. It is shown instance-wide in
the admin Actions section with owner, repository and status filters, and
per repository in the Actions tab. Both lists refresh in place.

Pending work is currently only visible per repository and newest-first,
so nothing shows what is queued, in which order, or what occupies the
runners. Reordering the queue will be proposed separately.

A migration adds indexes for the runner pickup query and
repository-scoped status lookups.

* Fix #34198

<img width="1345" height="451" alt="image"
src="https://github.com/user-attachments/assets/7d52ff76-81b4-44e8-b583-d7d89c9dffcd"
/>
<img width="1809" height="1134" alt="image"
src="https://github.com/user-attachments/assets/4d56c0cb-bae7-4ce2-8f3c-75163b2bc7f4"
/>

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
bircni
2026-09-26 10:01:41 +02:00
committed by GitHub
parent 5a56e118e4
commit 3875db1974
30 changed files with 928 additions and 95 deletions
+1
View File
@@ -427,6 +427,7 @@ func prepareMigrationTasks() []*migration {
newMigration(351, "Track transfer recipient access grants", v28.AddRecipientAccessGrantedToRepoTransfer),
newMigration(352, "Add token columns to deploy_key", v28.AddTokenToDeployKey),
newMigration(353, "Add audit event table", v28.AddAuditEventTable),
newMigration(354, "Add Actions job queue indexes", v28.AddActionQueueIndexes),
}
return preparedMigrations
}
+34
View File
@@ -0,0 +1,34 @@
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v28
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/timeutil"
"xorm.io/xorm"
)
// AddActionQueueIndexes indexes the runner pickup query and repository-scoped status lookups.
func AddActionQueueIndexes(_ context.Context, x base.EngineMigration) error {
type ActionRunJob struct {
RepoID int64 `xorm:"index(repo_status)"`
TaskID int64 `xorm:"index(pickup)"`
Status int `xorm:"index(pickup) index(repo_status)"`
Updated timeutil.TimeStamp `xorm:"index(pickup)"`
}
type ActionRun struct {
RepoID int64 `xorm:"index(repo_status)"`
Status int `xorm:"index(repo_status)"`
}
_, err := x.SyncWithOptions(xorm.SyncOptions{
IgnoreDropIndices: true,
IgnoreConstrains: true,
}, new(ActionRunJob), new(ActionRun))
return err
}
+51
View File
@@ -0,0 +1,51 @@
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v28
import (
"testing"
"gitea.dev/modelmigration/migrationtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAddActionQueueIndexes(t *testing.T) {
type ActionRunJob struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64
TaskID int64
Status int
Updated int64 `xorm:"updated"`
}
type ActionRun struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64
Status int
}
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(ActionRunJob), new(ActionRun))
defer deferable()
if x == nil || t.Failed() {
return
}
require.NoError(t, AddActionQueueIndexes(t.Context(), x))
tables := migrationtest.LoadTableSchemasMap(t, x)
indexCols := func(table string) [][]string {
schema, ok := tables[table]
require.True(t, ok)
var cols [][]string
for _, idx := range schema.Indexes {
cols = append(cols, idx.Cols)
}
return cols
}
assert.Contains(t, indexCols("action_run_job"), []string{"task_id", "status", "updated"})
assert.Contains(t, indexCols("action_run_job"), []string{"repo_id", "status"})
assert.Contains(t, indexCols("action_run"), []string{"repo_id", "status"})
}