-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
154 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package actions | ||
|
||
import ( | ||
actions_model "code.gitea.io/gitea/models/actions" | ||
"code.gitea.io/gitea/modules/container" | ||
) | ||
|
||
// GetAllRerunJobs get all jobs that need to be rerun when job should be rerun | ||
func GetAllRerunJobs(job *actions_model.ActionRunJob, allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob { | ||
rerunJobs := []*actions_model.ActionRunJob{job} | ||
rerunJobsIDSet := make(container.Set[string]) | ||
rerunJobsIDSet.Add(job.JobID) | ||
|
||
for { | ||
found := false | ||
for _, j := range allJobs { | ||
if rerunJobsIDSet.Contains(j.JobID) { | ||
continue | ||
} | ||
for _, need := range j.Needs { | ||
if rerunJobsIDSet.Contains(need) { | ||
found = true | ||
rerunJobs = append(rerunJobs, j) | ||
rerunJobsIDSet.Add(j.JobID) | ||
break | ||
} | ||
} | ||
} | ||
if !found { | ||
break | ||
} | ||
} | ||
|
||
return rerunJobs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package actions | ||
|
||
import ( | ||
"testing" | ||
|
||
actions_model "code.gitea.io/gitea/models/actions" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetAllRerunJobs(t *testing.T) { | ||
job1 := &actions_model.ActionRunJob{JobID: "job1"} | ||
job2 := &actions_model.ActionRunJob{JobID: "job2", Needs: []string{"job1"}} | ||
job3 := &actions_model.ActionRunJob{JobID: "job3", Needs: []string{"job2"}} | ||
job4 := &actions_model.ActionRunJob{JobID: "job4", Needs: []string{"job2", "job3"}} | ||
|
||
jobs := []*actions_model.ActionRunJob{job1, job2, job3, job4} | ||
|
||
testCases := []struct { | ||
job *actions_model.ActionRunJob | ||
rerunJobs []*actions_model.ActionRunJob | ||
}{ | ||
{ | ||
job1, | ||
[]*actions_model.ActionRunJob{job1, job2, job3, job4}, | ||
}, | ||
{ | ||
job2, | ||
[]*actions_model.ActionRunJob{job2, job3, job4}, | ||
}, | ||
{ | ||
job3, | ||
[]*actions_model.ActionRunJob{job3, job4}, | ||
}, | ||
{ | ||
job4, | ||
[]*actions_model.ActionRunJob{job4}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
rerunJobs := GetAllRerunJobs(tc.job, jobs) | ||
assert.ElementsMatch(t, tc.rerunJobs, rerunJobs) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
{{template "base/head" .}} | ||
<div role="main" aria-label="{{.Title}}" class="page-content ui container center tw-w-screen {{if .IsRepo}}repository{{end}}"> | ||
<div role="main" aria-label="{{.Title}}" class="page-content {{if .IsRepo}}repository{{end}}"> | ||
{{if .IsRepo}}{{template "repo/header" .}}{{end}} | ||
<div class="ui container center"> | ||
<p style="margin-top: 100px"><img src="{{AssetUrlPrefix}}/img/404.png" alt="404"></p> | ||
<div class="ui container tw-text-center"> | ||
<img class="tw-max-w-[80vw] tw-py-16" src="{{AssetUrlPrefix}}/img/404.png" alt="404"> | ||
<p>{{if .NotFoundPrompt}}{{.NotFoundPrompt}}{{else}}{{ctx.Locale.Tr "error404"}}{{end}}</p> | ||
{{if .NotFoundGoBackURL}}<a class="ui button green" href="{{.NotFoundGoBackURL}}">{{ctx.Locale.Tr "go_back"}}</a>{{end}} | ||
|
||
<div class="divider"></div> | ||
<br> | ||
{{if .ShowFooterVersion}}<p>{{ctx.Locale.Tr "admin.config.app_ver"}}: {{AppVer}}</p>{{end}} | ||
{{if .NotFoundGoBackURL}}<a class="ui button" href="{{.NotFoundGoBackURL}}">{{ctx.Locale.Tr "go_back"}}</a>{{end}} | ||
</div> | ||
</div> | ||
{{template "base/footer" .}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters