Rakefile in selenium-connect-2.3.0 vs Rakefile in selenium-connect-3.0.0

- old
+ new

@@ -1,31 +1,47 @@ # Encoding: utf-8 -require 'bundler/gem_tasks' require 'rspec/core/rake_task' -task default: :build_ci +task default: :build -task build_ci: [:clean, :prepare, :rubocop, :spec_unit] +task build: [:clean, :prepare, :rubocop, :unit, :integration] desc 'Runs standard build activities.' -task build: [:clean, :prepare, :rubocop, :spec_unit, :spec_full] +task build_full: [:clean, :prepare, :rubocop, :unit, :integration, :system] desc 'Removes the build directory.' task :clean do - FileUtils.rm_rf('build') + FileUtils.rm_rf 'build' + FileUtils.rm 'chromedriver.log' if File.exist? 'chromedriver.log' + FileUtils.rm 'libpeerconnection.log' if File.exist? 'libpeerconnection.log' end desc 'Adds the build tmp directory for test kit creation.' task :prepare do FileUtils.mkdir_p('build/tmp') + FileUtils.mkdir_p('build/spec') end -RSpec::Core::RakeTask.new(:spec_full) -RSpec::Core::RakeTask.new(:spec_unit) do |t| - t.rspec_opts = '--tag ~selenium' +def get_rspec_flags(log_name, others = nil) + "--format documentation --out build/spec/#{log_name}.log --format html --out build/spec/#{log_name}.html --format progress #{others}" end +RSpec::Core::RakeTask.new(:unit) do |t| + t.pattern = FileList['spec/unit/**/*_spec.rb'] + t.rspec_opts = get_rspec_flags('unit') +end + +RSpec::Core::RakeTask.new(:integration) do |t| + t.pattern = FileList['spec/integration/**/*_spec.rb'] + t.rspec_opts = get_rspec_flags('integration', '--tag=~selenium') +end + +RSpec::Core::RakeTask.new(:system) do |t| + t.pattern = FileList['spec/integration/**/*_spec.rb'] + t.rspec_opts = get_rspec_flags('system', '--tag selenium') +end + desc 'Runs code quality check' task :rubocop do sh 'rubocop' end @@ -44,11 +60,11 @@ # then make sure develop is up to date system 'git checkout develop' system 'git pull --no-edit origin develop' # next assure all the tests run - task(:build).invoke + task(:build_full).invoke # start the release process system "git flow release start #{version}" # update the version number in the .gemspec file @@ -71,10 +87,12 @@ task :release_finish, :update_message do |t, args| message = args['update_message'] gemspec = File.join(Dir.getwd, 'selenium-connect.gemspec') changelog = File.join(Dir.getwd, 'CHANGELOG.md') version = File.read(gemspec).match(/s.version\s+=\s?["|'](.+)["|']/)[1] + readme = File.join(Dir.getwd, 'README.md') + date = Time.new.strftime('%Y-%m-%d') ### Changelog # get the latest tag system 'git checkout master' last_tag = `git describe --abbrev=0` @@ -83,11 +101,10 @@ hash = `git log --grep="Merge branch 'release/#{last_tag.chomp}' into develop" --format="%H"` # get all the commits since them less merges log = `git log --format="- %s" --no-merges #{hash.chomp}..HEAD` changelog_contents = File.read(changelog) - date = Time.new.strftime('%Y-%m-%d') # create the new heading updated_changelog = "##{version} (#{date})\n" + log + "\n" + changelog_contents # update the contents File.open(changelog, 'w') { |f| f.write(updated_changelog) } puts "Updated change log for version #{version}\n" @@ -97,11 +114,18 @@ /s.description(\s+)=(\s?["|']).+(["|'])/, "s.description\\1=\\2#{message}\\3" ) File.open(gemspec, 'w') { |f| f.write(updated_gemspec) } - # Commit the updated change log and gemspec - system "git commit -am 'Updated CHANGELOG.md and gemspec for #{version} release.'" + ### Update the readme heading + updated = File.read(readme).gsub( + /^#selenium-connect \d+\.\d+.\d+ \(.+\)/, + "#selenium-connect #{version} (#{date})" + ) + File.open(readme, 'w') { |f| f.write(updated) } + + # Commit the updated change log and gemspec and readme + system "git commit -am 'Updated CHANGELOG.md gemspec and readme heading for #{version} release.'" # build the gem system 'gem build selenium-connect.gemspec' # push the gem