mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-14 03:29:55 +00:00
feat(actions): List workflows that were executed once but got removed from the default branch (#37835)
This commit is contained in:
@@ -132,6 +132,18 @@ func GetStatusInfoList(ctx context.Context, lang translation.Locale) []StatusInf
|
||||
return statusInfoList
|
||||
}
|
||||
|
||||
// GetRunWorkflowIDs returns all distinct WorkflowIDs that have at least
|
||||
// one ActionRun in the given repo.
|
||||
func GetRunWorkflowIDs(ctx context.Context, repoID int64) ([]string, error) {
|
||||
ids := make([]string, 0, 10)
|
||||
return ids, db.GetEngine(ctx).Table("action_run").
|
||||
Where(builder.Eq{"repo_id": repoID}).
|
||||
Distinct("workflow_id").
|
||||
Cols("workflow_id").
|
||||
Asc("workflow_id").
|
||||
Find(&ids)
|
||||
}
|
||||
|
||||
// GetActors returns a slice of Actors
|
||||
func GetActors(ctx context.Context, repoID int64) ([]*user_model.User, error) {
|
||||
actors := make([]*user_model.User, 0, 10)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package actions
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetRunWorkflowIDs(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
ids, err := GetRunWorkflowIDs(t.Context(), 4)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []string{"artifact.yaml", "test.yaml"}, ids)
|
||||
|
||||
ids, err = GetRunWorkflowIDs(t.Context(), 999999)
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, ids)
|
||||
}
|
||||
Reference in New Issue
Block a user