-
Notifications
You must be signed in to change notification settings - Fork 4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it 👍 Feels good to abstract that logic.
@@ -69,7 +70,8 @@ describe("Configuration", () => { | |||
|
|||
setup({ rules: [badRule] }); | |||
|
|||
expect(await runChecks({ pr: basePR, octokit, logger, finishProcessReviews: null })).toBe("failure"); | |||
const api = new GitHubApi(basePR, { logger, finishProcessReviews: null, octokit }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const api = new GitHubApi(basePR, { logger, finishProcessReviews: null, octokit }); | |
const api = new GitHubApi(basePR, { logger, octokit }); |
It's not taken by GitHubApi
. Same in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid it's a requirement in the object union that the method is receiving:
Argument of type '{ pr: PR; octokit: Octokit & { paginate: PaginateInterface; } & RestEndpointMethods & Api; logger: TestLogger; }' is not assignable to parameter of type 'Context & { pr: PR; }'.
Property 'finishProcessReviews' is missing in type '{ pr: PR; octokit: Octokit & { paginate: PaginateInterface; } & RestEndpointMethods & Api; logger: TestLogger; }' but required in type 'Context'.ts(2345)
I'll look into cleaning it in the future
I feel like this duplicates the purpose of |
I would be up to use it but would need to check if I can adapt the specific endpoints and combinations that are being called. Some stuff, like the following, may not be that straightforward to migrate. octokit.paginate(
this.octokit.rest.teams.listMembersInOrg,
{ org:pr.base.repo.owner.login, team_slug, per_page: maxGithubApiTeamMembersPerPage },
(response) => response.data.map(({ login }) => login),
); And I would still keep it in a wrapper so it can be tested easier. But this PR would be a step forward into that direction |
We have paginated methods there :)
One of the major points of creating
Cool |
Abstracted GitHub api interaction from the runner method.
This is the first step into isolating the code so it is easier to read.
Second step will isolate the logic