forked from CodeGrade/bottlenose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
131 lines (108 loc) · 2.99 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
#!/usr/bin/env rake
# -*- ruby -*-
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'single_test/tasks'
Bottlenose::Application.load_tasks
task :upgrade do
#system("bin/delayed_job stop")
system("rake db:migrate")
system("bundle exec rake assets:precompile")
system("whenever -i")
#system("rake install")
system("rake restart")
#system("bin/delayed_job run")
end
task :restart do
system("touch tmp/restart.txt")
end
task :install do
system("cd sandbox/src && make")
system("cd sandbox/src && make install")
end
task :start_delayed_job do
system("cd #{Rails.root} && bin/delayed_job start > /dev/null")
end
task :reap do
system("cd #{Rails.root} && script/sandbox-reaper")
end
task :backup do
system("cd #{Rails.root} && script/remote-backup")
end
task :dump_sql do
dbcfg = Rails.configuration.database_configuration
dbname = dbcfg[Rails.env]["database"]
dbuser = dbcfg[Rails.env]["username"]
cmd = %Q{pg_dump -U "#{dbuser}" "#{dbname}" > db/dump.sql}
puts cmd
system(cmd)
system(%Q{gzip -f db/dump.sql})
end
task :restore_sql do
puts
puts "This will replace the database with the latest dump!"
puts
puts "Ctrl+C to cancel, enter to continue."
puts
unless File.exists?("db/dump.sql.gz")
puts "No db dump found, aborting."
exit(0)
end
dbcfg = Rails.configuration.database_configuration
dbname = dbcfg[Rails.env]["database"]
dbuser = dbcfg[Rails.env]["username"]
system("rake db:drop")
system("rake db:create")
cmd = %Q{zcat db/dump.sql.gz | psql -U "#{dbuser}" #{dbname}}
system(cmd)
end
task :backup_and_reap do
Rake::Task["backup"].execute
Rake::Task["reap"].execute
end
namespace :db do
task :nuke do
puts
puts "This will destroy the database!"
puts
puts "Press CTRL+C now if you're running this on the"
puts "production server like Mark."
puts
puts "Otherwise, press enter to continue."
$stdin.readline
system("rake nuke_uploads")
system("rake db:drop")
system("rake db:create")
system("rake db:schema:load")
system("rake db:seed")
end
end
task :nuke_uploads do
puts
puts "This will delete all student work."
puts
puts "CTRL+C to cancel, or enter to continue"
puts
$stdin.readline
system("rm -rf public/assignments")
system("rm -rf public/submissions")
system("rm -rf public/uploads")
system("mkdir public/uploads")
system("touch public/uploads/empty")
end
task :clean do
Rake::Task["log:clear"].execute
Rake::Task["tmp:clear"].execute
Rake::Task["tmp:cache:clear"].execute
end
namespace :test do
task :short do
puts "\trake test:units"
system("(rake test:units) 2>&1 | grep failures")
puts "\trake test:functionals"
system("(rake test:functionals) 2>&1 | grep failures")
puts "\trake test:integration"
system("(rake test:integration) 2>&1 | grep failures")
end
end