feat(healthcheck): support score
Some checks failed
build / build (push) Successful in 2m16s
build / trigger-build-image (push) Successful in 13s
submodules sync / sync (push) Has been cancelled

This commit is contained in:
张泊明518370910136 2025-05-29 00:06:06 -04:00
parent a7f81cb2bd
commit 4c15ac48d9
4 changed files with 8 additions and 8 deletions

View File

@ -9,9 +9,7 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"os" "os"
"strings"
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
"github.com/joint-online-judge/JOJ3/pkg/healthcheck" "github.com/joint-online-judge/JOJ3/pkg/healthcheck"
) )
@ -74,10 +72,8 @@ func main() {
"checkFileSumList", checkFileSumList, "checkFileSumList", checkFileSumList,
"meta", metaFile, "meta", metaFile,
) )
groups := strings.Split(os.Getenv(env.Groups), ",")
res := healthcheck.All( res := healthcheck.All(
rootDir, checkFileNameList, checkFileSumList, rootDir, checkFileNameList, checkFileSumList, metaFile, repoSize,
groups, metaFile, repoSize,
) )
jsonRes, err := json.Marshal(res) jsonRes, err := json.Marshal(res)
if err != nil { if err != nil {

View File

@ -9,6 +9,7 @@ var name = "healthcheck"
type Healthcheck struct{} type Healthcheck struct{}
type Conf struct { type Conf struct {
Score int `default:"0"`
Stdout string `default:"stdout"` Stdout string `default:"stdout"`
Stderr string `default:"stderr"` Stderr string `default:"stderr"`
} }

View File

@ -34,10 +34,14 @@ func (*Healthcheck) parse(executorResult stage.ExecutorResult, conf Conf) (stage
}, true }, true
} }
slog.Debug("healthcheck result", "res", res) slog.Debug("healthcheck result", "res", res)
score := conf.Score
if res.Failed {
score = 0
}
comment := res.Msg comment := res.Msg
forceQuit := res.Failed forceQuit := res.Failed
return stage.ParserResult{ return stage.ParserResult{
Score: 0, Score: score,
Comment: comment, Comment: comment,
}, forceQuit }, forceQuit
} }

View File

@ -12,8 +12,7 @@ type Result struct {
func All( func All(
rootDir, checkFileNameList, checkFileSumList string, rootDir, checkFileNameList, checkFileSumList string,
groups, metaFile []string, metaFile []string, repoSize float64,
repoSize float64,
) (res Result) { ) (res Result) {
var err error var err error
err = RepoSize(repoSize) err = RepoSize(repoSize)