Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 107 lines (88 sloc) 2.677 kB
5c2612a @rick a real Rakefile
rick authored
1 require 'rake'
2 require 'rake/testtask'
3
7ba478e @rick Un-spiking, phase 0 :-)
rick authored
4 desc 'Default: run unit tests.'
5 task :default => :test
5c2612a @rick a real Rakefile
rick authored
6
967f30d @rick Rakefile cleanups
rick authored
7 desc 'Test whiskey_disk'
e104e70 @rick Make the rake test task do right by bacon
rick authored
8 task :test do
9 files = Dir['spec/**/*_spec.rb'].join(" ")
10 system("bacon #{files}")
5c2612a @rick a real Rakefile
rick authored
11 end
12
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
13 namespace :integration do
14 def say(mesg)
15 STDERR.puts mesg
16 end
967f30d @rick Rakefile cleanups
rick authored
17
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
18 def vagrant_path
19 File.expand_path(File.join(File.dirname(__FILE__), 'scenarios', 'setup', 'vagrant'))
20 end
967f30d @rick Rakefile cleanups
rick authored
21
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
22 def root_path
23 File.expand_path(File.dirname(__FILE__))
24 end
967f30d @rick Rakefile cleanups
rick authored
25
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
26 def pidfile
27 File.join(vagrant_path, 'pids', 'git-daemon.pid')
28 end
967f30d @rick Rakefile cleanups
rick authored
29
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
30 def start_git_daemon
31 stop_git_daemon
32 say "Starting git daemon..."
33 run(root_path, "git daemon --base-path=#{root_path}/scenarios/git_repositories/ --reuseaddr --verbose --detach --pid-file=#{pidfile}")
34 end
967f30d @rick Rakefile cleanups
rick authored
35
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
36 def stop_git_daemon
37 return unless File.exists?(pidfile)
38 pid = File.read(pidfile).chomp
39 return if pid == ''
40 say "Stopping git daemon..."
41 run(root_path, "kill #{pid}")
42 end
967f30d @rick Rakefile cleanups
rick authored
43
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
44 def start_vm
45 say "Bringing up vagrant vm..."
46 run(vagrant_path, 'vagrant up')
47 copy_ssh_config
48 end
49
50 def stop_vm
51 say "Shutting down vagrant vm..."
52 run(vagrant_path, 'vagrant halt')
53 end
967f30d @rick Rakefile cleanups
rick authored
54
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
55 def copy_ssh_config
56 say "Capturing vagrant ssh_config data..."
57 run(vagrant_path, "vagrant ssh_config > #{vagrant_path}/ssh_config")
58 end
967f30d @rick Rakefile cleanups
rick authored
59
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
60 def run(path, cmd)
61 Dir.chdir(path)
62 say "running: #{cmd} [cwd: #{Dir.pwd}]"
63 system(cmd)
64 end
967f30d @rick Rakefile cleanups
rick authored
65
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
66 desc 'Start a vagrant VM and git-daemon server to support running integration specs'
67 task :up do
68 start_vm
69 start_git_daemon
70 end
967f30d @rick Rakefile cleanups
rick authored
71
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
72 desc 'Shut down integration vagrant VM and git-daemon server'
73 task :down do
74 stop_git_daemon
75 stop_vm
76 end
967f30d @rick Rakefile cleanups
rick authored
77
b8a285c @rick Rakefile and README updates for new integration spec maintenance tasks
rick authored
78 desc 'Completely remove the vagrant VM files used by the integration spec suite'
79 task :destroy do
80 stop_git_daemon
81 stop_vm
82 run(vagrant_path, 'vagrant destroy')
83 end
84 end
85
5c2612a @rick a real Rakefile
rick authored
86 begin
87 require 'jeweler'
88 Jeweler::Tasks.new do |gemspec|
89 gemspec.name = "whiskey_disk"
90 gemspec.summary = "embarrassingly fast deployments."
91 gemspec.description = "Opinionated gem for doing fast git-based server deployments."
92 gemspec.email = "rick@rickbradley.com"
93 gemspec.homepage = "http://github.com/flogic/whiskey_disk"
94 gemspec.authors = ["Rick Bradley"]
df6ae48 @rick Foregoing vlad dependency, just using 'ssh'.
rick authored
95 gemspec.add_dependency('rake')
967f30d @rick Rakefile cleanups
rick authored
96
dddec8d @rick exclude integration specs & scenarios from the gemspec (& gem)
rick authored
97 # I've decided that the integration spec shizzle shouldn't go into the gem
ba5379c @imajes it's not clear how this ever worked.
imajes authored
98 rejected = %w(scenarios spec/integration)
99 gemspec.files.reject {|f| rejected.include?(f) }
100 gemspec.test_files.reject {|f| rejected.include?(f) }
5c2612a @rick a real Rakefile
rick authored
101 end
967f30d @rick Rakefile cleanups
rick authored
102 Jeweler::GemcutterTasks.new
5c2612a @rick a real Rakefile
rick authored
103 rescue LoadError
7d20e73 @rick Removing Jeweler warning from Rakefile
rick authored
104 # if you get here, you need Jeweler installed to do packaging and gem installation, yo.
5c2612a @rick a real Rakefile
rick authored
105 end
106
Something went wrong with that request. Please try again.