WordPress / props-bot-action

A GitHub Action for compiling a list of contributor props.
Other
11 stars 3 forks source link

Feat/comment pagination #53

Open ataylorme opened 7 months ago

ataylorme commented 7 months ago

What?

Add pagination support for PR comments

Why?

Addresses #41

How?

Use @octokit/plugin-paginate-graphql with plugin support from @actions/core

Notes

I am not sure if this will work as-is. Based on this comment I think the rather large GraphQL query may need to be broken down into multiple, smaller queries for effective pagination.

Probably one GraphQL for each set of PR info needed such as commits, comments, reviews, etc.

desrosj commented 7 months ago

Thanks for looking at this, @ataylorme!

I think this is the reason for #54.

I've gone and added some test variables to pull the data from the PR experiencing the problem.

I also rebuilt the action after your changes using npm run prepare. You'll need to do that every time you push, otherwise your changes won't be tested by the test workflows.

desrosj commented 7 months ago

I took another pass at this in #58 looking at the examples in the plugin README file. It's also not there yet.

I did see one thing in the documentation somewhere (struggling to find it again for reference) that made me think we may need to break off a few queries. Nested pagination is not supported. We may need to either:

ataylorme commented 7 months ago

@desrosj to truly sort this out, and have confidence in a solution, I would:

  1. Rewrite the plugin in TypeScript
  2. Break up the logic in getContributorData to smaller methods with single responsibility and use getContributorData to call those (e.g. getPullRequestComments, get closingIssuesReferences, etc.). Some advantages are:
    • Reduced cognitive complexity
    • More approachable unit tests
  3. Switch to using the REST API with pagination
    • @ octokit/types.ts combined with 1 and 2 will give strict typing that cannot be achieved with GraphQL

While a single, large graphQL query may be more efficient in reducing the number of API requests the changes above would make the code more maintainable and testable.