Validate and publish source-only candidates

This commit is contained in:
2026-12-05 21:05:56 +00:00
parent 0f9923d230
commit 3b925231d5
18 changed files with 291 additions and 56 deletions

View File

@@ -10,7 +10,7 @@ import (
"go.maximumdirect.net/releasekit/internal/validation"
)
// ErrInvalidVersion reports a version that is not stable vMAJOR.MINOR.PATCH.
// ErrInvalidVersion reports an identifier that does not match its selected format.
var ErrInvalidVersion = candidate.ErrInvalidVersion
// ErrUnexpectedPushURL reports that the effective publication push URL does
@@ -18,15 +18,22 @@ var ErrInvalidVersion = candidate.ErrInvalidVersion
var ErrUnexpectedPushURL = publish.ErrUnexpectedPushURL
// Candidate identifies one committed local source revision selected for
// validation. ModuleDir is the absolute selected module directory, ModulePath
// is its declared Go import path, and Tag is the complete derived Git tag.
// validation. SourceDir is the absolute selected source directory. ModuleDir
// and ModulePath identify a selected Go module and are empty for source-only
// releases. Tag is the complete derived Git tag.
type Candidate struct {
RepositoryDir string
SourceDir string
SourceSubdir string
GoEnabled bool
Publication PublicationMode
VersionFormat VersionFormat
VersionPrefix string
ModuleDir string
ModulePath string
Tag string
Commit string
Version string // selected stable semantic version.
Version string // selected production identifier.
}
// ReleaseRequest contains the inputs used to validate and optionally build one
@@ -43,7 +50,7 @@ type ReleaseRequest struct {
// the ModuleDir Go-module shorthand.
Source *SourceSpec
Product string
Version string // stable semantic version, independent of the derived Git tag.
Version string // production identifier, independent of the derived Git tag.
Remote string
// ExpectedPushURL optionally requires Publish's resolved push URL to match
// this string exactly before validation or tag creation. Check ignores this
@@ -140,12 +147,10 @@ type GoValidationSpec struct {
}
// Check validates one local, committed release candidate. It requires a clean
// worktree and index on main, a selected module declaration and module-local
// committed note matching Product and Version, and an unused local tag. An
// empty ModuleDir selects the repository root. The module declaration
// determines the full Git tag for the semantic Version. It always runs the
// offline Go test suite with the available compatible local Go toolchain and
// Go host target, then calls
// worktree and index on main, a committed source-local note matching Product
// and Version, and an unused local tag. A Go selection also requires a module
// declaration. Nil Source retains the ModuleDir Go-module shorthand. Check
// runs the offline Go test suite when Go is enabled, then calls
// AdditionalChecks when supplied. Validation.Go.Race runs that one suite with
// the race detector, Validation.Go.FullVet runs go vet after the suite instead
// of test-time vet, and Validation.Go.CompileTargets compiles all packages for
@@ -169,7 +174,7 @@ type GoValidationSpec struct {
// Nil disables the check; an empty object enables it. Outside-checkout
// destinations are reported as out of scope unless the selected specification
// enforces the checkout boundary. Submodule contents remain out of scope.
// The zero values of all selections preserve the ordinary suite. If
// The zero values of the legacy module selections preserve the ordinary suite. If
// Build selects targets, Check builds them after validation in temporary
// storage outside the worktree, then rechecks
// branch, HEAD, worktree, index, and local tag state. Success establishes local
@@ -185,6 +190,12 @@ func Check(ctx context.Context, request ReleaseRequest) (Candidate, error) {
func publicCandidate(checked candidate.Candidate) Candidate {
return Candidate{
RepositoryDir: checked.RepositoryDir,
SourceDir: checked.Identity.SourceDir,
SourceSubdir: checked.Identity.SourceSubdir,
GoEnabled: checked.Identity.GoEnabled,
Publication: PublicationMode(checked.Identity.Publication),
VersionFormat: VersionFormat(checked.Identity.VersionFormat),
VersionPrefix: checked.Identity.VersionPrefix,
ModuleDir: checked.ModuleDir,
ModulePath: checked.ModulePath,
Tag: checked.Tag,
@@ -199,6 +210,7 @@ func candidateRequest(request ReleaseRequest) candidate.Request {
RepositoryDir: request.RepositoryDir,
ModuleDir: request.ModuleDir,
Source: internalSourceSpec(request.Source),
BuildTargets: request.Build != nil && len(request.Build.Targets) != 0,
Product: request.Product,
Version: request.Version,
Validation: validation.Settings{