findPRByTimestamp searches for a PR created by github-actions[bot] around the given timestamp. This is a fallback for when the manifest doesn't record the PR number.
(repo string, timestamp string)
| 14 | // findPRByTimestamp searches for a PR created by github-actions[bot] around the given timestamp. |
| 15 | // This is a fallback for when the manifest doesn't record the PR number. |
| 16 | func findPRByTimestamp(repo string, timestamp string) int { |
| 17 | outcomeEvalPRLog.Printf("Searching for PR by timestamp: repo=%s, timestamp=%s", repo, timestamp) |
| 18 | ts, err := time.Parse(time.RFC3339, timestamp) |
| 19 | if err != nil { |
| 20 | outcomeEvalPRLog.Printf("Failed to parse timestamp %q: %v", timestamp, err) |
| 21 | return 0 |
| 22 | } |
| 23 | // Search in a 5-minute window around the timestamp |
| 24 | since := ts.Add(-2 * time.Minute).Format("2006-01-02T15:04:05Z") |
| 25 | until := ts.Add(5 * time.Minute).Format("2006-01-02T15:04:05Z") |
| 26 | |
| 27 | // Use gh CLI to search for PRs |
| 28 | output, err := workflow.RunGH("Searching for PR...", |
| 29 | "pr", "list", |
| 30 | "--repo", repo, |
| 31 | "--state", "all", |
| 32 | "--author", "app/github-actions", |
| 33 | "--search", fmt.Sprintf("created:%s..%s", since, until), |
| 34 | "--limit", "1", |
| 35 | "--json", "number", |
| 36 | "--jq", ".[0].number") |
| 37 | if err != nil { |
| 38 | return 0 |
| 39 | } |
| 40 | numStr := strings.TrimSpace(string(output)) |
| 41 | var n int |
| 42 | if _, err := fmt.Sscanf(numStr, "%d", &n); err == nil { |
| 43 | return n |
| 44 | } |
| 45 | return 0 |
| 46 | } |
| 47 | |
| 48 | // evalCreatePullRequest checks whether a PR was merged, closed, or is still open. |
| 49 | func evalCreatePullRequest(item CreatedItemReport, repoOverride string) OutcomeReport { |
no test coverage detected