feat(cmd/joj3): show capped total score [force build]
All checks were successful
submodules sync / sync (push) Successful in 53s
build / build (push) Successful in 1m36s
build / trigger-build-image (push) Successful in 10s

This commit is contained in:
张泊明518370910136 2024-11-16 02:22:11 -05:00
parent 39b47bc59e
commit 60d9e1b215
GPG Key ID: D47306D7062CDA9D
3 changed files with 11 additions and 2 deletions

View File

@ -39,6 +39,7 @@ type Conf struct {
Name string `default:"unknown"`
LogPath string `default:""`
ExpireUnixTimestamp int64 `default:"-1"`
MaxTotalScore int `default:"-1"`
Stage struct {
SandboxExecServer string `default:"localhost:5051"`
SandboxToken string `default:""`
@ -55,7 +56,7 @@ type Conf struct {
SkipScoreboard bool `default:"false"`
SkipFailedTable bool `default:"false"`
SubmitterInIssueTitle bool `default:"true"`
MaxTotalScore int `default:"-1"`
MaxTotalScore int `default:"-1"` // TODO: remove me
}
// TODO: remove the following backward compatibility fields
SandboxExecServer string `default:"localhost:5051"`
@ -172,6 +173,9 @@ func ParseConfFile(path string) (conf *Conf, err error) {
}
env.Attr.ConfName = conf.Name
// TODO: remove the following backward compatibility codes
if conf.MaxTotalScore < 0 && conf.Teapot.MaxTotalScore >= 0 {
conf.MaxTotalScore = conf.Teapot.MaxTotalScore
}
if len(conf.Stage.Stages) == 0 {
conf.Stage.SandboxExecServer = conf.SandboxExecServer
conf.Stage.SandboxToken = conf.SandboxToken

View File

@ -44,9 +44,14 @@ func mainImpl() (err error) {
totalScore += result.Score
}
}
cappedTotalScore := totalScore
if confObj.MaxTotalScore >= 0 {
cappedTotalScore = min(totalScore, confObj.MaxTotalScore)
}
slog.Info(
"joj3 summary",
"totalScore", totalScore,
"cappedTotalScore", cappedTotalScore,
"forceQuit", forceQuitStageName != "",
"forceQuitStageName", forceQuitStageName,
"issue", teapotResult.Issue,

View File

@ -59,7 +59,7 @@ func Run(conf *conf.Conf) (teapotResult TeapotResult, err error) {
env.Attr.RunNumber, conf.Teapot.ScoreboardPath,
conf.Teapot.FailedTablePath,
conf.Name, env.Attr.Sha, env.Attr.RunID,
"--max-total-score", strconv.Itoa(conf.Teapot.MaxTotalScore),
"--max-total-score", strconv.Itoa(conf.MaxTotalScore),
skipIssueArg, skipScoreboardArg,
skipFailedTableArg, submitterInIssueTitleArg,
) // #nosec G204