Commit b902a9b8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'split-tests' into 'master'

Split rspec and spinach tests in parallel

For https://dev.gitlab.org/gitlab/gitlabhq/issues/2386

See merge request !874
parents 541f7675 b8f12d19
...@@ -9,35 +9,57 @@ before_script: ...@@ -9,35 +9,57 @@ before_script:
- touch log/test.log - touch log/test.log
- bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"
- bundle exec rake db:create RAILS_ENV=test - bundle exec rake db:create RAILS_ENV=test
Rspec:
spec:feature:
script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
tags:
- ruby
- mysql
spec:api:
script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
tags:
- ruby
- mysql
spec:other:
script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
tags:
- ruby
- mysql
spinach:project:
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project
tags: tags:
- ruby - ruby
- mysql - mysql
Spinach: spinach:other:
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
tags: tags:
- ruby - ruby
- mysql - mysql
Jasmine: jasmine:ci:
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake jasmine:ci - RAILS_ENV=test SIMPLECOV=true bundle exec rake jasmine:ci
tags: tags:
- ruby - ruby
- mysql - mysql
Rubocop: rubocop:
script: script:
- bundle exec rubocop - bundle exec rubocop
tags: tags:
- ruby - ruby
- mysql - mysql
Brakeman: brakeman:
script: script:
- bundle exec rake brakeman - bundle exec rake brakeman
tags: tags:
......
...@@ -45,7 +45,7 @@ Feature: Project Source Browse Files ...@@ -45,7 +45,7 @@ Feature: Project Source Browse Files
Then I am redirected to the new file on new branch Then I am redirected to the new file on new branch
And I should see its new content And I should see its new content
@javascript @tricky @javascript
Scenario: I can create file in empty repo Scenario: I can create file in empty repo
Given I own an empty project Given I own an empty project
And I visit my empty project page And I visit my empty project page
......
namespace :cache do namespace :cache do
desc "GITLAB | Clear redis cache" desc "GitLab | Clear redis cache"
task :clear => :environment do task :clear => :environment do
# Hack into Rails.cache until https://github.com/redis-store/redis-store/pull/225 # Hack into Rails.cache until https://github.com/redis-store/redis-store/pull/225
# is accepted (I hope) and we can update the redis-store gem. # is accepted (I hope) and we can update the redis-store gem.
......
task dev: ["dev:setup"] task dev: ["dev:setup"]
namespace :dev do namespace :dev do
desc "GITLAB | Setup developer environment (db, fixtures)" desc "GitLab | Setup developer environment (db, fixtures)"
task :setup => :environment do task :setup => :environment do
ENV['force'] = 'yes' ENV['force'] = 'yes'
Rake::Task["gitlab:setup"].invoke Rake::Task["gitlab:setup"].invoke
Rake::Task["gitlab:shell:setup"].invoke Rake::Task["gitlab:shell:setup"].invoke
end end
desc 'GITLAB | Start/restart foreman and watch for changes' desc 'GitLab | Start/restart foreman and watch for changes'
task :foreman => :environment do task :foreman => :environment do
sh 'rerun --dir app,config,lib -- foreman start' sh 'rerun --dir app,config,lib -- foreman start'
end end
......
...@@ -3,7 +3,7 @@ require 'active_record/fixtures' ...@@ -3,7 +3,7 @@ require 'active_record/fixtures'
namespace :gitlab do namespace :gitlab do
namespace :backup do namespace :backup do
# Create backup of GitLab system # Create backup of GitLab system
desc "GITLAB | Create a backup of the GitLab system" desc "GitLab | Create a backup of the GitLab system"
task create: :environment do task create: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
configure_cron_mode configure_cron_mode
...@@ -19,7 +19,7 @@ namespace :gitlab do ...@@ -19,7 +19,7 @@ namespace :gitlab do
end end
# Restore backup of GitLab system # Restore backup of GitLab system
desc "GITLAB | Restore a previously created backup" desc "GitLab | Restore a previously created backup"
task restore: :environment do task restore: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
configure_cron_mode configure_cron_mode
......
namespace :gitlab do namespace :gitlab do
namespace :import do namespace :import do
desc "GITLAB | Add all users to all projects (admin users are added as masters)" desc "GitLab | Add all users to all projects (admin users are added as masters)"
task all_users_to_all_projects: :environment do |t, args| task all_users_to_all_projects: :environment do |t, args|
user_ids = User.where(admin: false).pluck(:id) user_ids = User.where(admin: false).pluck(:id)
admin_ids = User.where(admin: true).pluck(:id) admin_ids = User.where(admin: true).pluck(:id)
...@@ -13,7 +13,7 @@ namespace :gitlab do ...@@ -13,7 +13,7 @@ namespace :gitlab do
ProjectMember.add_users_into_projects(projects_ids, admin_ids, ProjectMember::MASTER) ProjectMember.add_users_into_projects(projects_ids, admin_ids, ProjectMember::MASTER)
end end
desc "GITLAB | Add a specific user to all projects (as a developer)" desc "GitLab | Add a specific user to all projects (as a developer)"
task :user_to_projects, [:email] => :environment do |t, args| task :user_to_projects, [:email] => :environment do |t, args|
user = User.find_by(email: args.email) user = User.find_by(email: args.email)
project_ids = Project.pluck(:id) project_ids = Project.pluck(:id)
...@@ -21,7 +21,7 @@ namespace :gitlab do ...@@ -21,7 +21,7 @@ namespace :gitlab do
ProjectMember.add_users_into_projects(project_ids, Array.wrap(user.id), ProjectMember::DEVELOPER) ProjectMember.add_users_into_projects(project_ids, Array.wrap(user.id), ProjectMember::DEVELOPER)
end end
desc "GITLAB | Add all users to all groups (admin users are added as owners)" desc "GitLab | Add all users to all groups (admin users are added as owners)"
task all_users_to_all_groups: :environment do |t, args| task all_users_to_all_groups: :environment do |t, args|
user_ids = User.where(admin: false).pluck(:id) user_ids = User.where(admin: false).pluck(:id)
admin_ids = User.where(admin: true).pluck(:id) admin_ids = User.where(admin: true).pluck(:id)
...@@ -35,7 +35,7 @@ namespace :gitlab do ...@@ -35,7 +35,7 @@ namespace :gitlab do
end end
end end
desc "GITLAB | Add a specific user to all groups (as a developer)" desc "GitLab | Add a specific user to all groups (as a developer)"
task :user_to_groups, [:email] => :environment do |t, args| task :user_to_groups, [:email] => :environment do |t, args|
user = User.find_by_email args.email user = User.find_by_email args.email
groups = Group.all groups = Group.all
......
namespace :gitlab do namespace :gitlab do
desc "GITLAB | Check the configuration of GitLab and its environment" desc "GitLab | Check the configuration of GitLab and its environment"
task check: %w{gitlab:gitlab_shell:check task check: %w{gitlab:gitlab_shell:check
gitlab:sidekiq:check gitlab:sidekiq:check
gitlab:ldap:check gitlab:ldap:check
...@@ -8,7 +8,7 @@ namespace :gitlab do ...@@ -8,7 +8,7 @@ namespace :gitlab do
namespace :app do namespace :app do
desc "GITLAB | Check the configuration of the GitLab Rails app" desc "GitLab | Check the configuration of the GitLab Rails app"
task check: :environment do task check: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
start_checking "GitLab" start_checking "GitLab"
...@@ -329,7 +329,7 @@ namespace :gitlab do ...@@ -329,7 +329,7 @@ namespace :gitlab do
end end
namespace :gitlab_shell do namespace :gitlab_shell do
desc "GITLAB | Check the configuration of GitLab Shell" desc "GitLab | Check the configuration of GitLab Shell"
task check: :environment do task check: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
start_checking "GitLab Shell" start_checking "GitLab Shell"
...@@ -574,7 +574,7 @@ namespace :gitlab do ...@@ -574,7 +574,7 @@ namespace :gitlab do
namespace :sidekiq do namespace :sidekiq do
desc "GITLAB | Check the configuration of Sidekiq" desc "GitLab | Check the configuration of Sidekiq"
task check: :environment do task check: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
start_checking "Sidekiq" start_checking "Sidekiq"
...@@ -667,7 +667,7 @@ namespace :gitlab do ...@@ -667,7 +667,7 @@ namespace :gitlab do
end end
namespace :repo do namespace :repo do
desc "GITLAB | Check the integrity of the repositories managed by GitLab" desc "GitLab | Check the integrity of the repositories managed by GitLab"
task check: :environment do task check: :environment do
namespace_dirs = Dir.glob( namespace_dirs = Dir.glob(
File.join(Gitlab.config.gitlab_shell.repos_path, '*') File.join(Gitlab.config.gitlab_shell.repos_path, '*')
......
namespace :gitlab do namespace :gitlab do
namespace :cleanup do namespace :cleanup do
desc "GITLAB | Cleanup | Clean namespaces" desc "GitLab | Cleanup | Clean namespaces"
task dirs: :environment do task dirs: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
remove_flag = ENV['REMOVE'] remove_flag = ENV['REMOVE']
...@@ -43,7 +43,7 @@ namespace :gitlab do ...@@ -43,7 +43,7 @@ namespace :gitlab do
end end
end end
desc "GITLAB | Cleanup | Clean repositories" desc "GitLab | Cleanup | Clean repositories"
task repos: :environment do task repos: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
remove_flag = ENV['REMOVE'] remove_flag = ENV['REMOVE']
...@@ -85,7 +85,7 @@ namespace :gitlab do ...@@ -85,7 +85,7 @@ namespace :gitlab do
end end
end end
desc "GITLAB | Cleanup | Block users that have been removed in LDAP" desc "GitLab | Cleanup | Block users that have been removed in LDAP"
task block_removed_ldap_users: :environment do task block_removed_ldap_users: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
block_flag = ENV['BLOCK'] block_flag = ENV['BLOCK']
......
namespace :gitlab do namespace :gitlab do
namespace :satellites do namespace :satellites do
desc "GITLAB | Create satellite repos" desc "GitLab | Create satellite repos"
task create: :environment do task create: :environment do
create_satellites create_satellites
end end
......
namespace :gitlab do namespace :gitlab do
desc "GITLAB | Generate sdocs for project" desc "GitLab | Generate sdocs for project"
task generate_docs: :environment do task generate_docs: :environment do
system(*%W(bundle exec sdoc -o doc/code app lib)) system(*%W(bundle exec sdoc -o doc/code app lib))
end end
......
...@@ -9,7 +9,7 @@ namespace :gitlab do ...@@ -9,7 +9,7 @@ namespace :gitlab do
# * The project owner will set to the first administator of the system # * The project owner will set to the first administator of the system
# * Existing projects will be skipped # * Existing projects will be skipped
# #
desc "GITLAB | Import bare repositories from gitlab_shell -> repos_path into GitLab project instance" desc "GitLab | Import bare repositories from gitlab_shell -> repos_path into GitLab project instance"
task repos: :environment do task repos: :environment do
git_base_path = Gitlab.config.gitlab_shell.repos_path git_base_path = Gitlab.config.gitlab_shell.repos_path
......
namespace :gitlab do namespace :gitlab do
namespace :env do namespace :env do
desc "GITLAB | Show information about GitLab and its environment" desc "GitLab | Show information about GitLab and its environment"
task info: :environment do task info: :environment do
# check if there is an RVM environment # check if there is an RVM environment
......
namespace :gitlab do namespace :gitlab do
desc "GITLAB | Setup production application" desc "GitLab | Setup production application"
task setup: :environment do task setup: :environment do
setup_db setup_db
end end
......
namespace :gitlab do namespace :gitlab do
namespace :shell do namespace :shell do
desc "GITLAB | Install or upgrade gitlab-shell" desc "GitLab | Install or upgrade gitlab-shell"
task :install, [:tag, :repo] => :environment do |t, args| task :install, [:tag, :repo] => :environment do |t, args|
warn_user_is_not_gitlab warn_user_is_not_gitlab
...@@ -75,12 +75,12 @@ namespace :gitlab do ...@@ -75,12 +75,12 @@ namespace :gitlab do
end end
end end
desc "GITLAB | Setup gitlab-shell" desc "GitLab | Setup gitlab-shell"
task setup: :environment do task setup: :environment do
setup setup
end end
desc "GITLAB | Build missing projects" desc "GitLab | Build missing projects"
task build_missing_projects: :environment do task build_missing_projects: :environment do
Project.find_each(batch_size: 1000) do |project| Project.find_each(batch_size: 1000) do |project|
path_to_repo = project.repository.path_to_repo path_to_repo = project.repository.path_to_repo
......
namespace :gitlab do namespace :gitlab do
desc "GITLAB | Run all tests" desc "GitLab | Run all tests"
task :test do task :test do
cmds = [ cmds = [
%W(rake brakeman), %W(rake brakeman),
......
namespace :gitlab do namespace :gitlab do
namespace :web_hook do namespace :web_hook do
desc "GITLAB | Adds a web hook to the projects" desc "GitLab | Adds a web hook to the projects"
task :add => :environment do task :add => :environment do
web_hook_url = ENV['URL'] web_hook_url = ENV['URL']
namespace_path = ENV['NAMESPACE'] namespace_path = ENV['NAMESPACE']
...@@ -20,7 +20,7 @@ namespace :gitlab do ...@@ -20,7 +20,7 @@ namespace :gitlab do
end end
end end
desc "GITLAB | Remove a web hook from the projects" desc "GitLab | Remove a web hook from the projects"
task :rm => :environment do task :rm => :environment do
web_hook_url = ENV['URL'] web_hook_url = ENV['URL']
namespace_path = ENV['NAMESPACE'] namespace_path = ENV['NAMESPACE']
...@@ -33,7 +33,7 @@ namespace :gitlab do ...@@ -33,7 +33,7 @@ namespace :gitlab do
puts "#{count} web hooks were removed." puts "#{count} web hooks were removed."
end end
desc "GITLAB | List web hooks" desc "GitLab | List web hooks"
task :list => :environment do task :list => :environment do
namespace_path = ENV['NAMESPACE'] namespace_path = ENV['NAMESPACE']
......
require Rails.root.join('db/migrate/limits_to_mysql') require Rails.root.join('db/migrate/limits_to_mysql')
desc "GITLAB | Add limits to strings in mysql database" desc "GitLab | Add limits to strings in mysql database"
task add_limits_mysql: :environment do task add_limits_mysql: :environment do
puts "Adding limits to schema.rb for mysql" puts "Adding limits to schema.rb for mysql"
LimitsToMysql.new.up LimitsToMysql.new.up
......
desc "GITLAB | Build internal ids for issues and merge requests" desc "GitLab | Build internal ids for issues and merge requests"
task migrate_iids: :environment do task migrate_iids: :environment do
puts 'Issues'.yellow puts 'Issues'.yellow
Issue.where(iid: nil).find_each(batch_size: 100) do |issue| Issue.where(iid: nil).find_each(batch_size: 100) do |issue|
......
desc "GITLAB | Setup gitlab db" desc "GitLab | Setup gitlab db"
task :setup do task :setup do
Rake::Task["gitlab:setup"].invoke Rake::Task["gitlab:setup"].invoke
end end
namespace :sidekiq do namespace :sidekiq do
desc "GITLAB | Stop sidekiq" desc "GitLab | Stop sidekiq"
task :stop do task :stop do
system *%W(bin/background_jobs stop) system *%W(bin/background_jobs stop)
end end
desc "GITLAB | Start sidekiq" desc "GitLab | Start sidekiq"
task :start do task :start do
system *%W(bin/background_jobs start) system *%W(bin/background_jobs start)
end end
...@@ -14,7 +14,7 @@ namespace :sidekiq do ...@@ -14,7 +14,7 @@ namespace :sidekiq do
system *%W(bin/background_jobs restart) system *%W(bin/background_jobs restart)
end end
desc "GITLAB | Start sidekiq with launchd on Mac OS X" desc "GitLab | Start sidekiq with launchd on Mac OS X"
task :launchd do task :launchd do
system *%W(bin/background_jobs start_no_deamonize) system *%W(bin/background_jobs start_no_deamonize)
end end
......
Rake::Task["spec"].clear if Rake::Task.task_defined?('spec') Rake::Task["spec"].clear if Rake::Task.task_defined?('spec')
namespace :spec do namespace :spec do
desc 'GITLAB | Run request specs' desc 'GitLab | Rspec | Run request specs'
task :api do task :api do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
...@@ -10,7 +10,7 @@ namespace :spec do ...@@ -10,7 +10,7 @@ namespace :spec do
run_commands(cmds) run_commands(cmds)
end end
desc 'GITLAB | Run feature specs' desc 'GitLab | Rspec | Run feature specs'
task :feature do task :feature do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
...@@ -19,7 +19,7 @@ namespace :spec do ...@@ -19,7 +19,7 @@ namespace :spec do
run_commands(cmds) run_commands(cmds)
end end
desc 'GITLAB | Run other specs' desc 'GitLab | Rspec | Run other specs'
task :other do task :other do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
...@@ -29,7 +29,7 @@ namespace :spec do ...@@ -29,7 +29,7 @@ namespace :spec do
end end
end end
desc "GITLAB | Run specs" desc "GitLab | Run specs"
task :spec do task :spec do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
......
Rake::Task["spinach"].clear if Rake::Task.task_defined?('spinach') Rake::Task["spinach"].clear if Rake::Task.task_defined?('spinach')
desc "GITLAB | Run spinach" namespace :spinach do
task :spinach do desc "GitLab | Spinach | Run project spinach features"
tags = if ENV['SEMAPHORE'] task :project do
'~@tricky' cmds = [
else %W(rake gitlab:setup),
'~@semaphore' %W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets),
end ]
run_commands(cmds)
cmds = [ end
%W(rake gitlab:setup),
%W(spinach --tags #{tags}),
]
run_commands(cmds)
end
desc "GITLAB | Run project spinach features" desc "GitLab | Spinach | Run other spinach features"
task :spinach_project do task :other do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
%W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets), %W(spinach --tags @admin,@dashboard,@profile,@public,@snippets),
] ]
run_commands(cmds) run_commands(cmds)
end
end end
desc "GITLAB | Run other spinach features" desc "GitLab | Run spinach"
task :spinach_other do task :spinach do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
%W(spinach --tags @admin,@dashboard,@profile,@public,@snippets), %W(spinach),
] ]
run_commands(cmds) run_commands(cmds)
end end
......
Rake::Task["test"].clear Rake::Task["test"].clear
desc "GITLAB | Run all tests" desc "GitLab | Run all tests"
task :test do task :test do
Rake::Task["gitlab:test"].invoke Rake::Task["gitlab:test"].invoke
end end
...@@ -8,6 +8,6 @@ end ...@@ -8,6 +8,6 @@ end
unless Rails.env.production? unless Rails.env.production?
require 'coveralls/rake/task' require 'coveralls/rake/task'
Coveralls::RakeTask.new Coveralls::RakeTask.new
desc "GITLAB | Run all tests on CI with simplecov" desc "GitLab | Run all tests on CI with simplecov"
task :test_ci => [:rubocop, :brakeman, 'jasmine:ci', :spinach, :spec, 'coveralls:push'] task :test_ci => [:rubocop, :brakeman, 'jasmine:ci', :spinach, :spec, 'coveralls:push']
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment