From ab4e06f977ca78181077e5de43d7aad070204192 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Thu, 17 Nov 2022 19:14:51 +0800 Subject: [PATCH] feat: support post step log --- go.mod | 2 +- go.sum | 4 ++-- runtime/reporter.go | 29 +++++++++++++++++++---------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 8c71640..f932911 100644 --- a/go.mod +++ b/go.mod @@ -72,4 +72,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/nektos/act => gitea.com/gitea/act v0.0.0-20221116100712-3caee171b716 +replace github.com/nektos/act => gitea.com/gitea/act v0.0.0-20221117110915-c92dcb7b0a01 diff --git a/go.sum b/go.sum index 1d7f968..2720897 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -gitea.com/gitea/act v0.0.0-20221116100712-3caee171b716 h1:wPFBAjfK5OFBruaX9BNSdPoRcVdEbsjviSpryVjFZjY= -gitea.com/gitea/act v0.0.0-20221116100712-3caee171b716/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo= +gitea.com/gitea/act v0.0.0-20221117110915-c92dcb7b0a01 h1:7bwzZWEL0cvSRxeNN0N+4earbjfhgzSJ/zBYRFEnXL0= +gitea.com/gitea/act v0.0.0-20221117110915-c92dcb7b0a01/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo= gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835 h1:27PhT7Nli/pgRo1bDYVZ+hlCKuF9cfFuo+y9muaPVJY= gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y= github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= diff --git a/runtime/reporter.go b/runtime/reporter.go index 2d2ecde..86daf64 100644 --- a/runtime/reporter.go +++ b/runtime/reporter.go @@ -70,19 +70,16 @@ func (r *Reporter) Fire(entry *log.Entry) error { r.stateM.Lock() defer r.stateM.Unlock() + log.WithFields(entry.Data).Trace(entry.Message) + timestamp := entry.Time if r.state.StartedAt == nil { r.state.StartedAt = timestamppb.New(timestamp) } - var step *runnerv1.StepState - if v, ok := entry.Data["stepNumber"]; ok { - if v, ok := v.(int); ok { - step = r.state.Steps[v] - } - } + stage := entry.Data["stage"] - if step == nil { + if stage != "Main" { if v, ok := entry.Data["jobResult"]; ok { if jobResult, ok := r.parseResult(v); ok { r.state.Result = jobResult @@ -100,10 +97,22 @@ func (r *Reporter) Fire(entry *log.Entry) error { return nil } + var step *runnerv1.StepState + if v, ok := entry.Data["stepNumber"]; ok { + if v, ok := v.(int); ok { + step = r.state.Steps[v] + } + } + if step == nil { + if !r.duringSteps() { + r.logRows = append(r.logRows, r.parseLogRow(entry)) + } + return nil + } + if step.StartedAt == nil { step.StartedAt = timestamppb.New(timestamp) } - if v, ok := entry.Data["raw_output"]; ok { if rawOutput, ok := v.(bool); ok && rawOutput { if step.LogLength == 0 { @@ -111,10 +120,10 @@ func (r *Reporter) Fire(entry *log.Entry) error { } step.LogLength++ r.logRows = append(r.logRows, r.parseLogRow(entry)) - return nil } + } else if !r.duringSteps() { + r.logRows = append(r.logRows, r.parseLogRow(entry)) } - if v, ok := entry.Data["stepResult"]; ok { if stepResult, ok := r.parseResult(v); ok { if step.LogLength == 0 {