42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
// 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. Its zero value runs the current
|
|
// default Go suite.
|
|
type Settings struct{}
|
|
|
|
// 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}
|
|
}
|
|
_, err = tool.Run(ctx, request.RepositoryDir, gotool.Native, gotool.Target{}, request.Output,
|
|
"test", "-mod=readonly", "-count=1", "./...")
|
|
if err != nil {
|
|
return &Failure{Check: GoTest, Cause: err}
|
|
}
|
|
return nil
|
|
}
|