diff --git a/cmd/repo-health-checker/main.go b/cmd/repo-health-checker/main.go index 45a11c8..8315cfb 100644 --- a/cmd/repo-health-checker/main.go +++ b/cmd/repo-health-checker/main.go @@ -6,7 +6,6 @@ import ( "fmt" "log/slog" "os" - "strings" "github.com/joint-online-judge/JOJ3/internal/conf" "github.com/joint-online-judge/JOJ3/pkg/healthcheck" @@ -60,20 +59,8 @@ func init() { } func prepareTeapotCheck() ( - confObj *conf.Conf, groups []string, actor, repoName string, err error, + confObj *conf.Conf, groups []string, err error, ) { - actor = os.Getenv("GITHUB_ACTOR") - repository := os.Getenv("GITHUB_REPOSITORY") - if actor == "" || - repository == "" || - strings.Count(repository, "/") != 1 || - confPath == "" { - slog.Error("teapot env not set", "actor", actor, "repository", repository, "confPath", confPath, "env", os.Environ()) - err = fmt.Errorf("teapot env not set") - return - } - repoParts := strings.Split(repository, "/") - repoName = repoParts[1] commitMsg, err := conf.GetCommitMsg() if err != nil { slog.Error("get commit msg", "error", err) @@ -108,13 +95,13 @@ func main() { "meta", metaFile, ) var err error - confObj, groups, actor, repoName, err := prepareTeapotCheck() + confObj, groups, err := prepareTeapotCheck() if err != nil { slog.Error("prepare teapot check", "error", err) confObj = nil } res := healthcheck.All( - confObj, actor, repoName, rootDir, checkFileNameList, checkFileSumList, + confObj, rootDir, checkFileNameList, checkFileSumList, groups, metaFile, repoSize, ) jsonRes, err := json.Marshal(res) diff --git a/pkg/healthcheck/all.go b/pkg/healthcheck/all.go index 22dbf33..aa3eb2d 100644 --- a/pkg/healthcheck/all.go +++ b/pkg/healthcheck/all.go @@ -13,13 +13,13 @@ type Result struct { func All( confObj *conf.Conf, - actor, repoName, rootDir, checkFileNameList, checkFileSumList string, + rootDir, checkFileNameList, checkFileSumList string, groups, metaFile []string, repoSize float64, ) (res Result) { var err error if confObj != nil { - output, err := TeapotCheck(confObj, actor, repoName, groups) + output, err := TeapotCheck(confObj, groups) if err != nil { res.Msg += fmt.Sprintf("### Teapot Check Failed:\n%s\n", output) res.Failed = true diff --git a/pkg/healthcheck/teapot.go b/pkg/healthcheck/teapot.go index 5d9be45..5da6523 100644 --- a/pkg/healthcheck/teapot.go +++ b/pkg/healthcheck/teapot.go @@ -19,9 +19,8 @@ type CheckResult struct { TimePeriod int `json:"time_period"` } -func runTeapot(conf *conf.Conf, actor, repoName string) (checkResults []CheckResult, err error) { +func runTeapot(conf *conf.Conf) (checkResults []CheckResult, err error) { os.Setenv("LOG_FILE_PATH", conf.Teapot.LogPath) - os.Setenv("_TYPER_STANDARD_TRACEBACK", "1") var formattedGroups []string for _, group := range conf.Teapot.Groups { groupConfig := fmt.Sprintf("%s=%d:%d", @@ -29,9 +28,9 @@ func runTeapot(conf *conf.Conf, actor, repoName string) (checkResults []CheckRes formattedGroups = append(formattedGroups, groupConfig) } args := []string{ - "joj3-check", conf.Teapot.EnvFilePath, - actor, conf.Teapot.GradingRepoName, repoName, - conf.Teapot.ScoreboardPath, conf.Name, + "joj3-check-env", conf.Teapot.EnvFilePath, + conf.Teapot.GradingRepoName, + conf.Teapot.ScoreboardPath, "--group-config", strings.Join(formattedGroups, ","), } var stdoutBuf, stderrBuf bytes.Buffer @@ -90,10 +89,8 @@ func generateOutput( return } -func TeapotCheck( - conf *conf.Conf, actor, repoName string, groups []string, -) (output string, err error) { - checkResults, err := runTeapot(conf, actor, repoName) +func TeapotCheck(conf *conf.Conf, groups []string) (output string, err error) { + checkResults, err := runTeapot(conf) if err != nil { slog.Error("teapot check", "error", err) return