Always include attempt in single-job log filename (job-{id}-attempt-{N}.log) and run-ZIP entry names ({name}-{id}-attempt-{N}.log) regardless of whether ?attempt was passed, update run-logs integration test happy-path expectations to match

This commit is contained in:
Zach Handley 2026-05-26 18:44:27 -07:00
parent d75d251b7b
commit 900d63a42a
2 changed files with 12 additions and 17 deletions

View file

@ -134,10 +134,7 @@ func OpenJobLogReader(
}
if !hasStep {
filename := fmt.Sprintf("job-%d.log", job.ID)
if hasAttempt {
filename = fmt.Sprintf("job-%d-attempt-%d.log", job.ID, attemptVal)
}
filename := fmt.Sprintf("job-%d-attempt-%d.log", job.ID, task.Attempt)
return reader, filename, modtime, nil
}
@ -152,13 +149,7 @@ func OpenJobLogReader(
}
reader.Close()
// Step-filtered filename keeps step and attempt distinct so multiple
// step-filtered entries can coexist inside a ZIP of run logs.
stepFilename := fmt.Sprintf("job-%d-step-%d.log", job.ID, stepIdx)
if hasAttempt {
stepFilename = fmt.Sprintf("job-%d-attempt-%d-step-%d.log", job.ID, attemptVal, stepIdx)
}
stepFilename := fmt.Sprintf("job-%d-attempt-%d-step-%d.log", job.ID, task.Attempt, stepIdx)
return nopReadSeekCloser{bytes.NewReader(buf)}, stepFilename, modtime, nil
}
@ -194,11 +185,15 @@ func WriteRunLogsZip(ctx context.Context, w io.Writer, run *actions_model.Action
return cleaned
}
entryName := func(job *actions_model.ActionRunJob, suffix string) string {
attemptFor := func(job *actions_model.ActionRunJob) int64 {
if hasAttempt {
return fmt.Sprintf("%s-%d-attempt-%d.%s", sanitize(job.Name), job.ID, attemptVal, suffix)
return attemptVal
}
return fmt.Sprintf("%s-%d.%s", sanitize(job.Name), job.ID, suffix)
return job.Attempt
}
entryName := func(job *actions_model.ActionRunJob, suffix string) string {
return fmt.Sprintf("%s-%d-attempt-%d.%s", sanitize(job.Name), job.ID, attemptFor(job), suffix)
}
writeMarker := func(job *actions_model.ActionRunJob, suffix, msg string) {

View file

@ -155,9 +155,9 @@ jobs:
entries[f.Name] = string(data)
}
job1Name := fmt.Sprintf("%s-%d.log", actionRunJob1.Name, actionRunJob1.ID)
job2Name := fmt.Sprintf("%s-%d.log", actionRunJob2.Name, actionRunJob2.ID)
utf8Name := fmt.Sprintf("%s-%d.log", actionRunJob3.Name, actionRunJob3.ID)
job1Name := fmt.Sprintf("%s-%d-attempt-%d.log", actionRunJob1.Name, actionRunJob1.ID, actionRunJob1.Attempt)
job2Name := fmt.Sprintf("%s-%d-attempt-%d.log", actionRunJob2.Name, actionRunJob2.ID, actionRunJob2.Attempt)
utf8Name := fmt.Sprintf("%s-%d-attempt-%d.log", actionRunJob3.Name, actionRunJob3.ID, actionRunJob3.Attempt)
require.Len(t, entries, 3, "zip should contain exactly one entry per job")
require.Contains(t, entries, job1Name, "expected job1 entry %q", job1Name)