diff --git a/cmd/joj3/main.go b/cmd/joj3/main.go index d6dbd2c..d387308 100644 --- a/cmd/joj3/main.go +++ b/cmd/joj3/main.go @@ -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 diff --git a/cmd/joj3/stage/summarize.go b/cmd/joj3/stage/summarize.go new file mode 100644 index 0000000..0c626f4 --- /dev/null +++ b/cmd/joj3/stage/summarize.go @@ -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, + ) +}