Skip to content

Commit 9347855

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Add endpoint deleting workflow run (go-gitea#34337) Fix remove org user failure on mssql (go-gitea#34449) Fix repo broken check (go-gitea#34444) Fix comment textarea scroll issue in Firefox (go-gitea#34438) Fix releases sidebar navigation link (go-gitea#34436)
2 parents d536882 + b6bf128 commit 9347855

File tree

33 files changed

+782
-122
lines changed

33 files changed

+782
-122
lines changed

models/actions/run.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
user_model "code.gitea.io/gitea/models/user"
1717
"code.gitea.io/gitea/modules/git"
1818
"code.gitea.io/gitea/modules/json"
19+
"code.gitea.io/gitea/modules/setting"
1920
api "code.gitea.io/gitea/modules/structs"
2021
"code.gitea.io/gitea/modules/timeutil"
2122
"code.gitea.io/gitea/modules/util"
@@ -343,13 +344,13 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
343344
return committer.Commit()
344345
}
345346

346-
func GetRunByID(ctx context.Context, id int64) (*ActionRun, error) {
347+
func GetRunByRepoAndID(ctx context.Context, repoID, runID int64) (*ActionRun, error) {
347348
var run ActionRun
348-
has, err := db.GetEngine(ctx).Where("id=?", id).Get(&run)
349+
has, err := db.GetEngine(ctx).Where("id=? AND repo_id=?", runID, repoID).Get(&run)
349350
if err != nil {
350351
return nil, err
351352
} else if !has {
352-
return nil, fmt.Errorf("run with id %d: %w", id, util.ErrNotExist)
353+
return nil, fmt.Errorf("run with id %d: %w", runID, util.ErrNotExist)
353354
}
354355

355356
return &run, nil
@@ -420,17 +421,10 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
420421

421422
if run.Status != 0 || slices.Contains(cols, "status") {
422423
if run.RepoID == 0 {
423-
run, err = GetRunByID(ctx, run.ID)
424-
if err != nil {
425-
return err
426-
}
424+
setting.PanicInDevOrTesting("RepoID should not be 0")
427425
}
428-
if run.Repo == nil {
429-
repo, err := repo_model.GetRepositoryByID(ctx, run.RepoID)
430-
if err != nil {
431-
return err
432-
}
433-
run.Repo = repo
426+
if err = run.LoadRepo(ctx); err != nil {
427+
return err
434428
}
435429
if err := updateRepoRunsNumbers(ctx, run.Repo); err != nil {
436430
return err

models/actions/run_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (job *ActionRunJob) Duration() time.Duration {
5151

5252
func (job *ActionRunJob) LoadRun(ctx context.Context) error {
5353
if job.Run == nil {
54-
run, err := GetRunByID(ctx, job.RunID)
54+
run, err := GetRunByRepoAndID(ctx, job.RepoID, job.RunID)
5555
if err != nil {
5656
return err
5757
}
@@ -142,7 +142,7 @@ func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, col
142142
{
143143
// Other goroutines may aggregate the status of the run and update it too.
144144
// So we need load the run and its jobs before updating the run.
145-
run, err := GetRunByID(ctx, job.RunID)
145+
run, err := GetRunByRepoAndID(ctx, job.RepoID, job.RunID)
146146
if err != nil {
147147
return 0, err
148148
}

models/actions/task_list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (tasks TaskList) LoadAttributes(ctx context.Context) error {
4848
type FindTaskOptions struct {
4949
db.ListOptions
5050
RepoID int64
51+
JobID int64
5152
OwnerID int64
5253
CommitSHA string
5354
Status Status
@@ -61,6 +62,9 @@ func (opts FindTaskOptions) ToConds() builder.Cond {
6162
if opts.RepoID > 0 {
6263
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
6364
}
65+
if opts.JobID > 0 {
66+
cond = cond.And(builder.Eq{"job_id": opts.JobID})
67+
}
6468
if opts.OwnerID > 0 {
6569
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
6670
}

models/activities/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.
530530

531531
if opts.RequestedTeam != nil {
532532
env := repo_model.AccessibleTeamReposEnv(organization.OrgFromUser(opts.RequestedUser), opts.RequestedTeam)
533-
teamRepoIDs, err := env.RepoIDs(ctx, 1, opts.RequestedUser.NumRepos)
533+
teamRepoIDs, err := env.RepoIDs(ctx)
534534
if err != nil {
535535
return nil, fmt.Errorf("GetTeamRepositories: %w", err)
536536
}

models/fixtures/action_artifact.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,39 @@
105105
created_unix: 1730330775
106106
updated_unix: 1730330775
107107
expired_unix: 1738106775
108+
109+
-
110+
id: 24
111+
run_id: 795
112+
runner_id: 1
113+
repo_id: 2
114+
owner_id: 2
115+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
116+
storage_path: "27/5/1730330775594233150.chunk"
117+
file_size: 1024
118+
file_compressed_size: 1024
119+
content_encoding: "application/zip"
120+
artifact_path: "artifact-795-1.zip"
121+
artifact_name: "artifact-795-1"
122+
status: 2
123+
created_unix: 1730330775
124+
updated_unix: 1730330775
125+
expired_unix: 1738106775
126+
127+
-
128+
id: 25
129+
run_id: 795
130+
runner_id: 1
131+
repo_id: 2
132+
owner_id: 2
133+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
134+
storage_path: "27/5/1730330775594233150.chunk"
135+
file_size: 1024
136+
file_compressed_size: 1024
137+
content_encoding: "application/zip"
138+
artifact_path: "artifact-795-2.zip"
139+
artifact_name: "artifact-795-2"
140+
status: 2
141+
created_unix: 1730330775
142+
updated_unix: 1730330775
143+
expired_unix: 1738106775

models/fixtures/action_run.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0"
4949
event: "push"
5050
is_fork_pull_request: 0
51-
status: 1
51+
status: 6 # running
5252
started: 1683636528
5353
stopped: 1683636626
5454
created: 1683636108
@@ -74,3 +74,23 @@
7474
updated: 1683636626
7575
need_approval: 0
7676
approved_by: 0
77+
78+
-
79+
id: 795
80+
title: "to be deleted (test)"
81+
repo_id: 2
82+
owner_id: 2
83+
workflow_id: "test.yaml"
84+
index: 191
85+
trigger_user_id: 1
86+
ref: "refs/heads/test"
87+
commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0"
88+
event: "push"
89+
is_fork_pull_request: 0
90+
status: 2
91+
started: 1683636528
92+
stopped: 1683636626
93+
created: 1683636108
94+
updated: 1683636626
95+
need_approval: 0
96+
approved_by: 0

models/fixtures/action_run_job.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,33 @@
6969
status: 5
7070
started: 1683636528
7171
stopped: 1683636626
72+
73+
-
74+
id: 198
75+
run_id: 795
76+
repo_id: 2
77+
owner_id: 2
78+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
79+
is_fork_pull_request: 0
80+
name: job_1
81+
attempt: 1
82+
job_id: job_1
83+
task_id: 53
84+
status: 1
85+
started: 1683636528
86+
stopped: 1683636626
87+
88+
-
89+
id: 199
90+
run_id: 795
91+
repo_id: 2
92+
owner_id: 2
93+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
94+
is_fork_pull_request: 0
95+
name: job_2
96+
attempt: 1
97+
job_id: job_2
98+
task_id: 54
99+
status: 2
100+
started: 1683636528
101+
stopped: 1683636626

models/fixtures/action_task.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,43 @@
117117
log_length: 707
118118
log_size: 90179
119119
log_expired: 0
120+
-
121+
id: 53
122+
job_id: 198
123+
attempt: 1
124+
runner_id: 1
125+
status: 1
126+
started: 1683636528
127+
stopped: 1683636626
128+
repo_id: 2
129+
owner_id: 2
130+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
131+
is_fork_pull_request: 0
132+
token_hash: b8d3962425466b6709b9ac51446f93260c54afe8e7b6d3686e34f991fb8a8953822b0deed86fe41a103f34bc48dbc4784223
133+
token_salt: ffffffffff
134+
token_last_eight: ffffffff
135+
log_filename: artifact-test2/2f/47.log
136+
log_in_storage: 1
137+
log_length: 0
138+
log_size: 0
139+
log_expired: 0
140+
-
141+
id: 54
142+
job_id: 199
143+
attempt: 1
144+
runner_id: 1
145+
status: 2
146+
started: 1683636528
147+
stopped: 1683636626
148+
repo_id: 2
149+
owner_id: 2
150+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
151+
is_fork_pull_request: 0
152+
token_hash: b8d3962425466b6709b9ac51446f93260c54afe8e7b6d3686e34f991fb8a8953822b0deed86fe41a103f34bc48dbc4784224
153+
token_salt: ffffffffff
154+
token_last_eight: ffffffff
155+
log_filename: artifact-test2/2f/47.log
156+
log_in_storage: 1
157+
log_length: 0
158+
log_size: 0
159+
log_expired: 0

models/organization/org_test.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -334,33 +334,14 @@ func TestAccessibleReposEnv_RepoIDs(t *testing.T) {
334334
testSuccess := func(userID int64, expectedRepoIDs []int64) {
335335
env, err := repo_model.AccessibleReposEnv(db.DefaultContext, org, userID)
336336
assert.NoError(t, err)
337-
repoIDs, err := env.RepoIDs(db.DefaultContext, 1, 100)
337+
repoIDs, err := env.RepoIDs(db.DefaultContext)
338338
assert.NoError(t, err)
339339
assert.Equal(t, expectedRepoIDs, repoIDs)
340340
}
341341
testSuccess(2, []int64{3, 5, 32})
342342
testSuccess(4, []int64{3, 32})
343343
}
344344

345-
func TestAccessibleReposEnv_Repos(t *testing.T) {
346-
assert.NoError(t, unittest.PrepareTestDatabase())
347-
org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3})
348-
testSuccess := func(userID int64, expectedRepoIDs []int64) {
349-
env, err := repo_model.AccessibleReposEnv(db.DefaultContext, org, userID)
350-
assert.NoError(t, err)
351-
repos, err := env.Repos(db.DefaultContext, 1, 100)
352-
assert.NoError(t, err)
353-
expectedRepos := make(repo_model.RepositoryList, len(expectedRepoIDs))
354-
for i, repoID := range expectedRepoIDs {
355-
expectedRepos[i] = unittest.AssertExistsAndLoadBean(t,
356-
&repo_model.Repository{ID: repoID})
357-
}
358-
assert.Equal(t, expectedRepos, repos)
359-
}
360-
testSuccess(2, []int64{3, 5, 32})
361-
testSuccess(4, []int64{3, 32})
362-
}
363-
364345
func TestAccessibleReposEnv_MirrorRepos(t *testing.T) {
365346
assert.NoError(t, unittest.PrepareTestDatabase())
366347
org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3})

models/repo/org_repo.go

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ func GetTeamRepositories(ctx context.Context, opts *SearchTeamRepoOptions) (Repo
4848
// accessible to a particular user
4949
type AccessibleReposEnvironment interface {
5050
CountRepos(ctx context.Context) (int64, error)
51-
RepoIDs(ctx context.Context, page, pageSize int) ([]int64, error)
52-
Repos(ctx context.Context, page, pageSize int) (RepositoryList, error)
51+
RepoIDs(ctx context.Context) ([]int64, error)
5352
MirrorRepos(ctx context.Context) (RepositoryList, error)
5453
AddKeyword(keyword string)
5554
SetSort(db.SearchOrderBy)
@@ -132,40 +131,18 @@ func (env *accessibleReposEnv) CountRepos(ctx context.Context) (int64, error) {
132131
return repoCount, nil
133132
}
134133

135-
func (env *accessibleReposEnv) RepoIDs(ctx context.Context, page, pageSize int) ([]int64, error) {
136-
if page <= 0 {
137-
page = 1
138-
}
139-
140-
repoIDs := make([]int64, 0, pageSize)
134+
func (env *accessibleReposEnv) RepoIDs(ctx context.Context) ([]int64, error) {
135+
var repoIDs []int64
141136
return repoIDs, db.GetEngine(ctx).
142137
Table("repository").
143138
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id").
144139
Where(env.cond()).
145-
GroupBy("`repository`.id,`repository`."+strings.Fields(string(env.orderBy))[0]).
140+
GroupBy("`repository`.id,`repository`." + strings.Fields(string(env.orderBy))[0]).
146141
OrderBy(string(env.orderBy)).
147-
Limit(pageSize, (page-1)*pageSize).
148142
Cols("`repository`.id").
149143
Find(&repoIDs)
150144
}
151145

152-
func (env *accessibleReposEnv) Repos(ctx context.Context, page, pageSize int) (RepositoryList, error) {
153-
repoIDs, err := env.RepoIDs(ctx, page, pageSize)
154-
if err != nil {
155-
return nil, fmt.Errorf("GetUserRepositoryIDs: %w", err)
156-
}
157-
158-
repos := make([]*Repository, 0, len(repoIDs))
159-
if len(repoIDs) == 0 {
160-
return repos, nil
161-
}
162-
163-
return repos, db.GetEngine(ctx).
164-
In("`repository`.id", repoIDs).
165-
OrderBy(string(env.orderBy)).
166-
Find(&repos)
167-
}
168-
169146
func (env *accessibleReposEnv) MirrorRepoIDs(ctx context.Context) ([]int64, error) {
170147
repoIDs := make([]int64, 0, 10)
171148
return repoIDs, db.GetEngine(ctx).

options/locale/locale_en-US.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,6 +3811,9 @@ runs.no_workflows.documentation = For more information on Gitea Actions, see <a
38113811
runs.no_runs = The workflow has no runs yet.
38123812
runs.empty_commit_message = (empty commit message)
38133813
runs.expire_log_message = Logs have been purged because they were too old.
3814+
runs.delete = Delete workflow run
3815+
runs.delete.description = Are you sure you want to permanently delete this workflow run? This action cannot be undone.
3816+
runs.not_done = This workflow run is not done.
38143817

38153818
workflow.disable = Disable Workflow
38163819
workflow.disable_success = Workflow '%s' disabled successfully.

options/locale/locale_ga-IE.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,7 +3728,11 @@ creation.name_placeholder=carachtair alfanumair nó íoslaghda amháin nach féi
37283728
creation.value_placeholder=Ionchur ábhar ar bith. Fágfar spás bán ag tús agus ag deireadh ar lár.
37293729
creation.description_placeholder=Cuir isteach cur síos gairid (roghnach).
37303730

3731+
save_success=Tá an rún "%s" sábháilte.
3732+
save_failed=Theip ar an rún a shábháil.
37313733

3734+
add_secret=Cuir rún leis
3735+
edit_secret=Cuir rún in eagar
37323736
deletion=Bain rún
37333737
deletion.description=Is buan rún a bhaint agus ní féidir é a chealú. Lean ort?
37343738
deletion.success=Tá an rún bainte.

routers/api/v1/api.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,10 @@ func Routes() *web.Router {
12791279
}, reqToken(), reqAdmin())
12801280
m.Group("/actions", func() {
12811281
m.Get("/tasks", repo.ListActionTasks)
1282-
m.Get("/runs/{run}/artifacts", repo.GetArtifactsOfRun)
1282+
m.Group("/runs/{run}", func() {
1283+
m.Get("/artifacts", repo.GetArtifactsOfRun)
1284+
m.Delete("", reqToken(), reqRepoWriter(unit.TypeActions), repo.DeleteActionRun)
1285+
})
12831286
m.Get("/artifacts", repo.GetArtifacts)
12841287
m.Group("/artifacts/{artifact_id}", func() {
12851288
m.Get("", repo.GetArtifact)

0 commit comments

Comments
 (0)