loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a new column schedule_id for action_run to track (#26975)

Fix #26971

And the UI now will display it's scheduled but not triggered by a push.

<img width="954" alt="图片"
src="https://github.com/go-gitea/gitea/assets/81045/d211845c-457e-4c3e-af1f-a0d654d3f365">

authored by

Lunny Xiao and committed by
GitHub
9c0a3532 ffa4949e

+37 -20
+2 -1
models/actions/run.go
··· 35 35 Index int64 `xorm:"index unique(repo_index)"` // a unique number for each run of a repository 36 36 TriggerUserID int64 `xorm:"index"` 37 37 TriggerUser *user_model.User `xorm:"-"` 38 - Ref string `xorm:"index"` // the commit/tag/… that caused the run 38 + ScheduleID int64 39 + Ref string `xorm:"index"` // the commit/tag/… that caused the run 39 40 CommitSHA string 40 41 IsForkPullRequest bool // If this is triggered by a PR from a forked repository or an untrusted user, we need to check if it is approved and limit permissions when running the workflow. 41 42 NeedApproval bool // may need approval if it's a fork pull request
+2
models/migrations/migrations.go
··· 530 530 NewMigration("Add Action Schedule Table", v1_21.AddActionScheduleTable), 531 531 // v274 -> v275 532 532 NewMigration("Add Actions artifacts expiration date", v1_21.AddExpiredUnixColumnInActionArtifactTable), 533 + // v275 -> v276 534 + NewMigration("Add ScheduleID for ActionRun", v1_21.AddScheduleIDForActionRun), 533 535 } 534 536 535 537 // GetCurrentDBVersion returns the current db version
+15
models/migrations/v1_21/v275.go
··· 1 + // Copyright 2023 The Gitea Authors. All rights reserved. 2 + // SPDX-License-Identifier: MIT 3 + 4 + package v1_21 //nolint 5 + 6 + import ( 7 + "xorm.io/xorm" 8 + ) 9 + 10 + func AddScheduleIDForActionRun(x *xorm.Engine) error { 11 + type ActionRun struct { 12 + ScheduleID int64 13 + } 14 + return x.Sync(new(ActionRun)) 15 + }
+1
options/locale/locale_en-US.ini
··· 3504 3504 3505 3505 runs.all_workflows = All Workflows 3506 3506 runs.commit = Commit 3507 + runs.scheduled = Scheduled 3507 3508 runs.pushed_by = pushed by 3508 3509 runs.invalid_workflow_helper = Workflow config file is invalid. Please check your config file: %s 3509 3510 runs.no_matching_runner_helper = No matching runner: %s
+7 -1
routers/api/actions/runner/runner.go
··· 202 202 if err := task.LoadJob(ctx); err != nil { 203 203 return nil, status.Errorf(codes.Internal, "load job: %v", err) 204 204 } 205 + if err := task.Job.LoadRun(ctx); err != nil { 206 + return nil, status.Errorf(codes.Internal, "load run: %v", err) 207 + } 205 208 206 - actions_service.CreateCommitStatus(ctx, task.Job) 209 + // don't create commit status for cron job 210 + if task.Job.Run.ScheduleID == 0 { 211 + actions_service.CreateCommitStatus(ctx, task.Job) 212 + } 207 213 208 214 if req.Msg.State.Result != runnerv1.Result_RESULT_UNSPECIFIED { 209 215 if err := actions_service.EmitJobsIfReady(task.Job.RunID); err != nil {
+1 -13
services/actions/schedule_tasks.go
··· 113 113 CommitSHA: cron.CommitSHA, 114 114 Event: cron.Event, 115 115 EventPayload: cron.EventPayload, 116 + ScheduleID: cron.ID, 116 117 Status: actions_model.StatusWaiting, 117 118 } 118 119 ··· 125 126 // Insert the action run and its associated jobs into the database 126 127 if err := actions_model.InsertRun(ctx, run, workflows); err != nil { 127 128 return err 128 - } 129 - 130 - // Retrieve the jobs for the newly created action run 131 - jobs, _, err := actions_model.FindRunJobs(ctx, actions_model.FindRunJobOptions{RunID: run.ID}) 132 - if err != nil { 133 - return err 134 - } 135 - 136 - // Create commit statuses for each job 137 - for _, job := range jobs { 138 - if err := createCommitStatus(ctx, job); err != nil { 139 - return err 140 - } 141 129 } 142 130 143 131 // Return nil if no errors occurred
+9 -5
templates/repo/actions/runs_list.tmpl
··· 15 15 {{- .Title -}} 16 16 </a> 17 17 <div class="flex-item-body"> 18 - <b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b> 19 - : {{$.locale.Tr "actions.runs.commit"}} 20 - <a href="{{$.RepoLink}}/commit/{{.CommitSHA}}">{{ShortSha .CommitSHA}}</a> 21 - {{$.locale.Tr "actions.runs.pushed_by"}} 22 - <a href="{{.TriggerUser.HomeLink}}">{{.TriggerUser.GetDisplayName}}</a> 18 + <b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>: 19 + {{- if .ScheduleID -}} 20 + {{$.locale.Tr "actions.runs.scheduled"}} 21 + {{- else -}} 22 + {{$.locale.Tr "actions.runs.commit"}} 23 + <a href="{{$.RepoLink}}/commit/{{.CommitSHA}}">{{ShortSha .CommitSHA}}</a> 24 + {{$.locale.Tr "actions.runs.pushed_by"}} 25 + <a href="{{.TriggerUser.HomeLink}}">{{.TriggerUser.GetDisplayName}}</a> 26 + {{- end -}} 23 27 </div> 24 28 </div> 25 29 <div class="flex-item-trailing">