feat(cmd/joj3): log stage summary
This commit is contained in:
		
							parent
							
								
									cd9174d7c7
								
							
						
					
					
						commit
						5bff234939
					
				|  | @ -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 | ||||
|  |  | |||
							
								
								
									
										34
									
								
								cmd/joj3/stage/summarize.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								cmd/joj3/stage/summarize.go
									
									
									
									
									
										Normal 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, | ||||
| 	) | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user