feat: support post step log

This commit is contained in:
Jason Song 2022-11-17 19:14:51 +08:00
parent cab56996b7
commit ab4e06f977
3 changed files with 22 additions and 13 deletions

2
go.mod
View File

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

4
go.sum
View File

@ -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=

View File

@ -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 {