Skip to content

Commit

Permalink
Migrate and fix rake tasks in myapp
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Dec 12, 2016
1 parent fc168fe commit 9ce75f9
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 56 deletions.
58 changes: 2 additions & 56 deletions myapp/Rakefile
Original file line number Diff line number Diff line change
@@ -1,58 +1,4 @@
#!/usr/bin/env rake

task :appraise do
failed = false

%w(4 5).each do |ver|
%w(production development).each do |env|
output = `bundle exec ruby integration_setup.rb`
if output.strip != ''
puts output
exit(-1)
end

rout, wout = IO.pipe
rerr, werr = IO.pipe

command = "bundle exec sidekiq"
pid = Process.spawn({'RAILS_ENV' => env, 'BUNDLE_GEMFILE' => "gemfiles/rails_#{ver}.gemfile"},
command, :out => wout, :err => werr)
status = nil
begin
require 'timeout'
Timeout.timeout(10) do
Process.wait(pid)
end
rescue Timeout::Error
puts "Killing #{pid}"
Process.kill('KILL', pid)
end
status = $?

# close write ends so we could read them
wout.close
werr.close

stdout = rout.readlines
stderr = rerr.readlines

# dispose the read ends of the pipes
rout.close
rerr.close

rc = status.exitstatus
success = stdout.grep(/Success/).size == 3
if success
puts "#{ver}/#{env} success, #{pid}/#{rc}/#{success}"
else
puts stdout.join
puts stderr.join if stderr.size > 0
puts "#{ver}/#{env} failed, #{pid}/#{rc}/#{success}"
failed = true
end
end
end
exit(failed ? -1 : 0)
end

task :default => :appraise
require File.expand_path('../config/application', __FILE__)
Myapp::Application.load_tasks
59 changes: 59 additions & 0 deletions myapp/Rakefile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env rake

desc "Run rails integration tests for Sidekiq"
task :appraise do
failed = false

%w(4 5).each do |ver|
%w(production development).each do |env|
output = `bundle exec ruby integration_setup.rb`
if output.strip != ''
puts output
exit(-1)
end

rout, wout = IO.pipe
rerr, werr = IO.pipe

command = "bundle exec sidekiq"
pid = Process.spawn({'RAILS_ENV' => env, 'BUNDLE_GEMFILE' => "gemfiles/rails_#{ver}.gemfile"},
command, :out => wout, :err => werr)
status = nil
begin
require 'timeout'
Timeout.timeout(10) do
Process.wait(pid)
end
rescue Timeout::Error
puts "Killing #{pid}"
Process.kill('KILL', pid)
end
status = $?

# close write ends so we could read them
wout.close
werr.close

stdout = rout.readlines
stderr = rerr.readlines

# dispose the read ends of the pipes
rout.close
rerr.close

rc = status.exitstatus
success = stdout.grep(/Success/).size == 3
if success
puts "#{ver}/#{env} success, #{pid}/#{rc}/#{success}"
else
puts stdout.join
puts stderr.join if stderr.size > 0
puts "#{ver}/#{env} failed, #{pid}/#{rc}/#{success}"
failed = true
end
end
end
exit(failed ? -1 : 0)
end

task :default => :appraise
22 changes: 22 additions & 0 deletions myapp/db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20120123214055) do

create_table "posts", force: :cascade do |t|
t.string "title"
t.string "body"
t.datetime "created_at"
t.datetime "updated_at"
end

end

0 comments on commit 9ce75f9

Please sign in to comment.