feat(cmd/joj3): log stage summary
All checks were successful
submodules sync / sync (push) Successful in 43s
build / build (push) Successful in 1m43s
build / trigger-build-image (push) Successful in 8s

This commit is contained in:
张泊明518370910136 2024-11-08 12:49:48 -05:00
parent cd9174d7c7
commit 5bff234939
GPG Key ID: D47306D7062CDA9D
2 changed files with 35 additions and 0 deletions

View File

@ -83,6 +83,7 @@ func mainImpl() error {
if err != nil {
slog.Error("stage run", "error", err)
}
stage.Summarize(confObj, stageResults, stageForceQuit)
if err = stage.Write(confObj.Stage.OutputPath, stageResults); err != nil {
slog.Error("stage write", "error", err)
return err

View File

@ -0,0 +1,34 @@
package stage
import (
"log/slog"
"os"
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
"github.com/joint-online-judge/JOJ3/internal/stage"
)
func Summarize(
conf *conf.Conf, stageResults []stage.StageResult, stageForceQuit bool,
) {
actor := os.Getenv("GITHUB_ACTOR")
repository := os.Getenv("GITHUB_REPOSITORY")
ref := os.Getenv("GITHUB_REF")
workflow := os.Getenv("GITHUB_WORKFLOW")
totalScore := 0
for _, stageResult := range stageResults {
for _, result := range stageResult.Results {
totalScore += result.Score
}
}
slog.Info(
"stage summary",
"name", conf.Name,
"totalScore", totalScore,
"forceQuit", stageForceQuit,
"actor", actor,
"repository", repository,
"ref", ref,
"workflow", workflow,
)
}