Class: Bard::CI::GithubActions

Inherits:
Struct
  • Object
show all
Defined in:
lib/bard/ci/github_actions.rb

Defined Under Namespace

Classes: API, Job, Run

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#branchObject

Returns the value of attribute branch

Returns:

  • (Object)

    the current value of branch



6
7
8
# File 'lib/bard/ci/github_actions.rb', line 6

def branch
  @branch
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



6
7
8
# File 'lib/bard/ci/github_actions.rb', line 6

def project_name
  @project_name
end

#shaObject

Returns the value of attribute sha

Returns:

  • (Object)

    the current value of sha



6
7
8
# File 'lib/bard/ci/github_actions.rb', line 6

def sha
  @sha
end

Instance Method Details

#consoleObject



26
27
28
# File 'lib/bard/ci/github_actions.rb', line 26

def console
  @run.console
end

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bard/ci/github_actions.rb', line 22

def exists?
  true
end

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bard/ci/github_actions.rb', line 7

def run
  last_time_elapsed = api.last_successful_run&.time_elapsed
  @run = api.create_run!(branch)

  start_time = Time.new.to_i
  while @run.building?
    elapsed_time = Time.new.to_i - start_time
    yield elapsed_time, last_time_elapsed
    sleep(2)
    @run = api.find_run(@run.id)
  end

  @run.success?
end

#statusObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bard/ci/github_actions.rb', line 30

def status
  last_run = api.last_run
  if last_run.building?
    "Building..."
  elsif last_run.success?
    "Succeeded!"
  elsif last_run.failure?
    "Failed!\n\n#{last_run.console}"
  else
    raise "Unknown job status: #{last_run.inspect}"
  end
end