class Stax::Cmd::Codebuild
Constants
- COLORS
Public Instance Methods
builds()
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 60 def builds my.stack_project_names.each do |project| debug("Builds for #{project}") ids = Aws::Codebuild.builds_for_project(project, options[:number]) print_table Aws::Codebuild.builds(ids).map { |b| duration = human_time_diff(b.end_time - b.start_time) [b.id, b.initiator, color(b.build_status, COLORS), duration, b.end_time] } end end
latest_run(name)
click to toggle source
latest run id for a build project
# File lib/stax/mixin/codebuild.rb, line 40 def latest_run(name) Aws::Codebuild.builds_for_project(name, 1).first end
latest_run_link(name)
click to toggle source
aws console link to latest project run
# File lib/stax/mixin/codebuild.rb, line 45 def latest_run_link(name) id = latest_run(name) "https://console.aws.amazon.com/codesuite/codebuild/#{aws_account_id}/projects/#{name}/build/#{id}/?region=#{aws_region}" end
link()
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 134 def link my.stack_project_names.map do |name| puts latest_run_link(name) end end
open()
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 141 def open my.stack_project_names.map do |name| os_open(latest_run_link(name)) end end
phases(id = nil)
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 72 def phases(id = nil) id ||= Aws::Codebuild.builds_for_project(my.stack_project_names.first, 1).first debug("Phases for build #{id}") Aws::Codebuild.builds([id]).first.phases.each(&method(:print_phase)) end
print_phase(p)
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 33 def print_phase(p) duration = (d = p.duration_in_seconds) ? "#{d}s" : '' status = p.phase_status || (p.phase_type == 'COMPLETED' ? '' : 'in progress') puts "%-16s %-12s %4s %s" % [p.phase_type, color(status, COLORS), duration, p.end_time] end
projects()
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 52 def projects print_table Aws::Codebuild.projects(my.stack_project_names).map { |p| [p.name, p.source.location, p.environment.image, p.environment.compute_type, p.last_modified] } end
reports(id = nil)
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 79 def reports(id = nil) id ||= Aws::Codebuild.builds_for_project(my.stack_project_names.first, 1).first debug("Reports for build #{id}") report_arns = Aws::Codebuild.builds([id]).first.report_arns print_table Aws::Codebuild.reports(report_arns).map { |r| duration = (r.test_summary.duration_in_nano_seconds/1_000_000_000.0).to_s + 's' [ r.name, color(r.status, COLORS), duration, r.created ] } end
start()
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 121 def start project = options[:project] || my.stack_project_names.first version = options[:version] || Git.sha debug("Starting build for #{project} #{version}") build = Aws::Codebuild.start( project_name: project, source_version: version, ) puts build.id tail build.id end
tail(id = nil)
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 102 def tail(id = nil) trap('SIGINT', 'EXIT') # clean exit with ctrl-c id ||= Aws::Codebuild.builds_for_project(my.stack_project_names.first, 1).first debug("Phases for build #{id}") seen = {} loop do (Aws::Codebuild.builds([id]).first.phases || []).each do |p| i = p.phase_type + p.phase_status.to_s print_phase(p) unless seen[i] seen[i] = true end break if seen['COMPLETED'] sleep(3) end end
tests(id = nil)
click to toggle source
# File lib/stax/mixin/codebuild.rb, line 90 def tests(id = nil) id ||= Aws::Codebuild.builds_for_project(my.stack_project_names.first, 1).first Aws::Codebuild.builds([id]).first.report_arns.each do |report_arn| debug("Tests for report #{report_arn}") print_table Aws::Codebuild.tests(report_arn).map { |t| duration = (t.duration_in_nano_seconds/1_000_000).to_s + 'ms' [ t.name, color(t.status, COLORS), t.prefix, t.message, duration ] } end end