diff --git a/api/queries.go b/api/queries.go index 4f1f74ed5..d18b2c679 100644 --- a/api/queries.go +++ b/api/queries.go @@ -35,17 +35,11 @@ type PullRequest struct { Commits struct { Nodes []struct { Commit struct { - Status struct { - Contexts []struct { - State string - } - } - CheckSuites struct { - Nodes []struct { - CheckRuns struct { - Nodes []struct { - Conclusion string - } + StatusCheckRollup struct { + Contexts struct { + Nodes []struct { + State string + Conclusion string } } } @@ -97,32 +91,23 @@ func (pr *PullRequest) ChecksStatus() (summary PullRequestChecksStatus) { return } commit := pr.Commits.Nodes[0].Commit - for _, status := range commit.Status.Contexts { - switch status.State { - case "SUCCESS": + for _, c := range commit.StatusCheckRollup.Contexts.Nodes { + state := c.State + if state == "" { + state = c.Conclusion + } + switch state { + case "SUCCESS", "NEUTRAL", "SKIPPED": summary.Passing++ - case "EXPECTED", "ERROR", "FAILURE": + case "ERROR", "FAILURE", "CANCELLED", "TIMED_OUT", "ACTION_REQUIRED": summary.Failing++ - case "PENDING": + case "EXPECTED", "QUEUED", "PENDING", "IN_PROGRESS": summary.Pending++ default: - panic(fmt.Errorf("unsupported status: %q", status.State)) + panic(fmt.Errorf("unsupported status: %q", state)) } summary.Total++ } - for _, checkSuite := range commit.CheckSuites.Nodes { - for _, checkRun := range checkSuite.CheckRuns.Nodes { - switch checkRun.Conclusion { - case "SUCCESS", "NEUTRAL": - summary.Passing++ - case "FAILURE", "CANCELLED", "TIMED_OUT", "ACTION_REQUIRED": - summary.Failing++ - default: - panic(fmt.Errorf("unsupported check conclusion: %q", checkRun.Conclusion)) - } - summary.Total++ - } - } return } @@ -267,15 +252,13 @@ func PullRequests(client *Client, ghRepo Repo, currentBranch, currentUsername st commits(last: 1) { nodes { commit { - status { - contexts { - state - } - } - checkSuites(first: 50) { - nodes { - checkRuns(first: 50) { - nodes { + statusCheckRollup { + contexts(last: 100) { + nodes { + ...on StatusContext { + state + } + ...on CheckRun { conclusion } } diff --git a/command/root.go b/command/root.go index 22c0122a1..4fe921391 100644 --- a/command/root.go +++ b/command/root.go @@ -75,6 +75,7 @@ var apiClientForContext = func(ctx context.Context) (*api.Client, error) { // antiope-preview: Checks // shadow-cat-preview: Draft pull requests api.AddHeader("Accept", "application/vnd.github.antiope-preview+json, application/vnd.github.shadow-cat-preview"), + api.AddHeader("GraphQL-Features", "pe_mobile"), } if verbose := os.Getenv("DEBUG"); verbose != "" { opts = append(opts, api.VerboseLog(os.Stderr))