Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checks pagination #1415

Merged
17 changes: 13 additions & 4 deletions lib/octokit/client/checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def update_check_run(repo, id, options = {})
# result.check_runs[0].id # => 51295429
# result.check_runs[0].status # => "in_progress"
def check_runs_for_ref(repo, ref, options = {})
get "#{Repository.path repo}/commits/#{ref}/check-runs", options
paginate "#{Repository.path repo}/commits/#{ref}/check-runs", options do |data, last_response|
data.check_runs.concat last_response.data.check_runs
data.total_count += last_response.data.total_count
end
end
alias :list_check_runs_for_ref :check_runs_for_ref

Expand All @@ -81,7 +84,10 @@ def check_runs_for_ref(repo, ref, options = {})
# result.check_runs[0].check_suite.id # => 50440400
# result.check_runs[0].status # => "in_progress"
def check_runs_for_check_suite(repo, id, options = {})
get "#{Repository.path repo}/check-suites/#{id}/check-runs", options
paginate "#{Repository.path repo}/check-suites/#{id}/check-runs", options do |data, last_response|
data.check_runs.concat last_response.data.check_runs
data.total_count += last_response.data.total_count
end
end
alias :list_check_runs_for_check_suite :check_runs_for_check_suite

Expand All @@ -107,7 +113,7 @@ def check_run(repo, id, options = {})
# annotations[0].path # => "README.md"
# annotations[0].message # => "Looks good!"
def check_run_annotations(repo, id, options = {})
get "#{Repository.path repo}/check-runs/#{id}/annotations", options
paginate "#{Repository.path repo}/check-runs/#{id}/annotations", options
end

