|
4 | 4 | "context" |
5 | 5 | "errors" |
6 | 6 | "fmt" |
7 | | - "strings" |
8 | 7 |
|
9 | 8 | "github.com/google/go-github/v41/github" |
10 | 9 | "github.com/rs/zerolog/log" |
@@ -59,11 +58,11 @@ func (r *Repository) getAggregatedState(ctx context.Context, pr *github.PullRequ |
59 | 58 | return "", err |
60 | 59 | } |
61 | 60 |
|
62 | | - if status == Pending { |
| 61 | + if status == Pending || status == Success { |
63 | 62 | return status, nil |
64 | 63 | } |
65 | 64 |
|
66 | | - return r.getCheckRunsState(ctx, pr) |
| 65 | + return "", fmt.Errorf("PR status: %s", status) |
67 | 66 | } |
68 | 67 |
|
69 | 68 | // getStatus provide checks status (status). |
@@ -102,42 +101,3 @@ func (r *Repository) getStatus(ctx context.Context, pr *github.PullRequest) (str |
102 | 101 |
|
103 | 102 | return "", errors.New(summary) |
104 | 103 | } |
105 | | - |
106 | | -// getCheckRunsState provide checks status (checksRun). |
107 | | -func (r *Repository) getCheckRunsState(ctx context.Context, pr *github.PullRequest) (string, error) { |
108 | | - prRef := pr.Head.GetSHA() |
109 | | - |
110 | | - checkSuites, _, err := r.client.Checks.ListCheckSuitesForRef(ctx, r.owner, r.name, prRef, nil) |
111 | | - if err != nil { |
112 | | - return "", err |
113 | | - } |
114 | | - |
115 | | - if checkSuites.GetTotal() == 0 { |
116 | | - return Success, nil |
117 | | - } |
118 | | - |
119 | | - ignoredApps := []string{"dependabot", "renovate", "github-pages"} |
120 | | - |
121 | | - var msg []string |
122 | | - for _, v := range checkSuites.CheckSuites { |
123 | | - slug := v.GetApp().GetSlug() |
124 | | - |
125 | | - if contains(ignoredApps, slug) { |
126 | | - continue |
127 | | - } |
128 | | - |
129 | | - if v.GetStatus() != "completed" { |
130 | | - return Pending, nil |
131 | | - } |
132 | | - |
133 | | - if v.GetConclusion() != "success" && v.GetConclusion() != "neutral" { |
134 | | - msg = append(msg, fmt.Sprintf("%s %s %s", v.GetApp().GetName(), v.GetStatus(), v.GetConclusion())) |
135 | | - } |
136 | | - } |
137 | | - |
138 | | - if len(msg) == 0 { |
139 | | - return Success, nil |
140 | | - } |
141 | | - |
142 | | - return "", errors.New(strings.Join(msg, ", ")) |
143 | | -} |
0 commit comments