forked from voxpupuli/beaker-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
179 lines (153 loc) · 4.95 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
require 'rspec/core/rake_task'
namespace :test do
namespace :spec do
desc "Run spec tests"
RSpec::Core::RakeTask.new(:run) do |t|
t.rspec_opts = ['--color', '--format documentation']
t.pattern = 'spec/'
end
desc "Run spec tests with coverage"
RSpec::Core::RakeTask.new(:coverage) do |t|
ENV['BEAKER_DOCKER_COVERAGE'] = 'y'
t.rspec_opts = ['--color', '--format documentation']
t.pattern = 'spec/'
end
end
namespace :acceptance do
desc <<-EOS
A quick acceptance test, named because it has no pre-suites to run
EOS
task :quick do
# setup & load_path of beaker's acceptance base and lib directory
beaker_gem_spec = Gem::Specification.find_by_name('beaker')
beaker_gem_dir = beaker_gem_spec.gem_dir
beaker_test_base_dir = File.join(beaker_gem_dir, 'acceptance/tests/base')
load_path_option = File.join(beaker_gem_dir, 'acceptance/lib')
ENV['BEAKER_setfile'] = 'acceptance/config/nodes/hosts.yaml'
sh("beaker",
"--hosts", "acceptance/config/nodes/hosts.yaml",
# We can't run these tests until the rsync support in the main
# beaker/host.rb is updated to work with passwords.
# "--tests", beaker_test_base_dir,
# "--load-path", load_path_option,
"--tests", 'acceptance/tests/',
"--log-level", "debug",
"--debug")
end
end
end
# namespace-named default tasks.
# these are the default tasks invoked when only the namespace is referenced.
# they're needed because `task :default` in those blocks doesn't work as expected.
task 'test:spec' => 'test:spec:run'
task 'test:acceptance' => 'test:acceptance:quick'
# global defaults
task :test => 'test:spec'
task :default => :test
###########################################################
#
# Documentation Tasks
#
###########################################################
DOCS_DAEMON = "yard server --reload --daemon --server thin"
FOREGROUND_SERVER = 'bundle exec yard server --reload --verbose --server thin lib/beaker'
def running?( cmdline )
ps = `ps -ef`
found = ps.lines.grep( /#{Regexp.quote( cmdline )}/ )
if found.length > 1
raise StandardError, "Found multiple YARD Servers. Don't know what to do."
end
yes = found.empty? ? false : true
return yes, found.first
end
def pid_from( output )
output.squeeze(' ').strip.split(' ')[1]
end
desc 'Start the documentation server in the foreground'
task :docs => 'docs:clear' do
original_dir = Dir.pwd
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
sh FOREGROUND_SERVER
Dir.chdir( original_dir )
end
namespace :docs do
desc 'Clear the generated documentation cache'
task :clear do
original_dir = Dir.pwd
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
sh 'rm -rf docs'
Dir.chdir( original_dir )
end
desc 'Generate static documentation'
task :gen => 'docs:clear' do
original_dir = Dir.pwd
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
output = `bundle exec yard doc`
puts output
if output =~ /\[warn\]|\[error\]/
fail "Errors/Warnings during yard documentation generation"
end
Dir.chdir( original_dir )
end
desc 'Run the documentation server in the background, alias `bg`'
task :background => 'docs:clear' do
yes, output = running?( DOCS_DAEMON )
if yes
puts "Not starting a new YARD Server..."
puts "Found one running with pid #{pid_from( output )}."
else
original_dir = Dir.pwd
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
sh "bundle exec #{DOCS_DAEMON}"
Dir.chdir( original_dir )
end
end
task(:bg) { Rake::Task['docs:background'].invoke }
desc 'Check the status of the documentation server'
task :status do
yes, output = running?( DOCS_DAEMON )
if yes
pid = pid_from( output )
puts "Found a YARD Server running with pid #{pid}"
else
puts "Could not find a running YARD Server."
end
end
desc "Stop a running YARD Server"
task :stop do
yes, output = running?( DOCS_DAEMON )
if yes
pid = pid_from( output )
puts "Found a YARD Server running with pid #{pid}"
`kill #{pid}`
puts "Stopping..."
yes, output = running?( DOCS_DAEMON )
if yes
`kill -9 #{pid}`
yes, output = running?( DOCS_DAEMON )
if yes
puts "Could not Stop Server!"
else
puts "Server stopped."
end
else
puts "Server stopped."
end
else
puts "Could not find a running YARD Server"
end
end
end
begin
require 'rubygems'
require 'github_changelog_generator/task'
rescue LoadError
else
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog}
config.user = 'voxpupuli'
config.project = 'beaker-docker'
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
config.future_release = gem_version
end
end