Retain safe CI diagnostics in rehearsal results
This commit is contained in:
@@ -64,6 +64,8 @@ func TestCleanupCommandSelectsExplicitRecordAndReportsSeparateOutcome(t *testing
|
||||
t.Fatal(err)
|
||||
}
|
||||
record := rehearsal.Attempt{Forge: "gitea", Manifest: manifest, RepositoryDir: repo, TagObject: object, Outcomes: map[string]string{"tag": "created", "push": "not_attempted", "workflow": "failed", "verification": "incomplete", "cleanup": "pending"}}
|
||||
record.JobEvidence = &rehearsal.JobResult{Manifest: manifest, Scope: "page", Build: "not_requested", Delivery: "not_attempted", Verification: "not_attempted", Diagnostics: []string{"delivery credential unavailable", "prepare build dependencies", "diagnostic delivery failed"}}
|
||||
|
||||
store, err := rehearsal.CreateAttempt(t.Context(), repo, "", record)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -74,6 +76,11 @@ func TestCleanupCommandSelectsExplicitRecordAndReportsSeparateOutcome(t *testing
|
||||
if err := json.Unmarshal(output.Bytes(), &doc); err != nil || status != 0 || doc.Cleanup != "complete" || doc.Verification != "incomplete" || doc.RecordPath != store.Path {
|
||||
t.Fatalf("status=%d output=%s diagnostics=%s error=%v", status, &output, &diagnostics, err)
|
||||
}
|
||||
for _, phase := range record.JobEvidence.Diagnostics {
|
||||
if !strings.Contains(output.String(), phase) {
|
||||
t.Fatalf("JSON dropped job phase %q: %s", phase, &output)
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(repo, ".git", "refs", "tags", filepath.FromSlash(identity.Tag))); !os.IsNotExist(err) {
|
||||
t.Fatalf("local tag remains: %v", err)
|
||||
}
|
||||
@@ -87,6 +94,11 @@ func TestCleanupCommandSelectsExplicitRecordAndReportsSeparateOutcome(t *testing
|
||||
binary := buildWorkflowCLI(t, cliRepositoryRoot(t))
|
||||
command := exec.Command(binary, "test-cleanup", "--record", store.Path)
|
||||
text, err := command.CombinedOutput()
|
||||
for _, phase := range record.JobEvidence.Diagnostics {
|
||||
if !strings.Contains(string(text), phase) {
|
||||
t.Fatalf("human output dropped job phase %q: %s", phase, text)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("built cleanup: %v: %s", err, text)
|
||||
}
|
||||
|
||||
@@ -311,6 +311,11 @@ writes across ordinary and diagnostic CI exit mapping.
|
||||
|
||||
## 7. Safe job diagnostics disappear from public and CLI results
|
||||
|
||||
**Completed:** The shared facade outcome conversion projects saved safe job
|
||||
phase messages with attempt context, including results reconstructed by cleanup
|
||||
and resume. Regression coverage retains credential, dependency, and delivery
|
||||
phase messages in public results and human/JSON CLI output; focused tests pass.
|
||||
|
||||
**Priority:** P2. **Stages:** 11–14.
|
||||
|
||||
**Relevant code:** [`observe`](../../internal/rehearsal/coordinator.go) saves
|
||||
|
||||
@@ -84,7 +84,8 @@ type RehearsalResult struct {
|
||||
Workflows []RehearsalWorkflow
|
||||
Artifacts []RehearsalArtifact
|
||||
Remaining []string
|
||||
Diagnostics []string
|
||||
// Diagnostics includes safe phase messages retained from CI evidence.
|
||||
Diagnostics []string
|
||||
}
|
||||
|
||||
// RehearsalError preserves the underlying failure or cancellation with Unwrap.
|
||||
@@ -216,6 +217,9 @@ func publicRehearsalOutcome(outcome rehearsal.Outcome) RehearsalResult {
|
||||
}
|
||||
if attempt.JobEvidence != nil {
|
||||
result.Scope = attempt.JobEvidence.Scope
|
||||
for _, message := range attempt.JobEvidence.Diagnostics {
|
||||
result.Diagnostics = append(result.Diagnostics, fmt.Sprintf("CI delivery for attempt %s: %s", manifest.AttemptID, message))
|
||||
}
|
||||
for _, a := range attempt.JobEvidence.Artifacts {
|
||||
result.Artifacts = append(result.Artifacts, RehearsalArtifact{Name: a.Name, Size: a.Size, SHA256: a.SHA256})
|
||||
}
|
||||
|
||||
45
rehearsal_diagnostics_test.go
Normal file
45
rehearsal_diagnostics_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package releasekit_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
releasekit "go.maximumdirect.net/releasekit"
|
||||
"go.maximumdirect.net/releasekit/internal/rehearsal"
|
||||
"go.maximumdirect.net/releasekit/internal/releaseidentity"
|
||||
)
|
||||
|
||||
func TestRecoveryRetainsSafeJobPhaseDiagnostics(t *testing.T) {
|
||||
repo := newTaggedDeliveryConsumer(t)
|
||||
profile := []byte(`{"fixture":true}`)
|
||||
writeBuildFixture(t, repo, "releasekit.json", string(profile))
|
||||
buildGit(t, repo, "add", "releasekit.json")
|
||||
buildGit(t, repo, "commit", "-m", "capture rehearsal profile")
|
||||
commit := buildGit(t, repo, "rev-parse", "HEAD")
|
||||
source, err := releaseidentity.LoadCommittedSource(t.Context(), repo, "", commit, &releaseidentity.SourceSpec{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, phase := range []string{"delivery credential unavailable", "prepare build dependencies", "diagnostic delivery failed"} {
|
||||
t.Run(phase, func(t *testing.T) {
|
||||
identity, id, err := releaseidentity.NewDiagnostic(t.Context(), source, "root", commit)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
manifest := rehearsal.NewManifest(identity, id, "root", "releasekit.json", profile)
|
||||
store, err := rehearsal.CreateAttempt(t.Context(), repo, "", rehearsal.Attempt{Manifest: manifest, RepositoryDir: repo, Forge: "gitea", Outcomes: map[string]string{"cleanup": "complete", "workflow": "failed", "verification": "incomplete"}, JobEvidence: &rehearsal.JobResult{Manifest: manifest, Scope: "page", Build: "not_requested", Delivery: "not_attempted", Verification: "not_attempted", Diagnostics: []string{phase}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
request := releasekit.RehearsalRecoveryRequest{RecordPath: store.Path}
|
||||
cleaned, err := releasekit.CleanupRehearsal(t.Context(), request)
|
||||
if err != nil || !strings.Contains(strings.Join(cleaned.Diagnostics, "\n"), phase) {
|
||||
t.Fatalf("cleanup=%+v error=%v", cleaned, err)
|
||||
}
|
||||
resumed, err := releasekit.ResumeRehearsal(t.Context(), request)
|
||||
if err == nil || !strings.Contains(strings.Join(resumed.Diagnostics, "\n"), phase) {
|
||||
t.Fatalf("resume=%+v error=%v", resumed, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user