# Methods for Check Suites
Expand Down Expand Up @@ -140,7 +146,10 @@ def check_suite(repo, id, options = {})
# result.check_suites[0].id # => 50440400
# result.check_suites[0].app.id # => 76765
def check_suites_for_ref(repo, ref, options = {})
get "#{Repository.path repo}/commits/#{ref}/check-suites", options
paginate "#{Repository.path repo}/commits/#{ref}/check-suites", options do |data, last_response|
data.check_suites.concat last_response.data.check_suites
data.total_count += last_response.data.total_count
end
end
alias :list_check_suites_for_ref :check_suites_for_ref

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
{
"http_interactions":[
{
"request":{
"method":"get",
"uri":"https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/check-runs/51295429/annotations?per_page=1",
"body":{
"encoding":"US-ASCII",
"base64_string":""
},
"headers":{
"Accept":[
"application/vnd.github.antiope-preview+json"
],
"User-Agent":[
"Octokit Ruby Gem 4.13.0"
],
"Content-Type":[
"application/json"
],
"Authorization":[
"token <<ACCESS_TOKEN>>"
],
"Accept-Encoding":[
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
]
}
},
"response":{
"status":{
"code":200,
"message":"OK"
},
"headers":{
"Server":[
"GitHub.com"
],
"Date":[
"Thu, 17 Jan 2019 14:55:47 GMT"
],
"Content-Type":[
"application/json; charset=utf-8"
],
"Transfer-Encoding":[
"chunked"
],
"Status":[
"200 OK"
],
"X-Ratelimit-Limit":[
"5000"
],
"X-Ratelimit-Remaining":[
"4979"
],
"X-Ratelimit-Reset":[
"1547738944"
],
"Cache-Control":[
"private, max-age=60, s-maxage=60"
],
"Vary":[
"Accept, Authorization, Cookie, X-GitHub-OTP"
],
"Etag":[
"W/\"86c75b80d451bfb4fea50d8960828ea9\""
],
"X-Github-Media-Type":[
"github.antiope-preview; format=json"
],
"Access-Control-Expose-Headers":[
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type"
],
"Access-Control-Allow-Origin":[
"*"
],
"Strict-Transport-Security":[
"max-age=31536000; includeSubdomains; preload"
],
"X-Frame-Options":[
"deny"
],
"X-Content-Type-Options":[
"nosniff"
],
"X-Xss-Protection":[
"1; mode=block"
],
"Referrer-Policy":[
"origin-when-cross-origin, strict-origin-when-cross-origin"
],
"Content-Security-Policy":[
"default-src 'none'"
],
"X-Github-Request-Id":[
"CF00:4C7A:46FB90:AFF523:5C409773"
],
"Link":[
"<https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/check-runs/51295429/annotations?page=2&per_page=1>; rel=\"next\""
]
},
"body":{
"encoding":"ASCII-8BIT",
"base64_string":"W3sicGF0aCI6IlJFQURNRS5tZCIsImJsb2JfaHJlZiI6Imh0dHBzOi8vZ2l0\naHViLmNvbS88R0lUSFVCX0xPR0lOPi88R0lUSFVCX1RFU1RfUkVQT1NJVE9S\nWT4vYmxvYi9lMWRiNzQxOGE3N2RiMDY1ZDE5MDBlNTc5YzgyZWYwYWFkMWRh\nMmIxL1JFQURNRS5tZCIsInN0YXJ0X2xpbmUiOjEsInN0YXJ0X2NvbHVtbiI6\nbnVsbCwiZW5kX2xpbmUiOjEsImVuZF9jb2x1bW4iOm51bGwsImFubm90YXRp\nb25fbGV2ZWwiOiJub3RpY2UiLCJ0aXRsZSI6IlJFQURNRS5tZCNMMSIsIm1l\nc3NhZ2UiOiJMb29rcyBnb29kISIsInJhd19kZXRhaWxzIjpudWxsfV0=\n"
},
"http_version":null
},
"recorded_at":"Thu, 17 Jan 2019 14:55:47 GMT"
},
{
"request":{
"method":"get",
"uri":"https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/check-runs/51295429/annotations?page=2&per_page=1",
"body":{
"encoding":"US-ASCII",
"base64_string":""
},
"headers":{
"Accept":[
"application/vnd.github.antiope-preview+json"
],
"User-Agent":[
"Octokit Ruby Gem 4.13.0"
],
"Content-Type":[
"application/json"
],
"Authorization":[
"token <<ACCESS_TOKEN>>"
],
"Accept-Encoding":[
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
]
}
},
"response":{
"status":{
"code":200,
"message":"OK"
},
"headers":{
"Server":[
"GitHub.com"
],
"Date":[
"Thu, 17 Jan 2019 14:55:47 GMT"
],
"Content-Type":[
"application/json; charset=utf-8"
],
"Transfer-Encoding":[
"chunked"
],
"Status":[
"200 OK"
],
"X-Ratelimit-Limit":[
"5000"
],
"X-Ratelimit-Remaining":[
"4979"
],
"X-Ratelimit-Reset":[
"1547738944"
],
"Cache-Control":[
"private, max-age=60, s-maxage=60"
],
"Vary":[
"Accept, Authorization, Cookie, X-GitHub-OTP"
],
"Etag":[
"W/\"86c75b80d451bfb4fea50d8960828ea9\""
],
"X-Github-Media-Type":[
"github.antiope-preview; format=json"
],
"Access-Control-Expose-Headers":[
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type"
],
"Access-Control-Allow-Origin":[
"*"
],
"Strict-Transport-Security":[
"max-age=31536000; includeSubdomains; preload"
],
"X-Frame-Options":[
"deny"
],
"X-Content-Type-Options":[
"nosniff"
],
"X-Xss-Protection":[
"1; mode=block"
],
"Referrer-Policy":[
"origin-when-cross-origin, strict-origin-when-cross-origin"
],
"Content-Security-Policy":[
"default-src 'none'"
],
"X-Github-Request-Id":[
"CF00:4C7A:46FB90:AFF523:5C409773"
],
"Link":[
"<https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/check-runs/51295429/annotations?page=1&per_page=1>; rel=\"prev\""
]
},
"body":{
"encoding":"ASCII-8BIT",
"base64_string":"W3sicGF0aCI6IlJFQURNRS5tZCIsImJsb2JfaHJlZiI6Imh0dHBzOi8vZ2l0\naHViLmNvbS88R0lUSFVCX0xPR0lOPi88R0lUSFVCX1RFU1RfUkVQT1NJVE9S\nWT4vYmxvYi9lMWRiNzQxOGE3N2RiMDY1ZDE5MDBlNTc5YzgyZWYwYWFkMWRh\nMmIxL1JFQURNRS5tZCIsInN0YXJ0X2xpbmUiOjEsInN0YXJ0X2NvbHVtbiI6\nbnVsbCwiZW5kX2xpbmUiOjEsImVuZF9jb2x1bW4iOm51bGwsImFubm90YXRp\nb25fbGV2ZWwiOiJub3RpY2UiLCJ0aXRsZSI6IlJFQURNRS5tZCNMMSIsIm1l\nc3NhZ2UiOiJMb29rcyBnb29kISIsInJhd19kZXRhaWxzIjpudWxsfV0=\n"
},
"http_version":null
},
"recorded_at":"Thu, 17 Jan 2019 14:55:47 GMT"
}
],
"recorded_with":"VCR 4.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"http_interactions":[
{
"request":{
"method":"get",
"uri":"https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/check-runs/51295429/annotations?per_page=1",
"body":{
"encoding":"US-ASCII",
"base64_string":""
},
"headers":{
"Accept":[
"application/vnd.github.antiope-preview+json"
],
"User-Agent":[
"Octokit Ruby Gem 4.13.0"
],
"Content-Type":[
"application/json"
],
"Authorization":[
"token <<ACCESS_TOKEN>>"
],
"Accept-Encoding":[
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
]
}
},
"response":{
"status":{
"code":200,
"message":"OK"
},
"headers":{
"Server":[
"GitHub.com"
],
"Date":[
"Thu, 17 Jan 2019 14:55:47 GMT"
],
"Content-Type":[
"application/json; charset=utf-8"
],
"Transfer-Encoding":[
"chunked"
],
"Status":[
"200 OK"
],
"X-Ratelimit-Limit":[
"5000"
],
"X-Ratelimit-Remaining":[
"4979"
],
"X-Ratelimit-Reset":[
"1547738944"
],
"Cache-Control":[
"private, max-age=60, s-maxage=60"
],
"Vary":[
"Accept, Authorization, Cookie, X-GitHub-OTP"
],
"Etag":[
"W/\"86c75b80d451bfb4fea50d8960828ea9\""
],
"X-Github-Media-Type":[
"github.antiope-preview; format=json"
],
"Access-Control-Expose-Headers":[
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type"
],
"Access-Control-Allow-Origin":[
"*"
],
"Strict-Transport-Security":[
"max-age=31536000; includeSubdomains; preload"
],
"X-Frame-Options":[
"deny"
],
"X-Content-Type-Options":[
"nosniff"
],
"X-Xss-Protection":[
"1; mode=block"
],
"Referrer-Policy":[
"origin-when-cross-origin, strict-origin-when-cross-origin"
],
"Content-Security-Policy":[
"default-src 'none'"
],
"X-Github-Request-Id":[
"CF00:4C7A:46FB90:AFF523:5C409773"
],
"Link":[
"<https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/check-runs/51295429/annotations?page=2&per_page=1>; rel=\"next\""
]
},
"body":{
"encoding":"ASCII-8BIT",
"base64_string":"W3sicGF0aCI6IlJFQURNRS5tZCIsImJsb2JfaHJlZiI6Imh0dHBzOi8vZ2l0\naHViLmNvbS88R0lUSFVCX0xPR0lOPi88R0lUSFVCX1RFU1RfUkVQT1NJVE9S\nWT4vYmxvYi9lMWRiNzQxOGE3N2RiMDY1ZDE5MDBlNTc5YzgyZWYwYWFkMWRh\nMmIxL1JFQURNRS5tZCIsInN0YXJ0X2xpbmUiOjEsInN0YXJ0X2NvbHVtbiI6\nbnVsbCwiZW5kX2xpbmUiOjEsImVuZF9jb2x1bW4iOm51bGwsImFubm90YXRp\nb25fbGV2ZWwiOiJub3RpY2UiLCJ0aXRsZSI6IlJFQURNRS5tZCNMMSIsIm1l\nc3NhZ2UiOiJMb29rcyBnb29kISIsInJhd19kZXRhaWxzIjpudWxsfV0=\n"
},
"http_version":null
},
"recorded_at":"Thu, 17 Jan 2019 14:55:47 GMT"
}
],
"recorded_with":"VCR 4.0.0"
}
Loading