TestPullRequests checks and tests untested patches of pull requests. TODO: test more pull requests at same time.
()
| 837 | // TestPullRequests checks and tests untested patches of pull requests. |
| 838 | // TODO: test more pull requests at same time. |
| 839 | func TestPullRequests() { |
| 840 | prs := make([]*PullRequest, 0, 10) |
| 841 | _ = x.Iterate(PullRequest{ |
| 842 | Status: PullRequestStatusChecking, |
| 843 | }, |
| 844 | func(idx int, bean any) error { |
| 845 | pr := bean.(*PullRequest) |
| 846 | |
| 847 | if err := pr.LoadAttributes(); err != nil { |
| 848 | log.Error("LoadAttributes: %v", err) |
| 849 | return nil |
| 850 | } |
| 851 | |
| 852 | if err := pr.testPatch(); err != nil { |
| 853 | log.Error("testPatch: %v", err) |
| 854 | return nil |
| 855 | } |
| 856 | prs = append(prs, pr) |
| 857 | return nil |
| 858 | }) |
| 859 | |
| 860 | // Update pull request status. |
| 861 | for _, pr := range prs { |
| 862 | pr.checkAndUpdateStatus() |
| 863 | } |
| 864 | |
| 865 | // Start listening on new test requests. |
| 866 | for prID := range PullRequestQueue.Queue() { |
| 867 | log.Trace("TestPullRequests[%v]: processing test task", prID) |
| 868 | PullRequestQueue.Remove(prID) |
| 869 | |
| 870 | pr, err := GetPullRequestByID(com.StrTo(prID).MustInt64()) |
| 871 | if err != nil { |
| 872 | log.Error("GetPullRequestByID[%s]: %v", prID, err) |
| 873 | continue |
| 874 | } else if err = pr.testPatch(); err != nil { |
| 875 | log.Error("testPatch[%d]: %v", pr.ID, err) |
| 876 | continue |
| 877 | } |
| 878 | |
| 879 | pr.checkAndUpdateStatus() |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | func InitTestPullRequests() { |
| 884 | go TestPullRequests() |
no test coverage detected