Module: Octokit::Client::Checks

Included in:
Octokit::Client
Defined in:
lib/octokit/client/checks.rb

Overview

Methods for the Checks API

Instance Method Summary collapse

Instance Method Details

#check_run(repo, id, options = {}) ⇒ Sawyer::Resource

Get a single check run

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The ID of the check run

Returns:

  • (Sawyer::Resource)

    A hash representing the check run

See Also:



100
101
102
# File 'lib/octokit/client/checks.rb', line 100

def check_run(repo, id, options = {})
  get "#{Repository.path repo}/check-runs/#{id}", options
end

#check_run_annotations(repo, id, options = {}) ⇒ Array<Sawyer::Resource>

List annotations for a check run

Examples:

List annotations for a check run

annotations = @client.check_run_annotations("octocat/Hello-World", 51295429)
annotations.count # => 1
annotations[0].path # => "README.md"
annotations[0].message # => "Looks good!"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The ID of the check run

Returns:

  • (Array<Sawyer::Resource>)

    An array of hashes representing check run annotations

See Also:



115
116
117
# File 'lib/octokit/client/checks.rb', line 115

def check_run_annotations(repo, id, options = {})
  paginate "#{Repository.path repo}/check-runs/#{id}/annotations", options
end

#check_runs_for_check_suite(repo, id, options = {}) ⇒ Sawyer::Resource Also known as: list_check_runs_for_check_suite

List check runs in a check suite

Examples:

List check runs in a check suite

result = @client.check_runs_for_check_suite("octocat/Hello-World", 50440400, status: "in_progress")
result.total_count # => 1
result.check_runs.count # => 1
result.check_runs[0].check_suite.id # => 50440400
result.check_runs[0].status # => "in_progress"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The ID of the check suite

  • options (Hash) (defaults to: {})

    A set of optional filters

Options Hash (options):

  • :check_name (String)

    Returns check runs with the specified name

  • :status (String)

    Returns check runs with the specified status

  • :filter (String)

    Filters check runs by their completed_at timestamp

Returns:

  • (Sawyer::Resource)

    A hash representing a collection of check runs

See Also:



86
87
88
89
90
91
# File 'lib/octokit/client/checks.rb', line 86

