Class: Stax::Cmd::Codebuild
Constant Summary
collapse
- COLORS =
{
SUCCEEDED: :green,
FAILED: :red,
FAULT: :red,
CLIENT_ERROR: :red,
STOPPED: :red,
}
Instance Method Summary
collapse
Methods inherited from SubCommand
#info, stax_info, stax_info_tasks
Instance Method Details
#builds ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/stax/mixin/codebuild.rb', line 48
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
|
#phases(id = nil) ⇒ Object
60
61
62
63
64
|
# File 'lib/stax/mixin/codebuild.rb', line 60
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
|
#projects ⇒ Object
40
41
42
43
44
|
# File 'lib/stax/mixin/codebuild.rb', line 40
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) ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'lib/stax/mixin/codebuild.rb', line 67
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 ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/stax/mixin/codebuild.rb', line 109
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) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/stax/mixin/codebuild.rb', line 90
def tail(id = nil)
trap('SIGINT', 'EXIT') 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) ⇒ Object
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/stax/mixin/codebuild.rb', line 78
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
|