Skip to content

Commit

Permalink
fix: Fixes broken pagination in ActionsWorkflowRuns
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfloyd authored Oct 11, 2022
2 parents 84189bc + e0e3172 commit 8517612
Show file tree
Hide file tree
Showing 29 changed files with 7,122 additions and 30 deletions.
8 changes: 6 additions & 2 deletions lib/octokit/client/actions_artifacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module ActionsArtifacts
# @return [Sawyer::Resource] the total count and an array of artifacts
# @see https://developer.github.com/v3/actions/artifacts#list-artifacts-for-a-repository
def repository_artifacts(repo, options = {})
paginate "#{Repository.path repo}/actions/artifacts", options
paginate "#{Repository.path repo}/actions/artifacts", options do |data, last_response|
data.artifacts.concat last_response.data.artifacts
end
end

# List all artifacts for a workflow run
Expand All @@ -24,7 +26,9 @@ def repository_artifacts(repo, options = {})
# @return [Sawyer::Resource] the total count and an array of artifacts
# @see https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts
def workflow_run_artifacts(repo, workflow_run_id, options = {})
paginate "#{Repository.path repo}/actions/runs/#{workflow_run_id}/artifacts", options
paginate "#{Repository.path repo}/actions/runs/#{workflow_run_id}/artifacts", options do |data, last_response|
data.artifacts.concat last_response.data.artifacts
end
end

# Get an artifact
Expand Down
4 changes: 3 additions & 1 deletion lib/octokit/client/actions_secrets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def get_public_key(repo)
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
# @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
def list_secrets(repo)
paginate "#{Repository.path repo}/actions/secrets"
paginate "#{Repository.path repo}/actions/secrets" do |data, last_response|
data.secrets.concat last_response.data.secrets
end
end

# Get a secret
Expand Down
8 changes: 6 additions & 2 deletions lib/octokit/client/actions_workflow_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def workflow_run_job_logs(repo, job_id, options = {})
# @return [Sawyer::Resource] Jobs information
# @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run-attempt
def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})
paginate "#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs", options
paginate "#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs", options do |data, last_response|
data.jobs.concat last_response.data.jobs
end
end
alias list_workflow_run_attempt_jobs workflow_run_attempt_jobs

Expand All @@ -53,7 +55,9 @@ def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})
# @return [Sawyer::Resource] Jobs information
# @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
def workflow_run_jobs(repo, run_id, options = {})
paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options
paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options do |data, last_response|
data.jobs.concat last_response.data.jobs
end
end
alias list_workflow_run_jobs workflow_run_jobs
end
Expand Down
8 changes: 6 additions & 2 deletions lib/octokit/client/actions_workflow_runs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ module ActionsWorkflowRuns
# @return [Sawyer::Resource] the total count and an array of workflows
# @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
def workflow_runs(repo, workflow, options = {})
paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options
paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options do |data, last_response|
data.workflow_runs.concat last_response.data.workflow_runs
end
end
alias list_workflow_runs workflow_runs

Expand All @@ -33,7 +35,9 @@ def workflow_runs(repo, workflow, options = {})
# @return [Sawyer::Resource] the total count and an array of workflows
# @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
def repository_workflow_runs(repo, options = {})
paginate "#{Repository.path repo}/actions/runs", options
paginate "#{Repository.path repo}/actions/runs", options do |data, last_response|
data.workflow_runs.concat last_response.data.workflow_runs
end
end
alias list_repository_workflow_runs repository_workflow_runs

Expand Down
4 changes: 3 additions & 1 deletion lib/octokit/client/actions_workflows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module ActionsWorkflows
# @return [Sawyer::Resource] the total count and an array of workflows
# @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows
def workflows(repo, options = {})
paginate "#{Repository.path repo}/actions/workflows", options
paginate "#{Repository.path repo}/actions/workflows", options do |data, last_response|
data.workflows.concat last_response.data.workflows
end
end
alias list_workflows workflows

Expand Down
Loading

0 comments on commit 8517612

Please sign in to comment.