Class: CIRunner::Check::CircleCI

Inherits:
Base
  • Object
show all
Includes:
ConcurrentDownload
Defined in:
lib/ci_runner/check/circle_ci.rb

Overview

Check class used when a project is configured to run its CI using CircleCI.

Instance Attribute Summary collapse

Attributes inherited from Base

#commit, #name, #repository, #status

Instance Method Summary collapse

Methods inherited from Base

#failed?, #success?

Constructor Details

#initialize(*args, url) ⇒ CircleCI

Returns a new instance of CircleCI.

Parameters:

  • args (See Base#initialize)
  • url (String)

    The html URL pointing to the CircleCI build.



62
63
64
65
66
# File 'lib/ci_runner/check/circle_ci.rb', line 62

def initialize(*args, url)
  super(*args)

  @url = url
end

Instance Attribute Details

#urlObject (readonly)

:private:



58
59
60
# File 'lib/ci_runner/check/circle_ci.rb', line 58

def url
  @url
end

Instance Method Details

#download_logTempfile

Download the CI logs for this CI build.

CircleCI doesn’t have an API to download a single log file for the whole build. Instead, we have to download a log output for each steps. Depending on the number of steps configured on a project, and whether it uses parallelism, the number of log files to download might be quite important.

The log for each steps are small in size, so downloading them in parallel to make things much faster.

Returns:

  • (Tempfile)


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/ci_runner/check/circle_ci.rb', line 84

def download_log
  client = Client::CircleCI.new(Configuration::User.instance.circle_ci_token)
  job = client.job(repository, build_number)
  steps = []

  job["steps"].each do |step|
    step["actions"].each do |parallel|
      next unless parallel["has_output"]

      steps << Step.new(*parallel.values_at("name", "output_url", "failed"))
    end
  end

  steps.uniq!

  steps.each do |step|
    @queue << step
  end

  process_queue
end

#providerString

Used to tell the user which CI provider we are downloading the log output from.

Returns:

  • (String)


71
72
73
# File 'lib/ci_runner/check/circle_ci.rb', line 71

def provider
  "CircleCI"
end