-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
117 lines (93 loc) · 1.89 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
require 'rake/testtask'
desc "Run tests"
Rake::TestTask.new do |t|
t.name = "test"
t.pattern = "test/*.rb"
t.warning = true
end
desc "Run benchmarks"
Rake::TestTask.new do |t|
t.name = "bench"
t.pattern = "test/bench/*.rb"
t.warning = true
end
task default: :test
#
# METRICS
#
metrics_tasks = []
begin
require 'flog_task'
FlogTask.new do |t|
t.threshold = 200
t.dirs = ['lib']
t.verbose = true
end
metrics_tasks << :flog
rescue LoadError
warn 'flog_task unavailable'
end
begin
require 'flay_task'
FlayTask.new do |t|
t.dirs = ['lib']
t.verbose = true
end
metrics_tasks << :flay
rescue LoadError
warn 'flay_task unavailable'
end
begin
require 'roodi_task'
RoodiTask.new config: '.roodi.yml', patterns: ['lib/**/*.rb']
metrics_tasks << :roodi
rescue LoadError
warn "roodi_task unavailable"
end
desc "Generate code metrics reports"
task code_metrics: metrics_tasks
#
# PROFILING
#
desc "Show current system load"
task "loadavg" do
puts File.read "/proc/loadavg"
end
def lib_sh(cmd)
sh "RUBYLIB=lib #{cmd}"
end
def rprof_sh(script, args, rprof_args = '')
lib_sh ['ruby-prof', rprof_args, script, '--', args].join(' ')
end
rprof_args = "-m1"
xname = "bin/conway_deathmatch"
xargs = "-n 100 -s 0 --renderfinal"
desc "Run ruby-prof on bin/conway_deathmatch (100 ticks)"
task "ruby-prof" => "loadavg" do
rprof_sh xname, xargs, rprof_args
end
desc "Run ruby-prof with --exclude-common-cycles"
task "ruby-prof-exclude" => "ruby-prof" do
rprof_sh xname, xargs, "#{rprof_args} --exclude-common-cycles"
end
task "no-prof" do
lib_sh [xname, xargs].join(' ')
end
#
# GEM BUILD / PUBLISH
#
begin
require 'buildar'
Buildar.new do |b|
b.gemspec_file = 'conway_deathmatch.gemspec'
b.version_file = 'VERSION'
b.use_git = true
end
rescue LoadError
# ok
end
#
# TRAVIS CI
#
desc "Rake tasks for travis to run"
task travis: %w[test no-prof]