chore(cmd/joj3): store groups to env
This commit is contained in:
		
							parent
							
								
									454df2c6fc
								
							
						
					
					
						commit
						b61e2e8464
					
				
							
								
								
									
										7
									
								
								cmd/joj3/env/env.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								cmd/joj3/env/env.go
									
									
									
									
										vendored
									
									
								
							|  | @ -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) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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 | ||||||
|  |  | ||||||
|  | @ -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, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user