From 6453e2a80f6de00d9b874027f6d93dac87938ab9 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 27 Oct 2014 18:12:52 -0200 Subject: [PATCH] ci:smoke: revamp --- lib/tasks/ci.rake | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index d7a5668..ea84489 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -2,29 +2,33 @@ namespace :ci do desc 'Continuous integration smoke test' task :smoke do - if ENV['HEAD'] && ENV['PREV_HEAD'] - from = ENV['PREV_HEAD'] - to = ENV['HEAD'] - changed_files = `git diff --name-only #{from}..#{to}`.split - # explicitly changed tests - tests = changed_files.select { |f| f =~ /test\/.*_test\.rb$/ } - features = changed_files.select { |f| f =~ /\.feature$/ } + current_branch = `git rev-parse --abbrev-ref HEAD`.strip + from = ENV['PREV_HEAD'] || "origin/#{current_branch}" + to = ENV['HEAD'] || current_branch + changed_files = `git diff --name-only #{from}..#{to}`.split - # match changed code files to their respective tests - changed_files.each do |f| - if f =~ /^(app|lib)\// - basename = File.basename(f, '.rb') - Dir.glob("test/**/#{basename}_test.rb").each do |t| - tests << t unless tests.include?(t) - end + unless $stdout.isatty + sh "git", "log", "--name-status", "#{from}..#{to}" + end + + # explicitly changed tests + tests = changed_files.select { |f| f =~ /test\/.*_test\.rb$/ } + features = changed_files.select { |f| f =~ /\.feature$/ } + + # match changed code files to their respective tests + changed_files.each do |f| + if f =~ /^(app|lib)\// + basename = File.basename(f, '.rb') + Dir.glob("test/**/#{basename}_test.rb").each do |t| + tests << t unless tests.include?(t) end end - - sh 'testrb', *tests unless tests.empty? - sh 'cucumber', *features unless features.empty? - sh 'cucumber', '-p', 'selenium', *features unless features.empty? end + + sh 'testrb', *tests unless tests.empty? + sh 'cucumber', *features unless features.empty? + sh 'cucumber', '-p', 'selenium', *features unless features.empty? end end -- libgit2 0.21.2