def check_runs_for_check_suite(repo, id, 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

#check_runs_for_ref(repo, ref, options = {}) ⇒ Sawyer::Resource Also known as: list_check_runs_for_ref

List check runs for a specific ref

Examples:

List check runs for a specific ref

result = @client.check_runs_for_ref("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd", status: "in_progress")
result.total_count # => 1
result.check_runs.count # => 1
result.check_runs[0].id # => 51295429
result.check_runs[0].status # => "in_progress"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • ref (String)

    A SHA, branch name, or tag name

  • options (Hash) (defaults to: {})

    A set of optional filters

Options Hash (options):

  • :check_name (String)

    Returns check runs with the specified name

  • :status (String)

    Returns check runs with the specified status

  • :filter (String)

    Filters check runs by their completed_at timestamp

Returns:

  • (Sawyer::Resource)

    A hash representing a collection of check runs

See Also:



62
63
64
65
66
67
# File 'lib/octokit/client/checks.rb', line 62

def check_runs_for_ref(repo, ref, 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

#check_suite(repo, id, options = {}) ⇒ Sawyer::Resource

Get a single check suite

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The ID of the check suite

Returns:

  • (Sawyer::Resource)

    A hash representing the check suite

See Also:



129
130
131
# File 'lib/octokit/client/checks.rb', line 129

def check_suite(repo, id, options = {})
  get "#{Repository.path repo}/check-suites/#{id}", options
end

#check_suites_for_ref(repo, ref, options = {}) ⇒ Sawyer::Resource Also known as: list_check_suites_for_ref

List check suites for a specific ref

Examples:

List check suites for a specific ref

result = @client.check_suites_for_ref("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd", app_id: 76765)
result.total_count # => 1
result.check_suites.count # => 1
result.check_suites[0].id # => 50440400
result.check_suites[0].app.id # => 76765

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • ref (String)

    A SHA, branch name, or tag name

  • options (Hash) (defaults to: {})

    A set of optional filters

Options Hash (options):

  • :app_id (Integer)

    Filters check suites by GitHub App id

  • :check_name (String)

    Filters checks suites by the name of the check run

Returns:

  • (Sawyer::Resource)

    A hash representing a collection of check suites

See Also:



148
149
150
151
152
153
# File 'lib/octokit/client/checks.rb', line 148

def check_suites_for_ref(repo, ref, 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

#create_check_run(repo, name, head_sha, options = {}) ⇒ Sawyer::Resource

Create a check run

Examples:

Create a check run

check_run = @client.create_check_run("octocat/Hello-World", "my-check", "7638417db6d59f3c431d3e1f261cc637155684cd")
check_run.name # => "my-check"
check_run.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
check_run.status # => "queued"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • name (String)

    The name of the check

  • head_sha (String)

    The SHA of the commit to check

Returns:

  • (Sawyer::Resource)

    A hash representing the new check run

See Also:



25
26
27
28
29
30
# File 'lib/octokit/client/checks.rb', line 25

def create_check_run(repo, name, head_sha, options = {})
  options[:name] = name
  options[:head_sha] = head_sha

  post "#{Repository.path repo}/check-runs", options
end

#create_check_suite(repo, head_sha, options = {}) ⇒ Sawyer::Resource

Create a check suite

Examples:

Create a check suite

check_suite = @client.create_check_suite("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd")
check_suite.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
check_suite.status # => "queued"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • head_sha (String)

    The SHA of the commit to check

Returns:

  • (Sawyer::Resource)

    A hash representing the new check suite

See Also:



182
183
184
185
186
# File 'lib/octokit/client/checks.rb', line 182

def create_check_suite(repo, head_sha, options = {})
  options[:head_sha] = head_sha

  post "#{Repository.path repo}/check-suites", options
end

#rerequest_check_suite(repo, id, options = {}) ⇒ Boolean

Rerequest check suite

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The ID of the check suite

Returns:

  • (Boolean)

    True if successful, raises an error otherwise

See Also:



194
195
196
197
# File 'lib/octokit/client/checks.rb', line 194

def rerequest_check_suite(repo, id, options = {})
  post "#{Repository.path repo}/check-suites/#{id}/rerequest", options
  true
end

#set_check_suite_preferences(repo, options = {}) ⇒ Sawyer::Resource

Set preferences for check suites on a repository

Examples:

Set preferences for check suites on a repository

result = @client.set_check_suite_preferences("octocat/Hello-World", auto_trigger_checks: [{ app_id: 76765, setting: false }])
result.preferences.auto_trigger_checks.count # => 1
result.preferences.auto_trigger_checks[0].app_id # => 76765
result.preferences.auto_trigger_checks[0].setting # => false
result.repository.full_name # => "octocat/Hello-World"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • options (Hash) (defaults to: {})

    Preferences to set

Returns:

  • (Sawyer::Resource)

    A hash representing the repository’s check suite preferences

See Also:



168
169
170
# File 'lib/octokit/client/checks.rb', line 168

def set_check_suite_preferences(repo, options = {})
  patch "#{Repository.path repo}/check-suites/preferences", options
end

#update_check_run(repo, id, options = {}) ⇒ Sawyer::Resource

Update a check run

Examples:

Update a check run

check_run = @client.update_check_run("octocat/Hello-World", 51295429, status: "in_progress")
check_run.id # => 51295429
check_run.status # => "in_progress"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The ID of the check run

Returns:

  • (Sawyer::Resource)

    A hash representing the updated check run

See Also:



42
43
44
# File 'lib/octokit/client/checks.rb', line 42

def update_check_run(repo, id, options = {})
  patch "#{Repository.path repo}/check-runs/#{id}", options
end