feat(healthcheck): support score
This commit is contained in:
parent
a7f81cb2bd
commit
4c15ac48d9
|
@ -9,9 +9,7 @@ import (
|
|||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
|
||||
"github.com/joint-online-judge/JOJ3/pkg/healthcheck"
|
||||
)
|
||||
|
||||
|
@ -74,10 +72,8 @@ func main() {
|
|||
"checkFileSumList", checkFileSumList,
|
||||
"meta", metaFile,
|
||||
)
|
||||
groups := strings.Split(os.Getenv(env.Groups), ",")
|
||||
res := healthcheck.All(
|
||||
rootDir, checkFileNameList, checkFileSumList,
|
||||
groups, metaFile, repoSize,
|
||||
rootDir, checkFileNameList, checkFileSumList, metaFile, repoSize,
|
||||
)
|
||||
jsonRes, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
|
|
|
@ -9,6 +9,7 @@ var name = "healthcheck"
|
|||
type Healthcheck struct{}
|
||||
|
||||
type Conf struct {
|
||||
Score int `default:"0"`
|
||||
Stdout string `default:"stdout"`
|
||||
Stderr string `default:"stderr"`
|
||||
}
|
||||
|
|
|
@ -34,10 +34,14 @@ func (*Healthcheck) parse(executorResult stage.ExecutorResult, conf Conf) (stage
|
|||
}, true
|
||||
}
|
||||
slog.Debug("healthcheck result", "res", res)
|
||||
score := conf.Score
|
||||
if res.Failed {
|
||||
score = 0
|
||||
}
|
||||
comment := res.Msg
|
||||
forceQuit := res.Failed
|
||||
return stage.ParserResult{
|
||||
Score: 0,
|
||||
Score: score,
|
||||
Comment: comment,
|
||||
}, forceQuit
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ type Result struct {
|
|||
|
||||
func All(
|
||||
rootDir, checkFileNameList, checkFileSumList string,
|
||||
groups, metaFile []string,
|
||||
repoSize float64,
|
||||
metaFile []string, repoSize float64,
|
||||
) (res Result) {
|
||||
var err error
|
||||
err = RepoSize(repoSize)
|
||||
|
|
Loading…
Reference in New Issue
Block a user