mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
refactor: rename model
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/models/webhook"
|
||||
actions_module "code.gitea.io/gitea/modules/actions"
|
||||
bots_module "code.gitea.io/gitea/modules/actions"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
@@ -33,19 +33,19 @@ func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository
|
||||
|
||||
if err := db.WithTx(ctx, func(ctx context.Context) error {
|
||||
e := db.GetEngine(ctx)
|
||||
if _, err := e.Delete(&actions_model.BotTaskStep{RepoID: repo.ID}); err != nil {
|
||||
if _, err := e.Delete(&actions_model.ActionTaskStep{RepoID: repo.ID}); err != nil {
|
||||
return fmt.Errorf("delete bots task steps of repo %d: %w", repo.ID, err)
|
||||
}
|
||||
if _, err := e.Delete(&actions_model.BotTask{RepoID: repo.ID}); err != nil {
|
||||
if _, err := e.Delete(&actions_model.ActionTask{RepoID: repo.ID}); err != nil {
|
||||
return fmt.Errorf("delete bots tasks of repo %d: %w", repo.ID, err)
|
||||
}
|
||||
if _, err := e.Delete(&actions_model.BotRunJob{RepoID: repo.ID}); err != nil {
|
||||
if _, err := e.Delete(&actions_model.ActionRunJob{RepoID: repo.ID}); err != nil {
|
||||
return fmt.Errorf("delete bots run jobs of repo %d: %w", repo.ID, err)
|
||||
}
|
||||
if _, err := e.Delete(&actions_model.BotRun{RepoID: repo.ID}); err != nil {
|
||||
if _, err := e.Delete(&actions_model.ActionRun{RepoID: repo.ID}); err != nil {
|
||||
return fmt.Errorf("delete bots runs of repo %d: %w", repo.ID, err)
|
||||
}
|
||||
if _, err := e.Delete(&actions_model.BotRunner{RepoID: repo.ID}); err != nil {
|
||||
if _, err := e.Delete(&actions_model.ActionRunner{RepoID: repo.ID}); err != nil {
|
||||
return fmt.Errorf("delete bots runner of repo %d: %w", repo.ID, err)
|
||||
}
|
||||
return nil
|
||||
@@ -55,7 +55,7 @@ func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository
|
||||
|
||||
// remove logs file after tasks have been deleted, to avoid new log files
|
||||
for _, task := range tasks {
|
||||
err := actions_module.RemoveLogs(ctx, task.LogInStorage, task.LogFilename)
|
||||
err := bots_module.RemoveLogs(ctx, task.LogInStorage, task.LogFilename)
|
||||
if err != nil {
|
||||
log.Error("remove log file %q: %v", task.LogFilename, err)
|
||||
// go on
|
||||
@@ -65,7 +65,7 @@ func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateCommitStatus(ctx context.Context, job *actions_model.BotRunJob) error {
|
||||
func CreateCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) error {
|
||||
if err := job.LoadAttributes(ctx); err != nil {
|
||||
return fmt.Errorf("load run: %w", err)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func checkJobsOfRun(ctx context.Context, runID int64) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
idToJobs := make(map[string][]*actions_model.BotRunJob, len(jobs))
|
||||
idToJobs := make(map[string][]*actions_model.ActionRunJob, len(jobs))
|
||||
for _, job := range jobs {
|
||||
idToJobs[job.JobID] = append(idToJobs[job.JobID], job)
|
||||
}
|
||||
@@ -75,8 +75,8 @@ type jobStatusResolver struct {
|
||||
needs map[int64][]int64
|
||||
}
|
||||
|
||||
func newJobStatusResolver(jobs actions_model.RunJobList) *jobStatusResolver {
|
||||
idToJobs := make(map[string][]*actions_model.BotRunJob, len(jobs))
|
||||
func newJobStatusResolver(jobs actions_model.ActionJobList) *jobStatusResolver {
|
||||
idToJobs := make(map[string][]*actions_model.ActionRunJob, len(jobs))
|
||||
for _, job := range jobs {
|
||||
idToJobs[job.JobID] = append(idToJobs[job.JobID], job)
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ import (
|
||||
func Test_jobStatusResolver_Resolve(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
jobs actions_model.RunJobList
|
||||
jobs actions_model.ActionJobList
|
||||
want map[int64]actions_model.Status
|
||||
}{
|
||||
{
|
||||
name: "no blocked",
|
||||
jobs: actions_model.RunJobList{
|
||||
jobs: actions_model.ActionJobList{
|
||||
{ID: 1, JobID: "1", Status: actions_model.StatusWaiting, Needs: []string{}},
|
||||
{ID: 2, JobID: "2", Status: actions_model.StatusWaiting, Needs: []string{}},
|
||||
{ID: 3, JobID: "3", Status: actions_model.StatusWaiting, Needs: []string{}},
|
||||
@@ -28,7 +28,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "single blocked",
|
||||
jobs: actions_model.RunJobList{
|
||||
jobs: actions_model.ActionJobList{
|
||||
{ID: 1, JobID: "1", Status: actions_model.StatusSuccess, Needs: []string{}},
|
||||
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
|
||||
{ID: 3, JobID: "3", Status: actions_model.StatusWaiting, Needs: []string{}},
|
||||
@@ -39,7 +39,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "multiple blocked",
|
||||
jobs: actions_model.RunJobList{
|
||||
jobs: actions_model.ActionJobList{
|
||||
{ID: 1, JobID: "1", Status: actions_model.StatusSuccess, Needs: []string{}},
|
||||
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
|
||||
{ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
|
||||
@@ -51,7 +51,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "chain blocked",
|
||||
jobs: actions_model.RunJobList{
|
||||
jobs: actions_model.ActionJobList{
|
||||
{ID: 1, JobID: "1", Status: actions_model.StatusFailure, Needs: []string{}},
|
||||
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
|
||||
{ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"2"}},
|
||||
@@ -63,7 +63,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "loop need",
|
||||
jobs: actions_model.RunJobList{
|
||||
jobs: actions_model.ActionJobList{
|
||||
{ID: 1, JobID: "1", Status: actions_model.StatusBlocked, Needs: []string{"3"}},
|
||||
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
|
||||
{ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"2"}},
|
||||
|
||||
Reference in New Issue
Block a user