Recover rejected rehearsals without remote credentials
This commit is contained in:
@@ -125,7 +125,7 @@ func recoverRecordedRehearsal(ctx context.Context, invocation cli.Invocation, pr
|
||||
}
|
||||
var token, woodToken string
|
||||
remoteDone := attempt.Outcomes["cleanup-page"] == "complete" && attempt.Outcomes["cleanup-remote-tag"] == "complete"
|
||||
if attempt.Outcomes["cleanup"] != "complete" && attempt.Outcomes["push"] != "not_attempted" && !remoteDone {
|
||||
if attempt.Outcomes["cleanup"] != "complete" && attempt.Outcomes["push"] != "not_attempted" && attempt.Outcomes["push"] != "not_dispatched" && !remoteDone {
|
||||
token, woodToken, err = cli.ResolveRehearsalRecoveryCredentials(ctx, attempt.RepositoryDir, attempt.Manifest.Commit, attempt.Manifest.ProfilePath, attempt.Manifest.ProfileSHA256, invocation.TokenFile, invocation.WoodpeckerTokenFile)
|
||||
if err != nil {
|
||||
return summary, &rehearsalInputError{err: err}
|
||||
|
||||
@@ -135,3 +135,47 @@ func TestRehearsalExitStatusPreservesObservedOutcomes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupKnownRejectedDispatchNeedsNoRemoteCredentials(t *testing.T) {
|
||||
repo := newCLIRepository(t)
|
||||
writeRepositoryFile(t, repo, "releasekit.json", `{"product":"Example","source":{},"rehearsal":{}}`)
|
||||
cliGitRun(t, repo, "add", "releasekit.json")
|
||||
cliGitRun(t, repo, "commit", "-m", "capture profile")
|
||||
captured, err := cli.CaptureCommittedProfile(t.Context(), repo, "HEAD", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source, err := releaseidentity.LoadCommittedSource(t.Context(), repo, "", captured.Commit, captured.Settings.SourceSpec())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
identity, id, err := releaseidentity.NewDiagnostic(t.Context(), source, "root", captured.Commit)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
manifest := rehearsal.NewManifest(identity, id, "root", captured.Path, captured.Bytes)
|
||||
object, err := rehearsal.CreateDiagnosticTag(t.Context(), repo, manifest)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
record := rehearsal.Attempt{Forge: "gitea", Manifest: manifest, RepositoryDir: repo, TagObject: object, Outcomes: map[string]string{"tag": "created", "push": "not_dispatched", "workflow": "failed", "verification": "incomplete", "cleanup": "pending"}}
|
||||
store, err := rehearsal.CreateAttempt(t.Context(), repo, "", record)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var output, diagnostics bytes.Buffer
|
||||
status := run(t.Context(), []string{"test-cleanup", "--record", store.Path, "--json"}, &output, &diagnostics)
|
||||
var doc rehearsalDocument
|
||||
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)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(repo, ".git", "refs", "tags", filepath.FromSlash(identity.Tag))); !os.IsNotExist(err) {
|
||||
t.Fatalf("local tag remains: %v", err)
|
||||
}
|
||||
output.Reset()
|
||||
diagnostics.Reset()
|
||||
status = run(t.Context(), []string{"test-resume", "--record", store.Path, "--json"}, &output, &diagnostics)
|
||||
if status != 1 || !strings.Contains(output.String(), `"cleanup":"complete"`) {
|
||||
t.Fatalf("resume status=%d output=%s diagnostics=%s", status, &output, &diagnostics)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,8 @@ the coordinator records `not_dispatched` and cleanup removes owned local
|
||||
resources without CI. Ambiguous writes retain observation-based recovery.
|
||||
Native rejecting-hook, pre-dispatch, lost-acknowledgment, unavailable-observation,
|
||||
Git/rehearsal, and source-publication regression checks pass.
|
||||
The CLI recovery path also skips remote credential loading for confirmed
|
||||
non-dispatch; an explicit saved-record cleanup/resume regression passes.
|
||||
|
||||
**Priority:** P2. **Stages:** 9, 10, 12, 13.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user