chore(cmd/joj3): store groups to env
Some checks failed
build / build (push) Failing after 0s
submodules sync / sync (push) Failing after 0s
build / trigger-build-image (push) Has been skipped

This commit is contained in:
张泊明518370910136 2025-01-29 08:27:09 -05:00
parent 454df2c6fc
commit b61e2e8464
GPG Key ID: D47306D7062CDA9D
3 changed files with 13 additions and 3 deletions

7
cmd/joj3/env/env.go vendored
View File

@ -8,6 +8,7 @@ import (
type Attribute struct { type Attribute struct {
ConfName string ConfName string
Groups string
RunID string RunID string
Actor string Actor string
Repository string Repository string
@ -39,3 +40,9 @@ func init() {
Attr.Workflow = os.Getenv("GITHUB_WORKFLOW") Attr.Workflow = os.Getenv("GITHUB_WORKFLOW")
Attr.RunNumber = os.Getenv("GITHUB_RUN_NUMBER") Attr.RunNumber = os.Getenv("GITHUB_RUN_NUMBER")
} }
func Set() {
os.Setenv("CONF_NAME", Attr.ConfName)
os.Setenv("GROUPS", Attr.Groups)
os.Setenv("RUN_ID", Attr.RunID)
}

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"os" "os"
"strings"
"github.com/joint-online-judge/JOJ3/cmd/joj3/env" "github.com/joint-online-judge/JOJ3/cmd/joj3/env"
"github.com/joint-online-judge/JOJ3/cmd/joj3/stage" "github.com/joint-online-judge/JOJ3/cmd/joj3/stage"
@ -116,6 +117,8 @@ func mainImpl() (err error) {
// run stages // run stages
groups := conf.MatchGroups(confObj, conventionalCommit) groups := conf.MatchGroups(confObj, conventionalCommit)
env.Attr.Groups = strings.Join(groups, ",")
env.Set()
stageResults, forceQuitStageName, err = stage.Run( stageResults, forceQuitStageName, err = stage.Run(
confObj, groups, confObj, groups,
) )
@ -128,7 +131,7 @@ func mainImpl() (err error) {
} }
// run teapot // run teapot
teapotRunResult, err = teapot.Run(confObj, groups) teapotRunResult, err = teapot.Run(confObj)
if err != nil { if err != nil {
slog.Error("teapot run", "error", err) slog.Error("teapot run", "error", err)
return err return err

View File

@ -18,7 +18,7 @@ type RunResult struct {
Sha string `json:"sha"` Sha string `json:"sha"`
} }
func Run(conf *conf.Conf, groups []string) ( func Run(conf *conf.Conf) (
runResult RunResult, err error, runResult RunResult, err error,
) { ) {
os.Setenv("LOG_FILE_PATH", conf.Teapot.LogPath) os.Setenv("LOG_FILE_PATH", conf.Teapot.LogPath)
@ -55,7 +55,7 @@ func Run(conf *conf.Conf, groups []string) (
env.Attr.RunNumber, conf.Teapot.ScoreboardPath, env.Attr.RunNumber, conf.Teapot.ScoreboardPath,
conf.Teapot.FailedTablePath, conf.Teapot.FailedTablePath,
conf.Name, env.Attr.Sha, env.Attr.RunID, conf.Name, env.Attr.Sha, env.Attr.RunID,
strings.Join(groups, ","), env.Attr.Groups,
"--max-total-score", strconv.Itoa(conf.MaxTotalScore), "--max-total-score", strconv.Itoa(conf.MaxTotalScore),
skipIssueArg, skipScoreboardArg, skipIssueArg, skipScoreboardArg,
skipFailedTableArg, submitterInIssueTitleArg, skipFailedTableArg, submitterInIssueTitleArg,