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

View File

@ -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"`
}

View File

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

View File

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