Validate and publish source-only candidates
This commit is contained in:
@@ -35,6 +35,7 @@ type Request struct {
|
||||
RepositoryDir string
|
||||
ModuleDir string
|
||||
Source *releaseidentity.SourceSpec
|
||||
BuildTargets bool
|
||||
Product string
|
||||
Version string
|
||||
Validation validation.Settings
|
||||
@@ -69,7 +70,7 @@ func Check(ctx context.Context, request Request) (Candidate, error) {
|
||||
// including the note bytes from the captured commit. It does not run checks.
|
||||
func Capture(ctx context.Context, request Request) (Candidate, error) {
|
||||
captured := Candidate{Version: request.Version}
|
||||
if !validStableVersion(request.Version) {
|
||||
if request.Source == nil && !validStableVersion(request.Version) {
|
||||
return captured, fmt.Errorf("%w: %q", ErrInvalidVersion, request.Version)
|
||||
}
|
||||
if strings.TrimSpace(request.Product) == "" {
|
||||
@@ -99,10 +100,13 @@ func Capture(ctx context.Context, request Request) (Candidate, error) {
|
||||
captured.ModulePath = identity.ModulePath
|
||||
captured.Tag = identity.Tag
|
||||
if err != nil {
|
||||
if errors.Is(err, versioncontract.ErrInvalidIdentifier) {
|
||||
return captured, fmt.Errorf("%w: %q", ErrInvalidVersion, request.Version)
|
||||
}
|
||||
return captured, fmt.Errorf("resolve selected module release identity: %w", err)
|
||||
}
|
||||
if identity.Publication == "source" {
|
||||
return captured, fmt.Errorf("general source candidate validation is not yet supported")
|
||||
if !identity.GoEnabled && request.BuildTargets {
|
||||
return captured, errors.New("build targets require Go capability")
|
||||
}
|
||||
note, err := git.ReadCommitFile(ctx, identity.RepositoryDir, state.commit, identity.NotePath)
|
||||
if err != nil {
|
||||
@@ -121,6 +125,7 @@ func Capture(ctx context.Context, request Request) (Candidate, error) {
|
||||
}
|
||||
|
||||
captured.Note = string(note)
|
||||
captured.Identity.Note = captured.Note
|
||||
return captured, nil
|
||||
}
|
||||
|
||||
@@ -134,6 +139,8 @@ func Validate(ctx context.Context, request Request, captured Candidate) error {
|
||||
if err := validation.Run(ctx, validation.Request{
|
||||
RepositoryDir: captured.RepositoryDir,
|
||||
ModuleDir: captured.ModuleDir,
|
||||
SourceDir: captured.Identity.SourceDir,
|
||||
SourceOnly: !captured.Identity.GoEnabled,
|
||||
Commit: captured.Commit,
|
||||
Output: request.Output,
|
||||
Settings: request.Validation,
|
||||
|
||||
Reference in New Issue
Block a user