Make product checks additive
This commit is contained in:
25
publish.go
25
publish.go
@@ -28,7 +28,7 @@ type PublicationPhase string
|
||||
const (
|
||||
// PublicationPreflight identifies local and remote candidate inspection.
|
||||
PublicationPreflight PublicationPhase = PublicationPhase(publish.Preflight)
|
||||
// PublicationValidation identifies the selected validation callback or default suite.
|
||||
// PublicationValidation identifies the standard suite and additional checks.
|
||||
PublicationValidation PublicationPhase = PublicationPhase(publish.Validation)
|
||||
// PublicationTagCreation identifies creation and inspection of the local annotated tag.
|
||||
PublicationTagCreation PublicationPhase = PublicationPhase(publish.TagCreation)
|
||||
@@ -50,8 +50,9 @@ type PublicationResult struct {
|
||||
State PublicationState // publication outcome for this invocation
|
||||
}
|
||||
|
||||
// Publish validates the captured candidate, optionally builds its selected
|
||||
// targets in temporary storage outside the worktree, and pushes its exact
|
||||
// Publish always runs the offline Go test suite for the captured candidate,
|
||||
// then calls AdditionalChecks when supplied. It optionally builds selected
|
||||
// targets in temporary storage outside the worktree and pushes the exact
|
||||
// annotated tag object to the selected remote. It returns a result with errors: preflight
|
||||
// failures are not_attempted, failed authoritative guards are conflict, and
|
||||
// errors after local tag creation but before push are not_published. A failed
|
||||
@@ -61,9 +62,9 @@ type PublicationResult struct {
|
||||
// by the successful push or exact remote object match.
|
||||
func Publish(ctx context.Context, request ReleaseRequest) (PublicationResult, error) {
|
||||
var validate func(context.Context, candidate.Candidate) error
|
||||
if request.Validate != nil {
|
||||
if request.AdditionalChecks != nil {
|
||||
validate = func(ctx context.Context, captured candidate.Candidate) error {
|
||||
return request.Validate(ctx, Candidate{
|
||||
return request.AdditionalChecks(ctx, Candidate{
|
||||
RepositoryDir: captured.RepositoryDir,
|
||||
Commit: captured.Commit,
|
||||
Version: captured.Version,
|
||||
@@ -71,13 +72,13 @@ func Publish(ctx context.Context, request ReleaseRequest) (PublicationResult, er
|
||||
}
|
||||
}
|
||||
result, err := publish.Publish(ctx, publish.Request{
|
||||
RepositoryDir: request.RepositoryDir,
|
||||
Product: request.Product,
|
||||
Version: request.Version,
|
||||
Remote: request.Remote,
|
||||
Validate: validate,
|
||||
AfterValidate: internalbuild.CandidateCallback(internalBuildSpec(request.Build), request.Output),
|
||||
Output: request.Output,
|
||||
RepositoryDir: request.RepositoryDir,
|
||||
Product: request.Product,
|
||||
Version: request.Version,
|
||||
Remote: request.Remote,
|
||||
AdditionalChecks: validate,
|
||||
AfterValidate: internalbuild.CandidateCallback(internalBuildSpec(request.Build), request.Output),
|
||||
Output: request.Output,
|
||||
})
|
||||
return PublicationResult{
|
||||
Version: result.Version,
|
||||
|
||||
Reference in New Issue
Block a user