Skip to content

Commit

Permalink
Add workflow_run_job_logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mathroule authored and timrogers committed Jul 13, 2022
1 parent 573e639 commit 0ca787c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/octokit/client/actions_workflow_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ def workflow_run_job(repo, job_id, options = {})
paginate "#{Repository.path repo}/actions/jobs/#{job_id}", options
end

# Download job logs for a workflow run
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
# @param job_id [Integer, String] Id of the job
#
# @return [String] URL to the archived log files of the job
# @see https://docs.github.com/rest/actions/workflow-runs#download-job-logs-for-a-workflow-run
def workflow_run_job_logs(repo, job_id, options = {})
url = "#{Repository.path repo}/actions/jobs/#{job_id}/logs"

response = client_without_redirects.head(url, options)
response.headers['Location']
end

# List jobs for a workflow run attempt
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
Expand Down
10 changes: 10 additions & 0 deletions spec/octokit/client/actions_workflow_jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
end
end

describe '.workflow_run_job_logs' do
it 'returns job logs for a workflow run' do
request = stub_head("repos/#{@test_repo}/actions/jobs/#{@job_id}/logs")

@client.workflow_run_job_logs(@test_repo, @job_id)

assert_requested request
end
end

describe '.workflow_run_attempt_jobs' do
it 'returns jobs for a workflow run attempt' do
request = stub_get("repos/#{@test_repo}/actions/runs/#{@run_id}/attempts/#{@attempt_number}/jobs")
Expand Down

0 comments on commit 0ca787c

Please sign in to comment.