feat: repo health check (#16) #17

Merged
张泊明518370910136 merged 37 commits from file_check into master 2024-09-11 20:09:27 +08:00
4 changed files with 14 additions and 12 deletions
Showing only changes of commit a505b70506 - Show all commits

View File

@ -57,13 +57,13 @@ func (*Keyword) Run(results []stage.ExecutorResult, confAny any) (
return nil, true, err
}
var res []stage.ParserResult
end := false
forceQuit := false
for _, result := range results {
tmp, matched := Parse(result, *conf)
if matched && conf.EndOnMatch {
end = true
forceQuit = true
}
res = append(res, tmp)
}
return res, end, nil
return res, forceQuit, nil
}

View File

@ -19,12 +19,12 @@ func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) (
if err != nil {
return nil, true, err
}
end := false
forceQuit := false
var res []stage.ParserResult
for _, result := range results {
comment := ""
if result.Status != stage.Status(envexec.StatusAccepted) {
end = true
forceQuit = true
comment = fmt.Sprintf(
"Unexpected executor status: %s.", result.Status,
)
@ -34,5 +34,5 @@ func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) (
Comment: comment,
})
}
return res, end, nil
return res, forceQuit, nil
}

View File

@ -164,6 +164,7 @@ type ParserResult struct {
}
type StageResult struct {
Name string `json:"name"`
Results []ParserResult `json:"results"`
Name string `json:"name"`
Results []ParserResult `json:"results"`
ForceQuit bool `json:"force_quit"`
}

View File

@ -26,17 +26,18 @@ func Run(stages []Stage) []StageResult {
slog.Error("parser not found", "name", stage.ParserName)
break
}
parserResults, end, err := parser.Run(executorResults, stage.ParserConf)
parserResults, forceQuit, err := parser.Run(executorResults, stage.ParserConf)
if err != nil {
slog.Error("parser run error", "name", stage.ExecutorName, "error", err)
break
}
slog.Debug("parser run done", "results", parserResults)
stageResults = append(stageResults, StageResult{
Name: stage.Name,
Results: parserResults,
Name: stage.Name,
Results: parserResults,
ForceQuit: forceQuit,
})
if end {
if forceQuit {
break
}
}