Rakefile in appsignal-0.9.1 vs Rakefile in appsignal-0.9.2

- old
+ new

@@ -1,5 +1,30 @@ +GEMFILES = %w( + capistrano2 + capistrano3 + no_dependencies + rails-3.0 + rails-3.1 + rails-3.2 + rails-4.0 + rails-4.1 + sinatra +) + +RUBY_VERSIONS = %w( + 1.9.3-p429 + 2.0.0-p451 + 2.1.2 + jruby-1.7.9 + rbx-2.2.9 +) + +VERSION_MANAGERS = { + :rbenv => 'rbenv local', + :rvm => 'rvm use' +} + task :publish do require 'appsignal/version' NAME = 'appsignal' VERSION_FILE = 'lib/appsignal/version.rb' @@ -57,47 +82,48 @@ raise "Actually change the version in: #{VERSION_FILE}" end end task :bundle do - system 'bundle --gemfile gemfiles/capistrano2.gemfile' - system 'bundle --gemfile gemfiles/capistrano3.gemfile' - system 'bundle --gemfile gemfiles/no_dependencies.gemfile' - system 'bundle --gemfile gemfiles/rails-3.0.gemfile' - system 'bundle --gemfile gemfiles/rails-3.1.gemfile' - system 'bundle --gemfile gemfiles/rails-3.2.gemfile' - system 'bundle --gemfile gemfiles/rails-4.0.gemfile' - system 'bundle --gemfile gemfiles/rails-4.1.gemfile' - system 'bundle --gemfile gemfiles/sinatra.gemfile' + GEMFILES.each do |gemfile| + system "bundle --gemfile gemfiles/#{gemfile}.gemfile" + end end task :spec do - puts 'Running capistrano2' - system 'env BUNDLE_GEMFILE=gemfiles/capistrano2.gemfile bundle exec rspec' + GEMFILES.each do |gemfile| + puts "Running #{gemfile}" + raise 'Not successful' unless system("env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec") + end +end - puts 'Running capistrano3' - system 'env BUNDLE_GEMFILE=gemfiles/capistrano3.gemfile bundle exec rspec' +task :generate_bundle_and_spec_all do + VERSION_MANAGERS.each do |version_manager, switch_command| + out = [] + out << '#!/bin/sh' + out << 'rm -f .ruby-version' - puts 'Running no dependencies' - system 'env BUNDLE_GEMFILE=gemfiles/no_dependencies.gemfile bundle exec rspec' + out << "echo 'Using #{version_manager}'" + RUBY_VERSIONS.each do |version| + out << "echo 'Switching to #{version}'" + out << "#{switch_command} #{version} || { echo 'Switching Ruby failed'; exit 1; }" + GEMFILES.each do |gemfile| + out << "echo 'Bundling #{gemfile} in #{version}'" + out << "bundle --quiet --gemfile gemfiles/#{gemfile}.gemfile || { echo 'Bundling failed'; exit 1; }" + out << "echo 'Running #{gemfile} in #{version}'" + out << "env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec || { echo 'Running specs failed'; exit 1; }" + end + end + out << 'rm .ruby-version' + out << "echo 'Successfully ran specs for all environments'" - puts 'Running rails-3.0' - system 'env BUNDLE_GEMFILE=gemfiles/rails-3.0.gemfile bundle exec rspec' - - puts 'Running rails-3.1' - system 'env BUNDLE_GEMFILE=gemfiles/rails-3.1.gemfile bundle exec rspec' - - puts 'Running rails-3.2' - system 'env BUNDLE_GEMFILE=gemfiles/rails-3.2.gemfile bundle exec rspec' - - puts 'Running rails-4.0' - system 'env BUNDLE_GEMFILE=gemfiles/rails-4.0.gemfile bundle exec rspec' - - puts 'Running rails-4.1' - system 'env BUNDLE_GEMFILE=gemfiles/rails-4.1.gemfile bundle exec rspec' - - puts 'Running sinatra' - system 'env BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec' + script = "bundle_and_spec_all_#{version_manager}.sh" + File.open(script, 'w') do |file| + file.write out.join("\n") + end + File.chmod(0775, script) + puts "Generated #{script}" + end end task :console do require 'irb' require 'irb/completion'