mirror of https://code.forgejo.org/forgejo/runner
chore: remove tracing codes
parent
41b5fa6b55
commit
2f879c41c4
1
go.mod
1
go.mod
|
@ -8,7 +8,6 @@ require (
|
|||
github.com/avast/retry-go/v4 v4.1.0
|
||||
github.com/bufbuild/connect-go v0.5.0
|
||||
github.com/docker/docker v20.10.17+incompatible
|
||||
github.com/google/go-cmp v0.5.8
|
||||
github.com/joho/godotenv v1.4.0
|
||||
github.com/kelseyhightower/envconfig v1.4.0
|
||||
github.com/mattn/go-isatty v0.0.16
|
||||
|
|
1
go.sum
1
go.sum
|
@ -404,7 +404,6 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
|
|
|
@ -12,8 +12,6 @@ import (
|
|||
|
||||
"github.com/avast/retry-go/v4"
|
||||
"github.com/bufbuild/connect-go"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
@ -61,9 +59,7 @@ func (r *Reporter) Fire(entry *log.Entry) error {
|
|||
|
||||
timestamp := entry.Time
|
||||
if r.state.StartedAt == nil {
|
||||
r.updateState(func() {
|
||||
r.state.StartedAt = timestamppb.New(timestamp)
|
||||
})
|
||||
r.state.StartedAt = timestamppb.New(timestamp)
|
||||
}
|
||||
|
||||
var step *runnerv1.StepState
|
||||
|
@ -76,15 +72,13 @@ func (r *Reporter) Fire(entry *log.Entry) error {
|
|||
if step == nil {
|
||||
if v, ok := entry.Data["jobResult"]; ok {
|
||||
if jobResult, ok := r.parseResult(v); ok {
|
||||
r.updateState(func() {
|
||||
r.state.Result = jobResult
|
||||
r.state.StoppedAt = timestamppb.New(timestamp)
|
||||
for _, s := range r.state.Steps {
|
||||
if s.Result == runnerv1.Result_RESULT_UNSPECIFIED {
|
||||
s.Result = runnerv1.Result_RESULT_CANCELLED
|
||||
}
|
||||
r.state.Result = jobResult
|
||||
r.state.StoppedAt = timestamppb.New(timestamp)
|
||||
for _, s := range r.state.Steps {
|
||||
if s.Result == runnerv1.Result_RESULT_UNSPECIFIED {
|
||||
s.Result = runnerv1.Result_RESULT_CANCELLED
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
if !r.duringSteps() {
|
||||
|
@ -94,19 +88,15 @@ func (r *Reporter) Fire(entry *log.Entry) error {
|
|||
}
|
||||
|
||||
if step.StartedAt == nil {
|
||||
r.updateState(func() {
|
||||
step.StartedAt = timestamppb.New(timestamp)
|
||||
})
|
||||
step.StartedAt = timestamppb.New(timestamp)
|
||||
}
|
||||
|
||||
if v, ok := entry.Data["raw_output"]; ok {
|
||||
if rawOutput, ok := v.(bool); ok && rawOutput {
|
||||
r.updateState(func() {
|
||||
if step.LogLength == 0 {
|
||||
step.LogIndex = int64(r.logOffset + len(r.logRows))
|
||||
}
|
||||
step.LogLength++
|
||||
})
|
||||
if step.LogLength == 0 {
|
||||
step.LogIndex = int64(r.logOffset + len(r.logRows))
|
||||
}
|
||||
step.LogLength++
|
||||
r.logRows = append(r.logRows, r.parseLogRow(entry))
|
||||
return nil
|
||||
}
|
||||
|
@ -114,13 +104,11 @@ func (r *Reporter) Fire(entry *log.Entry) error {
|
|||
|
||||
if v, ok := entry.Data["stepResult"]; ok {
|
||||
if stepResult, ok := r.parseResult(v); ok {
|
||||
r.updateState(func() {
|
||||
if step.LogLength == 0 {
|
||||
step.LogIndex = int64(r.logOffset + len(r.logRows))
|
||||
}
|
||||
step.Result = stepResult
|
||||
step.StoppedAt = timestamppb.New(timestamp)
|
||||
})
|
||||
if step.LogLength == 0 {
|
||||
step.LogIndex = int64(r.logOffset + len(r.logRows))
|
||||
}
|
||||
step.Result = stepResult
|
||||
step.StoppedAt = timestamppb.New(timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,19 +262,3 @@ func (r *Reporter) parseLogRow(entry *log.Entry) *runnerv1.LogRow {
|
|||
Content: strings.TrimSuffix(entry.Message, "\r\n"),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Reporter) updateState(update func()) {
|
||||
if log.GetLevel() < log.TraceLevel {
|
||||
update()
|
||||
return
|
||||
}
|
||||
|
||||
before := proto.Clone(r.state)
|
||||
update()
|
||||
diff := cmp.Diff(before, r.state, cmpopts.IgnoreUnexported(
|
||||
runnerv1.TaskState{},
|
||||
runnerv1.StepState{},
|
||||
timestamppb.Timestamp{},
|
||||
))
|
||||
log.Tracef("update state %d: %s", r.state.Id, diff)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue