saveRunSummary saves a run summary to disk
(outputDir string, summary *RunSummary, verbose bool)
| 163 | |
| 164 | // saveRunSummary saves a run summary to disk |
| 165 | func saveRunSummary(outputDir string, summary *RunSummary, verbose bool) error { |
| 166 | logsCacheLog.Printf("Saving run summary to cache: dir=%s, run_id=%d", outputDir, summary.RunID) |
| 167 | summaryPath := filepath.Join(outputDir, runSummaryFileName) |
| 168 | |
| 169 | // Marshal to JSON with indentation for readability |
| 170 | data, err := json.MarshalIndent(summary, "", " ") |
| 171 | if err != nil { |
| 172 | logsCacheLog.Printf("Failed to marshal run summary: %v", err) |
| 173 | return fmt.Errorf("failed to marshal run summary: %w", err) |
| 174 | } |
| 175 | |
| 176 | // Write to file |
| 177 | if err := os.WriteFile(summaryPath, data, constants.FilePermPublic); err != nil { |
| 178 | logsCacheLog.Printf("Failed to write run summary to disk: %v", err) |
| 179 | return fmt.Errorf("failed to write run summary: %w", err) |
| 180 | } |
| 181 | |
| 182 | logsCacheLog.Printf("Successfully saved run summary cache: path=%s", summaryPath) |
| 183 | if verbose { |
| 184 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Saved run summary to "+summaryPath)) |
| 185 | } |
| 186 | |
| 187 | return nil |
| 188 | } |