1
0
Fork 0
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:
Earl Warren 2025-08-14 10:46:28 +02:00
parent 023427115f
commit a197fea4ba
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 35 additions and 0 deletions

View file

@ -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)
}