feat(healthcheck): support score
This commit is contained in:
parent
a7f81cb2bd
commit
4c15ac48d9
|
@ -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 {
|
||||||
|
|
|
@ -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"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user