-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxcs.rb
More file actions
executable file
·64 lines (57 loc) · 1.72 KB
/
xcs.rb
File metadata and controls
executable file
·64 lines (57 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env ruby
require_relative 'xcs-base'
#output = send(*ARGV)
if ARGV.count < 2
puts "Usage: ./xcs-cli.rb (status|run|update-branch|cancel) [bot name] [additional args]"
puts "Regex is supported for bot name"
exit
end
action = ARGV[0]
bot_name = Regexp.new ARGV[1], Regexp::IGNORECASE
bots = get_bots.keep_if { |b| b.longName =~ bot_name }
#bots.each { |b| prints "%s %s\n", b.longName, b.guid }
case action
when "status"
bots.each do |bot|
printf "%-30s %s\n", bot.name, bot.latest_run_status
bot.botruns.last.to_s
end
when "run"
bots.each do |bot|
response = bot.integrate
printf "Scheduled botrun for %s\n", bot.name
printf "Integration queued is %s\n", response.integration
end
when "create-test"
options = {
"name" => "test",
"buildProjectPath" => "common/AXPlatformTest/AXPlatformTest.xcodeproj",
"buildSchemeName" => "CI Build",
"scmBranch" => "main",
"scmGUID" => "2ded7b82-44b1-b7d0-4ca8-15a6a266c7f1"
}
printf "%s\n", Bot.new(options).to_h
when "update-branch"
branch_name = ARGV[2]
bots.each do |bot|
options = { "branch" => branch_name }
bot.update options
end
when "cancel"
# TODO wichen: I think it's a little buggy. Doens't always work
bot_names = bots.map { |b| b.name }
puts "Canceling #{bot_names} until script is interrupted\n"
while true
bots.each do |bot|
status = bot.latestRunStatus
if status =~ /(running|integrating)/
printf "%s is running. Canceling...\n", bot.name
bot.cancel
elsif status =~ /(completed|canceled)/
else
printf "%s: %s\n", bot.name, status
end
end
sleep 2
end
end