summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-05-25 19:02:26 -0400
committerRobert Speicher <rspeicher@gmail.com>2016-05-26 16:09:58 -0400
commit18f8c55594b49158b94898c3eef2c0c84425855a (patch)
tree73bd00e30b86eac1ad59dc6ac7e84fabeded6332
parent416246002ea7cce1ef8d54cbcaf6ffb83b0ef32d (diff)
downloadgitlab-ce-rs-split-spec-feature.tar.gz
Add optional argument to `spec:feature` task to split runs in halfrs-split-spec-feature
This is really naive and will just divide the file list in two. One half is likely to run much faster than the other, depending on which specs end up where.
-rw-r--r--.gitlab-ci.yml424
-rw-r--r--lib/tasks/spec.rake30
2 files changed, 237 insertions, 217 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 85730e1b687..f429a215465 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,220 +27,226 @@ before_script:
stages:
- test
-- notifications
+# - notifications
-spec:feature:
+spec:feature:first_half:
stage: test
script:
- RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
+ - RAILS_ENV=test SIMPLECOV=true bundle exec rake "spec:feature[first_half]"
-spec:api:
+spec:feature:last_half:
stage: test
script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
-
-spec:models:
- stage: test
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models
-
-spec:lib:
- stage: test
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
-
-spec:services:
- stage: test
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
-
-spec:other:
- stage: test
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
-
-spinach:project:half:
- stage: test
- script:
- - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half
-
-spinach:project:rest:
- stage: test
- script:
- - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest
-
-spinach:other:
- stage: test
- script:
- - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
-
-teaspoon:
- stage: test
- script:
- - RAILS_ENV=test bundle exec teaspoon
-
-rubocop:
- stage: test
- script:
- - bundle exec rubocop
-
-scss-lint:
- stage: test
- script:
- - bundle exec rake scss_lint
-
-brakeman:
- stage: test
- script:
- - bundle exec rake brakeman
-
-flog:
- stage: test
- script:
- - bundle exec rake flog
-
-flay:
- stage: test
- script:
- - bundle exec rake flay
-
-bundler:audit:
- stage: test
- only:
- - master
- script:
- - "bundle exec bundle-audit check --update --ignore OSVDB-115941"
-
-db-migrate-reset:
- stage: test
- script:
- - RAILS_ENV=test bundle exec rake db:migrate:reset
-
-# Ruby 2.2 jobs
-
-spec:feature:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spec:api:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spec:models:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spec:lib:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spec:services:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spec:other:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spinach:project:half:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spinach:project:rest:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-spinach:other:ruby22:
- stage: test
- image: ruby:2.2
- only:
- - master
- script:
- - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
- cache:
- key: "ruby22"
- paths:
- - vendor
-
-notify:slack:
- stage: notifications
- script:
- - ./scripts/notify_slack.sh "#builds" "Build on \`$CI_BUILD_REF_NAME\` failed! Commit \`$(git log -1 --oneline)\` See <https://gitlab.com/gitlab-org/$(basename "$PWD")/commit/"$CI_BUILD_REF"/builds>"
- when: on_failure
- only:
- - master@gitlab-org/gitlab-ce
- - tags@gitlab-org/gitlab-ce
- - master@gitlab-org/gitlab-ee
- - tags@gitlab-org/gitlab-ee
+ - RAILS_ENV=test SIMPLECOV=true bundle exec rake "spec:feature[last_half]"
+
+# spec:api:
+# stage: test
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
+
+# spec:models:
+# stage: test
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models
+
+# spec:lib:
+# stage: test
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
+
+# spec:services:
+# stage: test
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
+
+# spec:other:
+# stage: test
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
+
+# spinach:project:half:
+# stage: test
+# script:
+# - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half
+
+# spinach:project:rest:
+# stage: test
+# script:
+# - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest
+
+# spinach:other:
+# stage: test
+# script:
+# - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
+
+# teaspoon:
+# stage: test
+# script:
+# - RAILS_ENV=test bundle exec teaspoon
+
+# rubocop:
+# stage: test
+# script:
+# - bundle exec rubocop
+
+# scss-lint:
+# stage: test
+# script:
+# - bundle exec rake scss_lint
+
+# brakeman:
+# stage: test
+# script:
+# - bundle exec rake brakeman
+
+# flog:
+# stage: test
+# script:
+# - bundle exec rake flog
+
+# flay:
+# stage: test
+# script:
+# - bundle exec rake flay
+
+# bundler:audit:
+# stage: test
+# only:
+# - master
+# script:
+# - "bundle exec bundle-audit check --update --ignore OSVDB-115941"
+
+# db-migrate-reset:
+# stage: test
+# script:
+# - RAILS_ENV=test bundle exec rake db:migrate:reset
+
+# # Ruby 2.2 jobs
+
+# spec:feature:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spec:api:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spec:models:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spec:lib:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spec:services:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spec:other:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spinach:project:half:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spinach:project:rest:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# spinach:other:ruby22:
+# stage: test
+# image: ruby:2.2
+# only:
+# - master
+# script:
+# - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
+# - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
+# cache:
+# key: "ruby22"
+# paths:
+# - vendor
+
+# notify:slack:
+# stage: notifications
+# script:
+# - ./scripts/notify_slack.sh "#builds" "Build on \`$CI_BUILD_REF_NAME\` failed! Commit \`$(git log -1 --oneline)\` See <https://gitlab.com/gitlab-org/$(basename "$PWD")/commit/"$CI_BUILD_REF"/builds>"
+# when: on_failure
+# only:
+# - master@gitlab-org/gitlab-ce
+# - tags@gitlab-org/gitlab-ce
+# - master@gitlab-org/gitlab-ee
+# - tags@gitlab-org/gitlab-ee
diff --git a/lib/tasks/spec.rake b/lib/tasks/spec.rake
index 2cf7a25a0fd..dfe248fdb15 100644
--- a/lib/tasks/spec.rake
+++ b/lib/tasks/spec.rake
@@ -1,7 +1,7 @@
Rake::Task["spec"].clear if Rake::Task.task_defined?('spec')
namespace :spec do
- desc 'GitLab | Rspec | Run request specs'
+ desc 'GitLab | RSpec | Run request specs'
task :api do
cmds = [
%W(rake gitlab:setup),
@@ -10,16 +10,17 @@ namespace :spec do
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run feature specs'
- task :feature do
+ desc 'GitLab | RSpec | Run feature specs'
+ task :feature, [:split] do |task, args|
cmds = [
%W(rake gitlab:setup),
- %W(rspec spec --tag @feature)
+ %W(rspec --).concat(split_feature_specs(args[:split]))
]
+
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run model specs'
+ desc 'GitLab | RSpec | Run model specs'
task :models do
cmds = [
%W(rake gitlab:setup),
@@ -28,7 +29,7 @@ namespace :spec do
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run service specs'
+ desc 'GitLab | RSpec | Run service specs'
task :services do
cmds = [
%W(rake gitlab:setup),
@@ -37,7 +38,7 @@ namespace :spec do
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run lib specs'
+ desc 'GitLab | RSpec | Run lib specs'
task :lib do
cmds = [
%W(rake gitlab:setup),
@@ -46,7 +47,7 @@ namespace :spec do
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run other specs'
+ desc 'GitLab | RSpec | Run other specs'
task :other do
cmds = [
%W(rake gitlab:setup),
@@ -70,3 +71,16 @@ def run_commands(cmds)
system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) or raise("#{cmd} failed!")
end
end
+
+def split_feature_specs(option = nil)
+ files = Dir["spec/features/**/*_spec.rb"]
+ count = files.length
+
+ if option == 'first_half'
+ files[0...count/2]
+ elsif option == 'last_half'
+ files[count/2..-1]
+ else
+ []
+ end
+end