-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
129 lines (117 loc) · 3.8 KB
/
Rakefile
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
require "sequel/core"
require_relative "env"
require_relative "helpers/buildkite"
require_relative "helpers/data_transfer"
require_relative "helpers/data_cleaner"
include Helpers
namespace :db do
##
# rake db:migrate
desc "Run DB migrations"
task :migrate, [:version] do |t, args|
Sequel.extension :migration
version = args[:version].to_i if args[:version]
Sequel.connect(DB_PATH) do |db|
Sequel::Migrator.run(db, "db/migrations", target: version)
end
end
##
# rake db:clean[555]
desc "Remove specific nb"
task :clean, [:nb] do |t, args|
nb = args[:nb]
db_conn = Sequel.connect(DB_PATH)
Helpers::DataCleaner.remove(db_conn, nb)
end
##
# rake db:clean_older[555]
desc "Remove all nightbuilds (with all measurements) older than nb, including it"
task :clean_older, [:nb] do |t, args|
nb = args[:nb]
db_conn = Sequel.connect(DB_PATH)
Helpers::DataCleaner.remove_this_and_older(db_conn, nb)
end
##
# rake db:clean_newer[734]
desc "Remove all nightbuilds (with all measurements) NEWER than nb, including it"
task :clean_newer, [:nb] do |t, args|
nb = args[:nb]
db_conn = Sequel.connect(DB_PATH)
Helpers::DataCleaner.remove_this_and_newer(db_conn, nb)
end
end
namespace :bk do
desc "Get results from buildkite for range of builds"
task :range, [:min_build_no, :max_build_no, :skip] do |t, args|
bk = Helpers::Buildkite.new
DB = Sequel.connect(DB_PATH)
min = args[:min_build_no].to_i if args[:min_build_no]
max = args[:max_build_no].to_i if args[:max_build_no]
case args[:skip]
when "skip_latency"
skip = {skip_latency: true}
when "skip_restorations"
skip = {skip_mainnet: true, skip_testnet: true}
else
skip = {}
end
(min..max).each do |build_no|
puts "Build: #{build_no}"
res = bk.get_benchmark_results_hash(build_no)
Helpers::DataTransfer.insert_into_db(res, DB, skip)
end
end
##
# rake bk:latest
desc "Get latest results from buildkite"
task :latest do
bk = Helpers::Buildkite.new
DB = Sequel.connect(DB_PATH)
nightly_builds = DB[:nightly_builds]
last_build_in_db = nightly_builds.order(Sequel.desc(:build_no)).first[:build_no] if nightly_builds.first
last_builds_from_bk = bk.get_pipline_build_numbers
builds = Helpers::DataTransfer.find_builds_to_transfer(last_build_in_db, last_builds_from_bk)
if builds.empty?
puts "No new build..."
else
builds.each do |build_no|
puts "Build: #{build_no}"
state = bk.get_pipeline_build(build_no)[:state]
if ["passed", "failed"].include? state
res = bk.get_benchmark_results_hash(build_no)
Helpers::DataTransfer.insert_into_db(res, DB)
else
puts " Skipping, build state = #{state}."
end
end
end
end
desc "Latencies for existing builds"
task :latencies do
bk = Helpers::Buildkite.new
DB = Sequel.connect(DB_PATH)
builds = DB[:nightly_builds].all.map { |b| b[:build_no]}
builds.each do |build_no|
puts "Build: #{build_no}"
state = bk.get_pipeline_build(build_no)[:state]
if ["passed", "failed"].include? state
res = bk.get_benchmark_results_hash(build_no)
Helpers::DataTransfer.insert_into_db(res, DB, {skip_mainnet: true, skip_testnet: true})
else
puts " Skipping, build state = #{state}."
end
end
end
desc "Update build statuses"
task :update_build_statuses do
bk = Helpers::Buildkite.new
DB = Sequel.connect(DB_PATH)
builds = DB[:nightly_builds].all.map { |b| b[:build_no]}
builds.each do |build_no|
state = bk.get_pipeline_build(build_no)[:state]
puts "Build: #{build_no} => #{state}"
DB[:nightly_builds].where(build_no: build_no).
update(build_status: state)
end
end
end