Report only fully hashed build artifacts
This commit is contained in:
@@ -50,10 +50,7 @@ type Result struct {
|
||||
SourceVerified bool
|
||||
Settings artifact.Settings
|
||||
Version string
|
||||
MainPackage string
|
||||
BinaryName string
|
||||
OutputDir string
|
||||
Targets []Target
|
||||
Artifacts []Artifact
|
||||
Compiler string
|
||||
}
|
||||
@@ -68,9 +65,6 @@ func BuildResolved(ctx context.Context, request Request) (Result, error) {
|
||||
Tag: identity.Tag,
|
||||
Settings: settings,
|
||||
Version: identity.Version,
|
||||
MainPackage: settings.MainPackage,
|
||||
BinaryName: settings.BinaryName,
|
||||
Targets: settings.Targets,
|
||||
}
|
||||
if !versioncontract.ValidStableVersion(identity.Version) {
|
||||
return result, fmt.Errorf("%w: %q", candidate.ErrInvalidVersion, identity.Version)
|
||||
@@ -78,14 +72,14 @@ func BuildResolved(ctx context.Context, request Request) (Result, error) {
|
||||
if identity.RepositoryDir == "" || identity.ModuleDir == "" || identity.ModulePath == "" {
|
||||
return result, errors.New("build requires a resolved module identity")
|
||||
}
|
||||
if len(result.Targets) != 0 {
|
||||
if len(settings.Targets) != 0 {
|
||||
if settings.MainPackage == "" {
|
||||
return result, errors.New("build requires a main package when targets are selected")
|
||||
}
|
||||
if !artifact.ValidComponent(settings.BinaryName) {
|
||||
return result, fmt.Errorf("unsafe binary name %q", settings.BinaryName)
|
||||
}
|
||||
for _, target := range result.Targets {
|
||||
for _, target := range settings.Targets {
|
||||
if !artifact.ValidComponent(target.OS) || !artifact.ValidComponent(target.Arch) {
|
||||
return result, fmt.Errorf("unsafe target %q/%q", target.OS, target.Arch)
|
||||
}
|
||||
@@ -114,7 +108,7 @@ func BuildResolved(ctx context.Context, request Request) (Result, error) {
|
||||
return result, fmt.Errorf("inspect build source: %w", err)
|
||||
}
|
||||
|
||||
if len(result.Targets) == 0 {
|
||||
if len(settings.Targets) == 0 {
|
||||
result.OutputDir = artifact.OutputDirectory(moduleDir, request.OutputDir)
|
||||
return result, nil
|
||||
}
|
||||
@@ -145,7 +139,7 @@ func BuildResolved(ctx context.Context, request Request) (Result, error) {
|
||||
goHost := goTool.HostTarget()
|
||||
host := Target{OS: goHost.OS, Arch: goHost.Arch}
|
||||
|
||||
for index, target := range result.Targets {
|
||||
for index, target := range settings.Targets {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return result, fmt.Errorf("build canceled: %w", err)
|
||||
}
|
||||
@@ -158,10 +152,10 @@ func BuildResolved(ctx context.Context, request Request) (Result, error) {
|
||||
return result, fmt.Errorf("build target %s/%s: %w", target.OS, target.Arch, err)
|
||||
}
|
||||
artifact := Artifact{Path: path, Filename: filename, Target: target}
|
||||
result.Artifacts = append(result.Artifacts, artifact)
|
||||
if err := hashArtifact(&result.Artifacts[len(result.Artifacts)-1]); err != nil {
|
||||
if err := hashArtifact(&artifact); err != nil {
|
||||
return result, fmt.Errorf("hash build output %q: %w", path, err)
|
||||
}
|
||||
result.Artifacts = append(result.Artifacts, artifact)
|
||||
}
|
||||
|
||||
var smokePath string
|
||||
|
||||
Reference in New Issue
Block a user