mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-10-10 19:32:04 +00:00
fix: a composite action must not change the result of the calling step before it completes (#1019)
Resolves forgejo/runner#1014 --- Manual testing can also be done using the [reproducer from the issue](https://code.forgejo.org/forgejo/runner/issues/1014#issuecomment-60694). ## Before The first step of the local composite action sets the step result of the job to success which confuses Forgejo display.  ## After Forgejo displays the progress of the composite action in the step calling it.  <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/1019): <!--number 1019 --><!--line 0 --><!--description Zml4OiBhIGNvbXBvc2l0ZSBhY3Rpb24gbXVzdCBub3QgY2hhbmdlIHRoZSByZXN1bHQgb2YgdGhlIGNhbGxpbmcgc3RlcCBiZWZvcmUgaXQgY29tcGxldGVz-->fix: a composite action must not change the result of the calling step before it completes<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1019 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
71bd44f9a0
commit
ed7dcb0081
3 changed files with 85 additions and 1 deletions
|
@ -146,6 +146,26 @@ func WithCompositeStepLogger(ctx context.Context, stepID string) context.Context
|
|||
}).WithContext(ctx))
|
||||
}
|
||||
|
||||
func GetOuterStepResult(entry *logrus.Entry) any {
|
||||
r, ok := entry.Data["stepResult"]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
// composite actions steps log with a list of stepID
|
||||
if s, ok := entry.Data["stepID"]; ok {
|
||||
if stepIDs, ok := s.([]string); ok {
|
||||
if len(stepIDs) > 1 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func withStepLogger(ctx context.Context, stepNumber int, stepID, stepName, stageName string) context.Context {
|
||||
rtn := common.Logger(ctx).WithFields(logrus.Fields{
|
||||
"stepNumber": stepNumber,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue