Class: GithubBot::Github::CheckRun

Inherits:
Object
  • Object
show all
Defined in:
lib/github_bot/github/check_run.rb

Overview

Public: Class to keep track of the check run that has been created for execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, repo:, sha:, client_api:, **opts) ⇒ CheckRun

Public: Create a new instance of the CheckRun

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (**opts):

  • :name (:symbol)

    The name of the check run

  • :repo (:symbol)

    The repository the checked run will be associated

  • :sha (:symbol)

    The SHA commit for the check run to execute

  • :client_api (:symbol)

    The GitHub API



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/github_bot/github/check_run.rb', line 17

def initialize(name:, repo:, sha:, client_api:, **opts)
  @client_api = client_api
  @repo = repo
  @sha = sha
  @name = name
  @run = @client_api.create_check_run(
    repo,
    name,
    sha,
    opts.merge(
      status: 'queued'
    )
  )
end

Instance Attribute Details

#nameObject (readonly)

The name/identifier of the check run



8
9
10
# File 'lib/github_bot/github/check_run.rb', line 8

def name
  @name
end

Instance Method Details

#action_required!(**options) ⇒ Object

Public: Updates the check run to require action



43
44
45
# File 'lib/github_bot/github/check_run.rb', line 43

def action_required!(**options)
  update(status: 'completed', conclusion: 'action_required', completed_at: Time.now, **options)
end

#complete!(**options) ⇒ Object

Public: Updates the check run to be complete



38
39
40
# File 'lib/github_bot/github/check_run.rb', line 38

def complete!(**options)
  update(status: 'completed', conclusion: 'success', completed_at: Time.now, **options)
end

#in_progress!(**options) ⇒ Object

Public: Updates the check run to be in progress



33
34
35
# File 'lib/github_bot/github/check_run.rb', line 33

def in_progress!(**options)
  update(status: 'in_progress', started_at: Time.now, **options)
end

#neutral!(**options) ⇒ Object

Public: Updates the check run to a neutral state



48
49
50
# File 'lib/github_bot/github/check_run.rb', line 48

def neutral!(**options)
  update(status: 'completed', conclusion: 'neutral', completed_at: Time.now, **options)
end