(opts auditJobRunOptions)
| 964 | } |
| 965 | |
| 966 | func fetchAuditJobLog(opts auditJobRunOptions) (string, string, error) { |
| 967 | args := []string{"run", "view"} |
| 968 | if opts.owner != "" && opts.repo != "" { |
| 969 | args = append(args, "-R", fmt.Sprintf("%s/%s", opts.owner, opts.repo)) |
| 970 | } |
| 971 | args = append(args, "--job", strconv.FormatInt(opts.jobID, 10), "--log") |
| 972 | if opts.verbose { |
| 973 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Fetching logs for job %d...", opts.jobID))) |
| 974 | fmt.Fprintln(os.Stderr, console.FormatVerboseMessage("Executing: gh "+strings.Join(args, " "))) |
| 975 | } |
| 976 | cmd := workflow.ExecGH(args...) |
| 977 | workflow.SetGHHostEnv(cmd, opts.hostname) |
| 978 | output, err := cmd.CombinedOutput() |
| 979 | if err != nil { |
| 980 | return "", "", fmt.Errorf("failed to fetch job logs: %w\nOutput: %s", err, string(output)) |
| 981 | } |
| 982 | jobLogPath := filepath.Join(opts.outputDir, fmt.Sprintf("job-%d.log", opts.jobID)) |
| 983 | if err := os.WriteFile(jobLogPath, output, constants.FilePermSensitive); err != nil { |
| 984 | return "", "", fmt.Errorf("failed to write job log: %w", err) |
| 985 | } |
| 986 | if opts.verbose { |
| 987 | fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Job log saved to "+jobLogPath)) |
| 988 | } |
| 989 | return string(output), jobLogPath, nil |
| 990 | } |
| 991 | |
| 992 | func extractAuditJobDetails(opts auditJobRunOptions, jobLogContent string) error { |
| 993 | if opts.stepNumber > 0 { |
no test coverage detected