Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
get all reviews (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-paulo-parity authored Apr 8, 2022
1 parent 5814820 commit 3aa9b3e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const commitStateFailure: CommitState = "failure"

export const maxGithubApiFilesPerPage = 100
export const maxGithubApiTeamMembersPerPage = 100
export const maxGithubApiReviewsPerPage = 100

export const rulesConfigurations: RulesConfigurations = {
basic: {
Expand Down
16 changes: 10 additions & 6 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
commitStateSuccess,
configFilePath,
maxGithubApiFilesPerPage,
maxGithubApiReviewsPerPage,
maxGithubApiTeamMembersPerPage,
} from "./constants"
import { LoggerInterface } from "./logger"
Expand Down Expand Up @@ -407,12 +408,15 @@ export const runChecks = async function (
}

if (matchedRules.length !== 0) {
const reviewsResponse = await octokit.rest.pulls.listReviews({
owner: pr.base.repo.owner.login,
repo: pr.base.repo.name,
pull_number: pr.number,
})
const { data: reviews } = reviewsResponse
const reviews = await octokit.paginate(
"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews",
{
owner: pr.base.repo.owner.login,
repo: pr.base.repo.name,
pull_number: pr.number,
per_page: maxGithubApiReviewsPerPage,
},
)

const latestReviews: Map<
number,
Expand Down
8 changes: 6 additions & 2 deletions test/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { configFilePath, maxGithubApiFilesPerPage } from "src/constants"
import {
configFilePath,
maxGithubApiFilesPerPage,
maxGithubApiReviewsPerPage,
} from "src/constants"
import { AndDistinctRule, AndRule, BasicRule, OrRule, PR } from "src/types"

export const org = "org"
Expand All @@ -25,7 +29,7 @@ export const condition = "condition"
export const githubApi = "https://api.github.com"
export const githubWebsite = "https://github.com"
export const prApiPath = `/repos/${org}/${repo}/pulls/${prNumber}`
export const reviewsApiPath = `${prApiPath}/reviews`
export const reviewsApiPath = `${prApiPath}/reviews?per_page=${maxGithubApiReviewsPerPage}`
export const changedFilesApiPath = `${prApiPath}/files?per_page=${maxGithubApiFilesPerPage}`
export const requestedReviewersApiPath = `${prApiPath}/requested_reviewers`
export const configFileContentsApiPath = `/repos/${org}/${repo}/contents/${encodeURIComponent(
Expand Down

0 comments on commit 3aa9b3e

Please sign in to comment.