writeFlakeSummary appends a markdown summary of flaky tests to path, creating it if needed. In practice path is the GitHub Actions runner's $GITHUB_STEP_SUMMARY, which testwrapper auto-detects. It logs and continues on errors, as a CI write failure should not poison the test run's exit status.
(path string, flaky []*failedTest, repo string)
| 655 | // continues on errors, as a CI write failure should not poison the test |
| 656 | // run's exit status. |
| 657 | func writeFlakeSummary(path string, flaky []*failedTest, repo string) { |
| 658 | f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) |
| 659 | if err != nil { |
| 660 | log.Printf("testwrapper: opening summary file %s: %v", path, err) |
| 661 | return |
| 662 | } |
| 663 | defer f.Close() |
| 664 | if len(flaky) == 0 { |
| 665 | fmt.Fprintln(f, "_No flaky tests detected._") |
| 666 | return |
| 667 | } |
| 668 | fmt.Fprintln(f, "### Flaky tests detected") |
| 669 | fmt.Fprintln(f) |
| 670 | fmt.Fprintln(f, "Tests that failed at least once and then passed on retry. Rows tagged 🆕 were not annotated with flakytest.Mark; testwrapper auto-detected the flake.") |
| 671 | fmt.Fprintln(f) |
| 672 | fmt.Fprintln(f, "| Package | Test | Retries | Retry time | Issue |") |
| 673 | fmt.Fprintln(f, "|---------|------|--------:|-----------:|-------|") |
| 674 | for _, ft := range flaky { |
| 675 | url := ft.issueURL |
| 676 | if url == "" { |
| 677 | url = fakeIssueURL(repo) |
| 678 | } |
| 679 | var tag string |
| 680 | if ft.issueURL == "" { |
| 681 | tag = " 🆕" |
| 682 | } |
| 683 | fmt.Fprintf(f, "| `%s` | `%s`%s | %d | %.1fs | [link](%s) |\n", |
| 684 | ft.pkg, ft.testName, tag, ft.attempts, ft.totalRetryElapsed.Seconds(), url) |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | // buildPackageTests groups failedTests by package into the wire format |
| 689 | // flakeapp expects. |
no test coverage detected
searching dependent graphs…