Commit 377fb0b
Eric Bower
·
2026-05-08 15:29:38 -0400 EDT
parent 9772fc9
chore: sessions dir
2 files changed,
+22,
-30
M
main.go
M
main.go
+19,
-27
| ... | ... | @@ -1061,7 +1061,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str | |
| 1061 | 1061 | log.Error("fetch history html", "session", s.Name, "err", err) | |
| 1062 | 1062 | continue | |
| 1063 | 1063 | } | |
| 1064 | - | if err := stageArtifact(cfg.ArtifactDir, name, jobID, s.Short, html, ".html"); err != nil { | |
| 1064 | + | if err := stageArtifact(cfg.ArtifactDir, name, jobID, filepath.Join("sessions", s.Short), html, ".html"); err != nil { | |
| 1065 | 1065 | log.Error("stage html artifact", "session", s.Short, "err", err) | |
| 1066 | 1066 | } | |
| 1067 | 1067 |
| ... | ... | @@ -1070,7 +1070,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str | |
| 1070 | 1070 | log.Error("fetch history plain", "session", s.Name, "err", err) | |
| 1071 | 1071 | continue | |
| 1072 | 1072 | } | |
| 1073 | - | if err := stageArtifact(cfg.ArtifactDir, name, jobID, s.Short, plain, ".txt"); err != nil { | |
| 1073 | + | if err := stageArtifact(cfg.ArtifactDir, name, jobID, filepath.Join("sessions", s.Short), plain, ".txt"); err != nil { | |
| 1074 | 1074 | log.Error("stage txt artifact", "session", s.Short, "err", err) | |
| 1075 | 1075 | } | |
| 1076 | 1076 | } |
| ... | ... | @@ -1795,7 +1795,7 @@ func formatTimestamp(ts string) string { | |
| 1795 | 1795 | ||
| 1796 | 1796 | // generateJobIndex produces HTML and plain-text index pages listing all | |
| 1797 | 1797 | // sessions for a job with links and metadata (status, exit code, ended at). | |
| 1798 | - | // It also includes any other artifacts in the job directory (e.g., event.json, workspace.tar). | |
| 1798 | + | // It also includes any other artifacts in the job directory (e.g., event.json, attestation.json, workspace.tar). | |
| 1799 | 1799 | func generateJobIndex(artifactDir, name, jobID string, sessions []SessionInfo) (htmlContent, txtContent string) { | |
| 1800 | 1800 | rows := make([]sessionRow, 0, len(sessions)) | |
| 1801 | 1801 | for _, s := range sessions { |
| ... | ... | @@ -1819,35 +1819,27 @@ func generateJobIndex(artifactDir, name, jobID string, sessions []SessionInfo) ( | |
| 1819 | 1819 | rows = append(rows, row) | |
| 1820 | 1820 | } | |
| 1821 | 1821 | ||
| 1822 | - | // Gather other artifacts in the job directory | |
| 1822 | + | // Gather artifacts by scanning the job directory (excluding sessions/) | |
| 1823 | 1823 | var artifacts []artifactRow | |
| 1824 | 1824 | jobDir := filepath.Join(artifactDir, name, jobID) | |
| 1825 | 1825 | ||
| 1826 | - | // Always add workspace.tar (it's uploaded before pici runs) | |
| 1827 | - | artifacts = append(artifacts, artifactRow{Name: "workspace.tar", Size: "—", ModTime: "—"}) | |
| 1828 | - | ||
| 1829 | - | // Add event.json if it exists | |
| 1830 | - | eventJSON := filepath.Join(jobDir, "event.json") | |
| 1831 | - | if info, err := os.Stat(eventJSON); err == nil { | |
| 1832 | - | artifacts = append(artifacts, artifactRow{ | |
| 1833 | - | Name: "event.json", | |
| 1834 | - | Size: formatFileSize(info.Size()), | |
| 1835 | - | ModTime: formatTimestamp(fmt.Sprintf("%d", info.ModTime().Unix())), | |
| 1836 | - | }) | |
| 1837 | - | } | |
| 1838 | - | ||
| 1839 | - | // Add published.json if it exists | |
| 1840 | - | publishedJSON := filepath.Join(jobDir, "published.json") | |
| 1841 | - | if info, err := os.Stat(publishedJSON); err == nil { | |
| 1842 | - | artifacts = append(artifacts, artifactRow{ | |
| 1843 | - | Name: "published.json", | |
| 1844 | - | Size: formatFileSize(info.Size()), | |
| 1845 | - | ModTime: formatTimestamp(fmt.Sprintf("%d", info.ModTime().Unix())), | |
| 1846 | - | }) | |
| 1826 | + | if entries, err := os.ReadDir(jobDir); err == nil { | |
| 1827 | + | for _, entry := range entries { | |
| 1828 | + | if entry.IsDir() { | |
| 1829 | + | continue // skip subdirectories (e.g. sessions/) | |
| 1830 | + | } | |
| 1831 | + | info, err := entry.Info() | |
| 1832 | + | if err != nil { | |
| 1833 | + | continue | |
| 1834 | + | } | |
| 1835 | + | artifacts = append(artifacts, artifactRow{ | |
| 1836 | + | Name: entry.Name(), | |
| 1837 | + | Size: formatFileSize(info.Size()), | |
| 1838 | + | ModTime: formatTimestamp(fmt.Sprintf("%d", info.ModTime().Unix())), | |
| 1839 | + | }) | |
| 1840 | + | } | |
| 1847 | 1841 | } | |
| 1848 | 1842 | ||
| 1849 | - | // Skip zmx task artifacts (runner.html, runner.txt, etc.) — already in tasks table | |
| 1850 | - | ||
| 1851 | 1843 | // Resolve overall job status | |
| 1852 | 1844 | jobStatus := "success" | |
| 1853 | 1845 | hasRunning := false |
+3,
-3
| ... | ... | @@ -126,8 +126,8 @@ zmx run step2 echo "hello from step2" | |
| 126 | 126 | ||
| 127 | 127 | // Track per-session artifacts | |
| 128 | 128 | for _, s := range p.Sessions { | |
| 129 | - | htmlPath := filepath.Join(artifactDir, p.Name, p.JobID, s.Short+".html") | |
| 130 | - | txtPath := filepath.Join(artifactDir, p.Name, p.JobID, s.Short+".txt") | |
| 129 | + | htmlPath := filepath.Join(artifactDir, p.Name, p.JobID, "sessions", s.Short+".html") | |
| 130 | + | txtPath := filepath.Join(artifactDir, p.Name, p.JobID, "sessions", s.Short+".txt") | |
| 131 | 131 | if _, err := os.Stat(htmlPath); err == nil { | |
| 132 | 132 | sessionArtifactShorts[s.Short+"_html"] = true | |
| 133 | 133 | } |
| ... | ... | @@ -215,7 +215,7 @@ zmx run step2 echo "hello from step2" | |
| 215 | 215 | ||
| 216 | 216 | // 8. Assert HTML artifacts were staged for each session | |
| 217 | 217 | for _, s := range finalPayload.Sessions { | |
| 218 | - | artifactPath := filepath.Join(cfg.ArtifactDir, finalPayload.Name, finalPayload.JobID, s.Short+".html") | |
| 218 | + | artifactPath := filepath.Join(cfg.ArtifactDir, finalPayload.Name, finalPayload.JobID, "sessions", s.Short+".html") | |
| 219 | 219 | data, err := os.ReadFile(artifactPath) | |
| 220 | 220 | if err != nil { | |
| 221 | 221 | t.Errorf("read artifact %s: %v", artifactPath, err) |