Method: Bard::CLI#ci

Defined in:
lib/bard.rb

#ci(branch = Git.current_branch) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/bard.rb', line 92

def ci branch=Git.current_branch
  ci = CI.new(project_name, branch, local: options["local-ci"])
  if ci.exists?
    return puts ci.status if options["status"]

    puts "Continuous integration: starting build on #{branch}..."

    success = ci.run do |elapsed_time, last_time|
      if last_time
        percentage = (elapsed_time.to_f / last_time.to_f * 100).to_i
        output = "  Estimated completion: #{percentage}%"
      else
        output = "  No estimated completion time. Elapsed time: #{elapsed_time} sec"
      end
      print "\x08" * output.length
      print output
      $stdout.flush
    end

    if success
      puts
      puts "Continuous integration: success!"
      if ci.jenkins? && File.exist?("coverage")
        puts "Downloading test coverage from CI..."
        download_ci_test_coverage
      end
      puts "Deploying..."
    else
      puts
      puts ci.last_response
      puts ci.console
      puts red("Automated tests failed!")
      exit 1
    end

  else
    puts red("No CI found for #{project_name}!")
    puts "Re-run with --skip-ci to bypass CI, if you absolutely must, and know what you're doing."
    exit 1
  end
end