From 872adf1621d9d0b095cfe88368d75b8ef60cd9c5 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Tue, 8 Oct 2024 17:53:36 -0400 Subject: [PATCH 01/11] refactor(cmd/joj): re-group conf --- cmd/joj3/conf/conf.go | 25 +++++++++++++++---------- cmd/joj3/stage/main.go | 7 +++++-- cmd/joj3/teapot/main.go | 14 +++++++------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index 944e62c..d14ae1c 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -14,16 +14,21 @@ import ( ) type Conf struct { - SandboxExecServer string `default:"localhost:5051"` - SandboxToken string `default:""` - LogPath string `default:""` - OutputPath string `default:"joj3_result.json"` - GradingRepoName string `default:""` - SkipTeapot bool `default:"true"` - ScoreboardPath string `default:"scoreboard.csv"` - FailedTablePath string `default:"failed-table.md"` - Name string `default:"unknown"` - Stages []struct { + Name string `default:"unknown"` + LogPath string `default:""` + Stage struct { + SandboxExecServer string `default:"localhost:5051"` + SandboxToken string `default:""` + OutputPath string `default:"stages_result.json"` + } + Teapot struct { + Skip bool `default:"true"` + LogPath string `default:"/home/tt/.cache/joint-teapot-debug.log"` + ScoreboardPath string `default:"scoreboard.csv"` + FailedTablePath string `default:"failed-table.md"` + GradingRepoName string `default:""` + } + Stages []struct { Name string Group string Executor struct { diff --git a/cmd/joj3/stage/main.go b/cmd/joj3/stage/main.go index 8d88791..51a857e 100644 --- a/cmd/joj3/stage/main.go +++ b/cmd/joj3/stage/main.go @@ -74,7 +74,10 @@ func outputResult(outputPath string, results []stage.StageResult) error { } func Run(conf conf.Conf, group string) error { - executors.InitWithConf(conf.SandboxExecServer, conf.SandboxToken) + executors.InitWithConf( + conf.Stage.SandboxExecServer, + conf.Stage.SandboxToken, + ) stages, err := generateStages(conf, group) if err != nil { slog.Error("generate stages", "error", err) @@ -86,7 +89,7 @@ func Run(conf conf.Conf, group string) error { slog.Error("run stages", "error", err) return err } - if err := outputResult(conf.OutputPath, results); err != nil { + if err := outputResult(conf.Stage.OutputPath, results); err != nil { slog.Error("output result", "error", err) return err } diff --git a/cmd/joj3/teapot/main.go b/cmd/joj3/teapot/main.go index 74a4a60..a88d872 100644 --- a/cmd/joj3/teapot/main.go +++ b/cmd/joj3/teapot/main.go @@ -12,10 +12,10 @@ import ( ) func Run(conf conf.Conf) error { - if conf.SkipTeapot { + if conf.Teapot.Skip { return nil } - os.Setenv("LOG_FILE_PATH", "/home/tt/.cache/joint-teapot-debug.log") + os.Setenv("LOG_FILE_PATH", conf.Teapot.LogPath) os.Setenv("_TYPER_STANDARD_TRACEBACK", "1") envFilePath := "/home/tt/.config/teapot/teapot.env" actor := os.Getenv("GITHUB_ACTOR") @@ -30,8 +30,8 @@ func Run(conf conf.Conf) error { 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, conf.ScoreboardPath, conf.Name) // #nosec G204 + envFilePath, conf.Stage.OutputPath, actor, conf.Teapot.GradingRepoName, + repoName, runNumber, conf.Teapot.ScoreboardPath, conf.Name) // #nosec G204 outputBytes, err := cmd.CombinedOutput() output := re.ReplaceAllString(string(outputBytes), "") for _, line := range strings.Split(output, "\n") { @@ -45,8 +45,8 @@ func Run(conf conf.Conf) error { return err } cmd = exec.Command("joint-teapot", "joj3-failed-table", - envFilePath, conf.OutputPath, actor, conf.GradingRepoName, repoName, - runNumber, conf.FailedTablePath, conf.Name) // #nosec G204 + envFilePath, conf.Stage.OutputPath, actor, conf.Teapot.GradingRepoName, + repoName, runNumber, conf.Teapot.FailedTablePath, conf.Name) // #nosec G204 outputBytes, err = cmd.CombinedOutput() output = re.ReplaceAllString(string(outputBytes), "") for _, line := range strings.Split(output, "\n") { @@ -60,7 +60,7 @@ func Run(conf conf.Conf) error { return err } cmd = exec.Command("joint-teapot", "joj3-create-result-issue", - envFilePath, conf.OutputPath, repoName, runNumber, conf.Name) // #nosec G204 + envFilePath, conf.Stage.OutputPath, repoName, runNumber, conf.Name) // #nosec G204 outputBytes, err = cmd.CombinedOutput() output = re.ReplaceAllString(string(outputBytes), "") for _, line := range strings.Split(output, "\n") { -- 2.30.2 From 66122f71947bf7523f2180b19146655479c22e2f Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Tue, 8 Oct 2024 18:25:09 -0400 Subject: [PATCH 02/11] refactor(cmd/joj): put stages into stage conf --- cmd/joj3/conf/conf.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index d14ae1c..177343a 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -20,6 +20,21 @@ type Conf struct { SandboxExecServer string `default:"localhost:5051"` SandboxToken string `default:""` OutputPath string `default:"stages_result.json"` + Stages []struct { + Name string + Group string + Executor struct { + Name string + With struct { + Default stage.Cmd + Cases []OptionalCmd + } + } + Parser struct { + Name string + With interface{} + } + } } Teapot struct { Skip bool `default:"true"` @@ -28,21 +43,6 @@ type Conf struct { FailedTablePath string `default:"failed-table.md"` GradingRepoName string `default:""` } - Stages []struct { - Name string - Group string - Executor struct { - Name string - With struct { - Default stage.Cmd - Cases []OptionalCmd - } - } - Parser struct { - Name string - With interface{} - } - } } type OptionalCmd struct { -- 2.30.2 From 9f17bb317dc57b0ea586ef66613b2561b0461de0 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Wed, 9 Oct 2024 05:00:57 -0400 Subject: [PATCH 03/11] docs(cmd/joj3): add TODO --- cmd/joj3/conf/conf.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index 177343a..f17efd7 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -36,6 +36,7 @@ type Conf struct { } } } + // TODO: allow skip scoreboard/failed table/issue Teapot struct { Skip bool `default:"true"` LogPath string `default:"/home/tt/.cache/joint-teapot-debug.log"` -- 2.30.2 From 6620f9bc28841fe2dc41a5176feab9562e9ec53b Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Wed, 9 Oct 2024 18:50:06 -0400 Subject: [PATCH 04/11] feat!: support multiple parsers in one stage (#52) --- cmd/joj3/conf/conf.go | 2 +- cmd/joj3/stage/main.go | 20 +++++++++---- internal/stage/model.go | 17 +++++++---- internal/stage/run.go | 64 +++++++++++++++++++++++++---------------- 4 files changed, 67 insertions(+), 36 deletions(-) diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index f17efd7..b038cda 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -30,7 +30,7 @@ type Conf struct { Cases []OptionalCmd } } - Parser struct { + Parsers []struct { Name string With interface{} } diff --git a/cmd/joj3/stage/main.go b/cmd/joj3/stage/main.go index 51a857e..33fd449 100644 --- a/cmd/joj3/stage/main.go +++ b/cmd/joj3/stage/main.go @@ -16,7 +16,7 @@ import ( func generateStages(conf conf.Conf, group string) ([]stage.Stage, error) { stages := []stage.Stage{} existNames := map[string]bool{} - for _, s := range conf.Stages { + for _, s := range conf.Stage.Stages { if s.Group != "" && group != s.Group { continue } @@ -50,12 +50,20 @@ func generateStages(conf conf.Conf, group string) ([]stage.Stage, error) { if len(s.Executor.With.Cases) == 0 { cmds = []stage.Cmd{defaultCmd} } + parsers := []stage.StageParser{} + for _, p := range s.Parsers { + parsers = append(parsers, stage.StageParser{ + Name: p.Name, + Conf: p.With, + }) + } stages = append(stages, stage.Stage{ - Name: s.Name, - ExecutorName: s.Executor.Name, - ExecutorCmds: cmds, - ParserName: s.Parser.Name, - ParserConf: s.Parser.With, + Name: s.Name, + Executor: stage.StageExecutor{ + Name: s.Executor.Name, + Cmds: cmds, + }, + Parsers: parsers, }) } slog.Debug("stages generated", "stages", stages) diff --git a/internal/stage/model.go b/internal/stage/model.go index bd21dd7..a6c7e79 100644 --- a/internal/stage/model.go +++ b/internal/stage/model.go @@ -150,12 +150,19 @@ func (r ExecutorResult) String() string { return fmt.Sprintf("%+v", d) } +type StageExecutor struct { + Name string + Cmds []Cmd +} +type StageParser struct { + Name string + Conf any +} + type Stage struct { - Name string - ExecutorName string - ExecutorCmds []Cmd - ParserName string - ParserConf any + Name string + Executor StageExecutor + Parsers []StageParser } type ParserResult struct { diff --git a/internal/stage/run.go b/internal/stage/run.go index 4e346bc..aa95468 100644 --- a/internal/stage/run.go +++ b/internal/stage/run.go @@ -8,51 +8,67 @@ import ( func Run(stages []Stage) (stageResults []StageResult, err error) { var executorResults []ExecutorResult var parserResults []ParserResult + var tmpParserResults []ParserResult var forceQuit bool slog.Info("stage run start") for _, stage := range stages { slog.Info("stage start", "name", stage.Name) - slog.Info("executor run start", "name", stage.ExecutorName) - slog.Debug("executor run start", "name", stage.ExecutorName, - "cmds", stage.ExecutorCmds) - executor, ok := executorMap[stage.ExecutorName] + slog.Info("executor run start", "name", stage.Executor.Name) + slog.Debug("executor run start", "name", stage.Executor.Name, + "cmds", stage.Executor.Cmds) + executor, ok := executorMap[stage.Executor.Name] if !ok { - slog.Error("executor not found", "name", stage.ExecutorName) - err = fmt.Errorf("executor not found: %s", stage.ExecutorName) + slog.Error("executor not found", "name", stage.Executor.Name) + err = fmt.Errorf("executor not found: %s", stage.Executor.Name) return } - executorResults, err = executor.Run(stage.ExecutorCmds) + executorResults, err = executor.Run(stage.Executor.Cmds) if err != nil { - slog.Error("executor run error", "name", stage.ExecutorName, "error", err) + slog.Error("executor run error", "name", stage.Executor.Name, "error", err) return } slog.Debug("executor run done", "results", executorResults) for _, executorResult := range executorResults { slog.Debug("executor run done", "result.Files", executorResult.Files) } - slog.Info("parser run start", "name", stage.ParserName) - slog.Debug("parser run start", "name", stage.ParserName, - "conf", stage.ParserConf) - parser, ok := parserMap[stage.ParserName] - if !ok { - slog.Error("parser not found", "name", stage.ParserName) - err = fmt.Errorf("parser not found: %s", stage.ParserName) - return + parserResults = []ParserResult{} + for _, stageParser := range stage.Parsers { + slog.Info("parser run start", "name", stageParser.Name) + slog.Debug("parser run start", "name", stageParser.Name, + "conf", stageParser.Conf) + parser, ok := parserMap[stageParser.Name] + if !ok { + slog.Error("parser not found", "name", stageParser.Name) + err = fmt.Errorf("parser not found: %s", stageParser.Name) + return + } + tmpParserResults, forceQuit, err = parser.Run( + executorResults, stageParser.Conf) + if err != nil { + slog.Error("parser run error", "name", stageParser.Name, "error", err) + return + } + slog.Debug("parser run done", "results", tmpParserResults) + if len(parserResults) == 0 { + parserResults = tmpParserResults + } else { + for i := range len(parserResults) { + parserResults[i].Score += tmpParserResults[i].Score + parserResults[i].Comment += tmpParserResults[i].Comment + } + } + if forceQuit { + slog.Error("parser force quit", "name", stageParser.Name) + break + } } - parserResults, forceQuit, err = parser.Run(executorResults, stage.ParserConf) - if err != nil { - slog.Error("parser run error", "name", stage.ParserName, "error", err) - return - } - slog.Debug("parser run done", "results", parserResults) stageResults = append(stageResults, StageResult{ Name: stage.Name, Results: parserResults, ForceQuit: forceQuit, }) if forceQuit { - slog.Error("parser force quit", "name", stage.ParserName) - return + break } } return -- 2.30.2 From 4eb030a6d66fc362fc7e0859159242fabd453a48 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Fri, 11 Oct 2024 04:42:19 -0400 Subject: [PATCH 05/11] feat(stage): parser force quit only on stage ends --- internal/stage/run.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/stage/run.go b/internal/stage/run.go index aa95468..b303e7c 100644 --- a/internal/stage/run.go +++ b/internal/stage/run.go @@ -32,6 +32,7 @@ func Run(stages []Stage) (stageResults []StageResult, err error) { slog.Debug("executor run done", "result.Files", executorResult.Files) } parserResults = []ParserResult{} + stageForceQuit := false for _, stageParser := range stage.Parsers { slog.Info("parser run start", "name", stageParser.Name) slog.Debug("parser run start", "name", stageParser.Name, @@ -48,6 +49,7 @@ func Run(stages []Stage) (stageResults []StageResult, err error) { slog.Error("parser run error", "name", stageParser.Name, "error", err) return } + stageForceQuit = stageForceQuit || forceQuit slog.Debug("parser run done", "results", tmpParserResults) if len(parserResults) == 0 { parserResults = tmpParserResults @@ -59,15 +61,14 @@ func Run(stages []Stage) (stageResults []StageResult, err error) { } if forceQuit { slog.Error("parser force quit", "name", stageParser.Name) - break } } stageResults = append(stageResults, StageResult{ Name: stage.Name, Results: parserResults, - ForceQuit: forceQuit, + ForceQuit: stageForceQuit, }) - if forceQuit { + if stageForceQuit { break } } -- 2.30.2 From 214f5e76e89ca64f334d4a8bfe5126cf0fac35ad Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 12 Oct 2024 00:25:28 -0400 Subject: [PATCH 06/11] feat(cmd/joj3): skip teapot config --- cmd/joj3/conf/conf.go | 5 ++- cmd/joj3/teapot/main.go | 88 +++++++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 41 deletions(-) diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index b038cda..5d3478c 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -36,13 +36,14 @@ type Conf struct { } } } - // TODO: allow skip scoreboard/failed table/issue Teapot struct { - Skip bool `default:"true"` LogPath string `default:"/home/tt/.cache/joint-teapot-debug.log"` ScoreboardPath string `default:"scoreboard.csv"` FailedTablePath string `default:"failed-table.md"` GradingRepoName string `default:""` + SkipIssue bool `default:"false"` + SkipScoreboard bool `default:"false"` + SkipFailedTable bool `default:"false"` } } diff --git a/cmd/joj3/teapot/main.go b/cmd/joj3/teapot/main.go index a88d872..3fb6003 100644 --- a/cmd/joj3/teapot/main.go +++ b/cmd/joj3/teapot/main.go @@ -12,12 +12,16 @@ import ( ) func Run(conf conf.Conf) error { - if conf.Teapot.Skip { + actions := os.Getenv("GITHUB_ACTIONS") + if actions != "true" { + slog.Info("teapot exit", "GITHUB_ACTIONS", actions) return nil } os.Setenv("LOG_FILE_PATH", conf.Teapot.LogPath) os.Setenv("_TYPER_STANDARD_TRACEBACK", "1") envFilePath := "/home/tt/.config/teapot/teapot.env" + // TODO: pass sha to joint-teapot + // sha := os.Getenv("GITHUB_SHA") actor := os.Getenv("GITHUB_ACTOR") repository := os.Getenv("GITHUB_REPOSITORY") runNumber := os.Getenv("GITHUB_RUN_NUMBER") @@ -29,49 +33,55 @@ 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.Stage.OutputPath, actor, conf.Teapot.GradingRepoName, - repoName, runNumber, conf.Teapot.ScoreboardPath, conf.Name) // #nosec G204 - outputBytes, err := cmd.CombinedOutput() - output := re.ReplaceAllString(string(outputBytes), "") - for _, line := range strings.Split(output, "\n") { - if line == "" { - continue + if !conf.Teapot.SkipScoreboard { + cmd := exec.Command("joint-teapot", "joj3-scoreboard", + envFilePath, conf.Stage.OutputPath, actor, conf.Teapot.GradingRepoName, + repoName, runNumber, conf.Teapot.ScoreboardPath, conf.Name) // #nosec G204 + outputBytes, err := cmd.CombinedOutput() + output := re.ReplaceAllString(string(outputBytes), "") + for _, line := range strings.Split(output, "\n") { + if line == "" { + continue + } + slog.Info("joint-teapot joj3-scoreboard", "output", line) } - slog.Info("joint-teapot joj3-scoreboard", "output", line) - } - if err != nil { - slog.Error("joint-teapot joj3-scoreboard", "err", err) - return err - } - cmd = exec.Command("joint-teapot", "joj3-failed-table", - envFilePath, conf.Stage.OutputPath, actor, conf.Teapot.GradingRepoName, - repoName, runNumber, conf.Teapot.FailedTablePath, conf.Name) // #nosec G204 - outputBytes, err = cmd.CombinedOutput() - output = re.ReplaceAllString(string(outputBytes), "") - for _, line := range strings.Split(output, "\n") { - if line == "" { - continue + if err != nil { + slog.Error("joint-teapot joj3-scoreboard", "err", err) + return err } - slog.Info("joint-teapot joj3-failed-table", "output", line) } - 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.Stage.OutputPath, repoName, runNumber, conf.Name) // #nosec G204 - outputBytes, err = cmd.CombinedOutput() - output = re.ReplaceAllString(string(outputBytes), "") - for _, line := range strings.Split(output, "\n") { - if line == "" { - continue + if !conf.Teapot.SkipFailedTable { + cmd := exec.Command("joint-teapot", "joj3-failed-table", + envFilePath, conf.Stage.OutputPath, actor, conf.Teapot.GradingRepoName, + repoName, runNumber, conf.Teapot.FailedTablePath, conf.Name) // #nosec G204 + outputBytes, err := cmd.CombinedOutput() + output := re.ReplaceAllString(string(outputBytes), "") + for _, line := range strings.Split(output, "\n") { + if line == "" { + continue + } + slog.Info("joint-teapot joj3-failed-table", "output", line) + } + if err != nil { + slog.Error("joint-teapot joj3-failed-table", "err", err) + return err } - slog.Info("joint-teapot joj3-create-result-issue", "output", line) } - if err != nil { - slog.Error("joint-teapot joj3-create-result-issue", "err", err) - return err + if !conf.Teapot.SkipIssue { + cmd := exec.Command("joint-teapot", "joj3-create-result-issue", + envFilePath, conf.Stage.OutputPath, repoName, runNumber, conf.Name) // #nosec G204 + outputBytes, err := cmd.CombinedOutput() + output := re.ReplaceAllString(string(outputBytes), "") + for _, line := range strings.Split(output, "\n") { + if line == "" { + continue + } + slog.Info("joint-teapot joj3-create-result-issue", "output", line) + } + if err != nil { + slog.Error("joint-teapot joj3-create-result-issue", "err", err) + return err + } } return nil } -- 2.30.2 From adba2e4a1d51b4bcb62e2a15b25bf6764c82dc67 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 12 Oct 2024 00:52:46 -0400 Subject: [PATCH 07/11] feat(cmd/joj3): make it backward compatible --- cmd/joj3/conf/conf.go | 76 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 16 deletions(-) diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index 5d3478c..72fb036 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -13,28 +13,30 @@ import ( "github.com/koding/multiconfig" ) +type ConfStage struct { + Name string + Group string + Executor struct { + Name string + With struct { + Default stage.Cmd + Cases []OptionalCmd + } + } + Parsers []struct { + Name string + With interface{} + } +} + type Conf struct { Name string `default:"unknown"` LogPath string `default:""` Stage struct { SandboxExecServer string `default:"localhost:5051"` SandboxToken string `default:""` - OutputPath string `default:"stages_result.json"` - Stages []struct { - Name string - Group string - Executor struct { - Name string - With struct { - Default stage.Cmd - Cases []OptionalCmd - } - } - Parsers []struct { - Name string - With interface{} - } - } + OutputPath string `default:"joj3_result.json"` + Stages []ConfStage } Teapot struct { LogPath string `default:"/home/tt/.cache/joint-teapot-debug.log"` @@ -45,6 +47,29 @@ type Conf struct { SkipScoreboard bool `default:"false"` SkipFailedTable bool `default:"false"` } + // TODO: remove the following backward compatibility fields + SandboxExecServer string `default:"localhost:5051"` + SandboxToken string `default:""` + 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 + Executor struct { + Name string + With struct { + Default stage.Cmd + Cases []OptionalCmd + } + } + Parser struct { + Name string + With interface{} + } + } } type OptionalCmd struct { @@ -134,6 +159,25 @@ func parseConfFile(path string) (conf Conf, err error) { slog.Error("validate stages conf", "error", err) return } + // TODO: remove the following backward compatibility codes + conf.Stage.SandboxExecServer = conf.SandboxExecServer + conf.Stage.SandboxToken = conf.SandboxToken + conf.Stage.OutputPath = conf.OutputPath + conf.Stage.Stages = make([]ConfStage, len(conf.Stages)) + for i, stage := range conf.Stages { + conf.Stage.Stages[i].Name = stage.Name + conf.Stage.Stages[i].Group = stage.Group + conf.Stage.Stages[i].Executor = stage.Executor + conf.Stage.Stages[i].Parsers = []struct { + Name string + With interface{} + }{ + { + Name: stage.Parser.Name, + With: stage.Parser.With, + }, + } + } return } -- 2.30.2 From 01133d4dff0e68b60cf85064ea8b9520345d85f6 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 12 Oct 2024 01:02:07 -0400 Subject: [PATCH 08/11] chore: fix ci-test --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 70840d3..b9a81b2 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,5 @@ test: ci-test: ./scripts/prepare_test_repos.sh $(TMP_DIR) ./scripts/run_foreach_test_repos.sh $(TMP_DIR) "sed -i '2i \ \ \"sandboxExecServer\": \"172.17.0.1:5051\",' conf.json" + export GITHUB_ACTIONS="test" go test -coverprofile cover.out -v ./... -- 2.30.2 From b23c0894ea2c24903b80641189083516fb8a37ce Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 12 Oct 2024 01:05:09 -0400 Subject: [PATCH 09/11] chore: log GITHUB_ACTIONS --- Makefile | 3 +-- cmd/joj3/teapot/main.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b9a81b2..67c1186 100644 --- a/Makefile +++ b/Makefile @@ -30,5 +30,4 @@ test: ci-test: ./scripts/prepare_test_repos.sh $(TMP_DIR) ./scripts/run_foreach_test_repos.sh $(TMP_DIR) "sed -i '2i \ \ \"sandboxExecServer\": \"172.17.0.1:5051\",' conf.json" - export GITHUB_ACTIONS="test" - go test -coverprofile cover.out -v ./... + GITHUB_ACTIONS="test" go test -coverprofile cover.out -v ./... diff --git a/cmd/joj3/teapot/main.go b/cmd/joj3/teapot/main.go index 3fb6003..3bdee79 100644 --- a/cmd/joj3/teapot/main.go +++ b/cmd/joj3/teapot/main.go @@ -13,6 +13,7 @@ import ( func Run(conf conf.Conf) error { actions := os.Getenv("GITHUB_ACTIONS") + slog.Info("teapot start", "GITHUB_ACTIONS", actions) if actions != "true" { slog.Info("teapot exit", "GITHUB_ACTIONS", actions) return nil -- 2.30.2 From 40fc67a60da23aa2bf2aa2f9038af8e9de0ec473 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 12 Oct 2024 01:07:46 -0400 Subject: [PATCH 10/11] chore: remove log GITHUB_ACTIONS --- cmd/joj3/teapot/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/joj3/teapot/main.go b/cmd/joj3/teapot/main.go index 3bdee79..3fb6003 100644 --- a/cmd/joj3/teapot/main.go +++ b/cmd/joj3/teapot/main.go @@ -13,7 +13,6 @@ import ( func Run(conf conf.Conf) error { actions := os.Getenv("GITHUB_ACTIONS") - slog.Info("teapot start", "GITHUB_ACTIONS", actions) if actions != "true" { slog.Info("teapot exit", "GITHUB_ACTIONS", actions) return nil -- 2.30.2 From 459d1bf53db91721462bc8487eba64a4ef11ac8e Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 12 Oct 2024 01:18:25 -0400 Subject: [PATCH 11/11] feat(cmd/joj3): trigger old conf on new stages empty --- cmd/joj3/conf/conf.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index 72fb036..403aa6c 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -160,22 +160,24 @@ func parseConfFile(path string) (conf Conf, err error) { return } // TODO: remove the following backward compatibility codes - conf.Stage.SandboxExecServer = conf.SandboxExecServer - conf.Stage.SandboxToken = conf.SandboxToken - conf.Stage.OutputPath = conf.OutputPath - conf.Stage.Stages = make([]ConfStage, len(conf.Stages)) - for i, stage := range conf.Stages { - conf.Stage.Stages[i].Name = stage.Name - conf.Stage.Stages[i].Group = stage.Group - conf.Stage.Stages[i].Executor = stage.Executor - conf.Stage.Stages[i].Parsers = []struct { - Name string - With interface{} - }{ - { - Name: stage.Parser.Name, - With: stage.Parser.With, - }, + if len(conf.Stage.Stages) == 0 { + conf.Stage.SandboxExecServer = conf.SandboxExecServer + conf.Stage.SandboxToken = conf.SandboxToken + conf.Stage.OutputPath = conf.OutputPath + conf.Stage.Stages = make([]ConfStage, len(conf.Stages)) + for i, stage := range conf.Stages { + conf.Stage.Stages[i].Name = stage.Name + conf.Stage.Stages[i].Group = stage.Group + conf.Stage.Stages[i].Executor = stage.Executor + conf.Stage.Stages[i].Parsers = []struct { + Name string + With interface{} + }{ + { + Name: stage.Parser.Name, + With: stage.Parser.With, + }, + } } } return -- 2.30.2