// Package validation owns the shared checks run against a captured candidate. package validation import ( "context" "io" "gitea.maximumdirect.net/eric/ReleaseKit/internal/gotool" ) // Settings selects shared validation behavior. type Settings struct { Race bool } // Request identifies the captured source and output used by shared validation. type Request struct { RepositoryDir string Commit string Output io.Writer Settings Settings } // ReadCandidateTree loads the committed-file inventory when a selected check // needs file-oriented input. func (request Request) ReadCandidateTree(ctx context.Context) (*CandidateTree, error) { return ReadCandidateTree(ctx, request.RepositoryDir, request.Commit) } // Run executes shared validation for the captured candidate. func Run(ctx context.Context, request Request) error { tool, err := gotool.New(ctx, request.RepositoryDir) if err != nil { return &Failure{Check: GoTest, Cause: err} } args := []string{"test", "-mod=readonly", "-count=1"} if request.Settings.Race { args = append(args, "-race") } args = append(args, "./...") _, err = tool.Run(ctx, request.RepositoryDir, gotool.Native, gotool.Target{}, request.Output, args...) if err != nil { return &Failure{Check: GoTest, Cause: err} } return nil }