summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml87
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock5
-rwxr-xr-xRakefile3
-rw-r--r--features/support/env.rb3
-rw-r--r--spec/knapsack_merger.rb41
-rw-r--r--spec/spec_helper.rb4
7 files changed, 99 insertions, 45 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 85730e1b687..a819610c41e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -25,58 +25,55 @@ before_script:
- retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"
- RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate
-stages:
-- test
-- notifications
-
-spec:feature:
- stage: test
- script:
- - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
-
-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:
+.rspec_tests: &rspec_tests
stage: test
+ variables:
+ RAILS_ENV: "test"
+ SIMPLECOV: "true"
script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
+ - JOB_NAME=( $CI_BUILD_NAME )
+ - export CI_NODE_INDEX=${JOB_NAME[1]}
+ - export CI_NODE_TOTAL=${JOB_NAME[2]}
+ - bundle exec rake assets:precompile 2>/dev/null
+ - bundle exec rake knapsack:rspec
-spec:services:
+.spinach_tests: &spinach_tests
stage: test
+ variables:
+ RAILS_ENV: "test"
+ SIMPLECOV: "true"
script:
- - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
+ - JOB_NAME=( $CI_BUILD_NAME )
+ - export CI_NODE_INDEX=${JOB_NAME[1]}
+ - export CI_NODE_TOTAL=${JOB_NAME[2]}
+ - bundle exec rake assets:precompile 2>/dev/null
+ - bundle exec rake knapsack:cucumber
-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
+stages:
+- test
+- notifications
-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
+spec 0 10: *rspec_tests
+spec 1 10: *rspec_tests
+spec 2 10: *rspec_tests
+spec 3 10: *rspec_tests
+spec 4 10: *rspec_tests
+spec 5 10: *rspec_tests
+spec 6 10: *rspec_tests
+spec 7 10: *rspec_tests
+spec 8 10: *rspec_tests
+spec 9 10: *rspec_tests
+
+spinach 0 10: *spinach_tests
+spinach 1 10: *spinach_tests
+spinach 2 10: *spinach_tests
+spinach 3 10: *spinach_tests
+spinach 4 10: *spinach_tests
+spinach 5 10: *spinach_tests
+spinach 6 10: *spinach_tests
+spinach 7 10: *spinach_tests
+spinach 8 10: *spinach_tests
+spinach 9 10: *spinach_tests
teaspoon:
stage: test
diff --git a/Gemfile b/Gemfile
index d9429de786f..b9ae1aecb50 100644
--- a/Gemfile
+++ b/Gemfile
@@ -313,6 +313,7 @@ group :test do
gem 'webmock', '~> 1.21.0'
gem 'test_after_commit', '~> 0.4.2'
gem 'sham_rack'
+ gem 'knapsack'
end
group :production do
diff --git a/Gemfile.lock b/Gemfile.lock
index 8ae25269e65..930a0f3f8d2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -358,6 +358,9 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.10.0)
+ knapsack (1.9.0)
+ rake
+ timecop (>= 0.1.0)
launchy (2.4.3)
addressable (~> 2.3)
letter_opener (1.4.1)
@@ -728,6 +731,7 @@ GEM
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.2)
+ timecop (0.8.1)
timfel-krb5-auth (0.8.3)
tinder (1.10.1)
eventmachine (~> 1.0)
@@ -874,6 +878,7 @@ DEPENDENCIES
jquery-ui-rails (~> 5.0.0)
jwt
kaminari (~> 0.17.0)
+ knapsack
letter_opener_web (~> 1.3.0)
licensee (~> 8.0.0)
loofah (~> 2.0.3)
diff --git a/Rakefile b/Rakefile
index 5dd389d5678..16261bf8ae2 100755
--- a/Rakefile
+++ b/Rakefile
@@ -3,8 +3,11 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
+require 'knapsack'
relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__)
require relative_url_conf if File.exist?("#{relative_url_conf}.rb")
Gitlab::Application.load_tasks
+
+Knapsack.load_tasks
diff --git a/features/support/env.rb b/features/support/env.rb
index 357d164d87f..6ebd012a40f 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -11,6 +11,7 @@ ENV['RAILS_ENV'] = 'test'
require './config/environment'
require 'rspec/expectations'
require 'sidekiq/testing/inline'
+require 'knapsack'
require_relative 'capybara'
require_relative 'db_cleaner'
@@ -20,6 +21,8 @@ require_relative 'rerun'
require Rails.root.join('spec', 'support', f)
end
+Knapsack::Adapters::CucumberAdapter.bind
+
Dir["#{Rails.root}/features/steps/shared/*.rb"].each { |file| require file }
WebMock.allow_net_connect!
diff --git a/spec/knapsack_merger.rb b/spec/knapsack_merger.rb
new file mode 100644
index 00000000000..c6bcefe8464
--- /dev/null
+++ b/spec/knapsack_merger.rb
@@ -0,0 +1,41 @@
+begin
+ class Knapsack::Report
+ alias_method :save_without_leading_existing_report, :save
+
+ def load_existing_report
+ Knapsack::Presenter.existing_report = open
+ rescue
+ false
+ end
+
+ def save
+ load_existing_report
+ save_without_leading_existing_report
+ end
+ end
+
+ class << Knapsack::Presenter
+ attr_accessor :existing_report
+
+ def initialize
+ @existing_report = []
+ end
+
+ def report_hash
+ return current_report_hash unless existing_report
+ existing_report.merge(current_report_hash).sort.to_h
+ end
+
+ def current_report_hash
+ Knapsack.tracker.test_files_with_time
+ end
+
+ def report_yml
+ report_hash.to_yaml
+ end
+
+ def report_json
+ JSON.pretty_generate(report_hash)
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 576d16e7ea3..84b9ee75f6a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -15,6 +15,10 @@ require 'rspec/rails'
require 'shoulda/matchers'
require 'sidekiq/testing/inline'
require 'rspec/retry'
+require 'knapsack'
+require_relative 'knapsack_merger'
+
+Knapsack::Adapters::RSpecAdapter.bind
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.