mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-21 08:05:21 +01:00
2f060c5834
Fix #28761 Fix #27884 Fix #28093 ## Changes ### Rerun all jobs When rerun all jobs, status of the jobs with `needs` will be set to `blocked` instead of `waiting`. Therefore, these jobs will not run until the required jobs are completed. ### Rerun a single job When a single job is rerun, its dependents should also be rerun, just like GitHub does (https://github.com/go-gitea/gitea/issues/28761#issuecomment-2008620820). In this case, only the specified job will be set to `waiting`, its dependents will be set to `blocked` to wait the job. ### Show warning if every job has `needs` If every job in a workflow has `needs`, all jobs will be blocked and no job can be run. So I add a warning message. <img src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b" width="480px" />
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
// 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)
|
|
}
|
|
}
|