Compare commits

...

3 Commits

Author SHA1 Message Date
eb77dc6fc4
feat: clean ANSI escape sequences from teapot output
All checks were successful
build / build (push) Successful in 1m40s
build / trigger-build-image (push) Successful in 6s
2024-10-07 16:32:10 -04:00
67e222aa59
feat: support scoreboard & failed table path in conf 2024-10-07 16:26:40 -04:00
1fe7e13c2c
feat: remove env log 2024-10-07 02:46:44 -04:00
2 changed files with 15 additions and 12 deletions

View File

@ -20,6 +20,8 @@ type Conf struct {
OutputPath string `default:"joj3_result.json"`
GradingRepoName string `default:""`
SkipTeapot bool `default:"true"`
ScoreboardPath string `default:"scoreboard.csv"`
FailedTablePath string `default:"failed-table.md"`
Stages []struct {
Name string
Group string

View File

@ -5,6 +5,7 @@ import (
"log/slog"
"os"
"os/exec"
"regexp"
"strings"
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
@ -14,10 +15,6 @@ func Run(conf conf.Conf) error {
if conf.SkipTeapot {
return nil
}
for _, env := range os.Environ() {
pair := strings.SplitN(env, "=", 2)
slog.Info("env", "key", pair[0], "value", pair[1])
}
os.Setenv("LOG_FILE_PATH", "/home/tt/.cache/joint-teapot-debug.log")
os.Setenv("_TYPER_STANDARD_TRACEBACK", "1")
envFilePath := "/home/tt/.config/teapot/teapot.env"
@ -31,28 +28,32 @@ func Run(conf conf.Conf) error {
}
repoParts := strings.Split(repository, "/")
repoName := repoParts[1]
re := regexp.MustCompile(`\x1b\[[0-9;]*[a-zA-Z]`)
cmd := exec.Command("joint-teapot", "joj3-scoreboard",
envFilePath, conf.OutputPath, actor, conf.GradingRepoName, repoName,
runNumber) // #nosec G204
output, err := cmd.CombinedOutput()
slog.Info("joint-teapot joj3-scoreboard", "output", string(output))
runNumber, conf.ScoreboardPath) // #nosec G204
outputBytes, err := cmd.CombinedOutput()
output := re.ReplaceAllString(string(outputBytes), "")
slog.Info("joint-teapot joj3-scoreboard", "output", output)
if err != nil {
slog.Error("joint-teapot joj3-scoreboard", "err", err)
return err
}
cmd = exec.Command("joint-teapot", "joj3-failed-table",
envFilePath, conf.OutputPath, actor, conf.GradingRepoName, repoName,
runNumber) // #nosec G204
output, err = cmd.CombinedOutput()
slog.Info("joint-teapot joj3-failed-table", "output", string(output))
runNumber, conf.FailedTablePath) // #nosec G204
outputBytes, err = cmd.CombinedOutput()
output = re.ReplaceAllString(string(outputBytes), "")
slog.Info("joint-teapot joj3-failed-table", "output", output)
if err != nil {
slog.Error("joint-teapot joj3-failed-table", "err", err)
return err
}
cmd = exec.Command("joint-teapot", "joj3-create-result-issue",
envFilePath, conf.OutputPath, repoName, runNumber) // #nosec G204
output, err = cmd.CombinedOutput()
slog.Info("joint-teapot joj3-create-result-issue", "output", string(output))
outputBytes, err = cmd.CombinedOutput()
output = re.ReplaceAllString(string(outputBytes), "")
slog.Info("joint-teapot joj3-create-result-issue", "output", output)
if err != nil {
slog.Error("joint-teapot joj3-create-result-issue", "err", err)
return err