mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
feat: assign a unique random name to each run context
If the run context has a parent, both share the same unique random name. A composite action does not have a run context of its own, it re-uses the run context of the job that calls it: this is when a parent is used and needed. There may be any level of parent / child relationship and ensureRandom name recursively look for the first parent with a non empty random.
This commit is contained in:
parent
023427115f
commit
a197fea4ba
2 changed files with 35 additions and 0 deletions
|
@ -937,3 +937,18 @@ func Test_waitForServiceContainer(t *testing.T) {
|
|||
m.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRunContext_ensureRandomName(t *testing.T) {
|
||||
parent := &RunContext{
|
||||
Name: "parentname",
|
||||
}
|
||||
rc := &RunContext{
|
||||
Name: "runname",
|
||||
Parent: parent,
|
||||
}
|
||||
|
||||
parent.ensureRandomName(t.Context())
|
||||
assert.NotEmpty(t, parent.randomName)
|
||||
rc.ensureRandomName(t.Context())
|
||||
assert.Equal(t, parent.randomName, rc.randomName)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue