diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index 8901dfb..01bde54 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -5,7 +5,13 @@ namespace :ci do current_branch = `git rev-parse --abbrev-ref HEAD`.strip from = ENV['PREV_HEAD'] || "origin/#{current_branch}" + if !system("git show-ref --verify --quiet refs/remotes/#{from}") + from = 'origin/master' + end to = ENV['HEAD'] || current_branch + + puts "Testing changes between #{from} and #{to} ..." + changed_files = `git diff --name-only #{from}..#{to}`.split.select do |f| File.exist?(f) && f.split(File::SEPARATOR).first != 'vendor' end @@ -33,14 +39,23 @@ namespace :ci do end end + if tests.empty? && features.empty? && changed_plugins.empty? + puts "Could not figure out specific changes to be tested in isolation!" + end + puts + sh 'testrb', '-Itest', *tests unless tests.empty? sh 'cucumber', *features unless features.empty? sh 'xvfb-run', 'cucumber', '-p', 'selenium', *features unless features.empty? changed_plugins.each do |plugin| - task = "test:noosfero_plugins:#{plugin}" - puts "Running #{task}" - Rake::Task[task].execute + if $broken_plugins.include?(plugin) + puts "Skipping plugins/#{plugin}: marked as broken" + else + task = "test:noosfero_plugins:#{plugin}" + puts "Running #{task}" + Rake::Task[task].execute + end end end diff --git a/lib/tasks/plugins_tests.rake b/lib/tasks/plugins_tests.rake index a355dc2..87bd88f 100644 --- a/lib/tasks/plugins_tests.rake +++ b/lib/tasks/plugins_tests.rake @@ -1,4 +1,4 @@ -@broken_plugins = %w[ +$broken_plugins = %w[ anti_spam bsc comment_classification @@ -205,14 +205,14 @@ namespace :test do @all_tasks.each do |taskname| desc "Run #{taskname} tests for all plugins" task taskname do - test_sequence(@all_plugins - @broken_plugins, taskname) + test_sequence(@all_plugins - $broken_plugins, taskname) end end end desc "Run all tests for all plugins" task :noosfero_plugins do - test_sequence(@all_plugins - @broken_plugins, @all_tasks) do |failed| + test_sequence(@all_plugins - $broken_plugins, @all_tasks) do |failed| plugins_status_report(failed) end end @@ -229,7 +229,7 @@ def plugins_status_report(failed) printf ('-' * w) + ' ' + ('-' * 20) + "\n" @all_plugins.each do |plugin| - if @broken_plugins.include?(plugin) + if $broken_plugins.include?(plugin) status = "SKIP" elsif !failed[plugin] || failed[plugin].empty? status = "PASS" -- libgit2 0.21.2