mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03:24 +09:00
fix(actions): fail unexpandable reusable workflow callers and decouple the job emitter's cross-run processing (#38565) (#38587)
Backport #38565 by @Zettat123 ## Changes ### 1. Handle reusable workflow expansion failures If a reusable workflow caller job is invalid (e.g. uses a workflow with syntax error), the job emitter should mark it as failed instead of retrying. Related: https://github.com/go-gitea/gitea/pull/38518#discussion_r3608882095 ### 2. No longer process concurrent run inline **Before**: If a run(R1)'s status change unlocks another blocked run(R2) via concurrency group, the job emitter will process R2 in R1's transaction. **Current**: No longer process R2 inline and emit the ID of R2 to let another pass process it. Co-authored-by: Zettat123 <zettat123@gmail.com>
This commit is contained in:
@@ -206,3 +206,34 @@ func TestResolveUses(t *testing.T) {
|
||||
assert.ErrorContains(t, err, "must point to this Gitea instance")
|
||||
})
|
||||
}
|
||||
|
||||
func TestUndoExpansion(t *testing.T) {
|
||||
require.NoError(t, unittest.PrepareTestDatabase())
|
||||
ctx := t.Context()
|
||||
|
||||
// A claimed caller with two children inserted by the aborted expansion, plus a sibling that must survive.
|
||||
caller := &actions_model.ActionRunJob{
|
||||
RunID: 991, RepoID: 4, OwnerID: 1, JobID: "caller", Name: "caller",
|
||||
Status: actions_model.StatusBlocked, IsReusableCaller: true, IsExpanded: true,
|
||||
}
|
||||
require.NoError(t, db.Insert(ctx, caller))
|
||||
for _, jobID := range []string{"child1", "child2"} {
|
||||
require.NoError(t, db.Insert(ctx, &actions_model.ActionRunJob{
|
||||
RunID: 991, RepoID: 4, OwnerID: 1, JobID: jobID, Name: jobID,
|
||||
Status: actions_model.StatusBlocked, ParentJobID: caller.ID,
|
||||
}))
|
||||
}
|
||||
sibling := &actions_model.ActionRunJob{
|
||||
RunID: 991, RepoID: 4, OwnerID: 1, JobID: "sibling", Name: "sibling",
|
||||
Status: actions_model.StatusBlocked,
|
||||
}
|
||||
require.NoError(t, db.Insert(ctx, sibling))
|
||||
|
||||
require.NoError(t, undoExpansion(ctx, caller))
|
||||
|
||||
assert.Equal(t, 0, unittest.GetCount(t, &actions_model.ActionRunJob{ParentJobID: caller.ID}))
|
||||
assert.False(t, caller.IsExpanded)
|
||||
refreshed := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: caller.ID})
|
||||
assert.False(t, refreshed.IsExpanded)
|
||||
unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: sibling.ID})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user