Commit 0a1fccb2 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Try to use knapsack

parent ca3c5c29
...@@ -25,58 +25,55 @@ before_script: ...@@ -25,58 +25,55 @@ before_script:
- retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"
- RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate - RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate
stages: .rspec_tests: &rspec_tests
- 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:
stage: test stage: test
variables:
RAILS_ENV: "test"
SIMPLECOV: "true"
script: 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 stage: test
variables:
RAILS_ENV: "test"
SIMPLECOV: "true"
script: 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: stages:
stage: test - test
script: - notifications
- 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: spec 0 10: *rspec_tests
stage: test spec 1 10: *rspec_tests
script: spec 2 10: *rspec_tests
- RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null spec 3 10: *rspec_tests
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other 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: teaspoon:
stage: test stage: test
......
...@@ -313,6 +313,7 @@ group :test do ...@@ -313,6 +313,7 @@ group :test do
gem 'webmock', '~> 1.21.0' gem 'webmock', '~> 1.21.0'
gem 'test_after_commit', '~> 0.4.2' gem 'test_after_commit', '~> 0.4.2'
gem 'sham_rack' gem 'sham_rack'
gem 'knapsack'
end end
group :production do group :production do
......
...@@ -358,6 +358,9 @@ GEM ...@@ -358,6 +358,9 @@ GEM
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
kgio (2.10.0) kgio (2.10.0)
knapsack (1.9.0)
rake
timecop (>= 0.1.0)
launchy (2.4.3) launchy (2.4.3)
addressable (~> 2.3) addressable (~> 2.3)
letter_opener (1.4.1) letter_opener (1.4.1)
...@@ -728,6 +731,7 @@ GEM ...@@ -728,6 +731,7 @@ GEM
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (2.0.2) tilt (2.0.2)
timecop (0.8.1)
timfel-krb5-auth (0.8.3) timfel-krb5-auth (0.8.3)
tinder (1.10.1) tinder (1.10.1)
eventmachine (~> 1.0) eventmachine (~> 1.0)
...@@ -874,6 +878,7 @@ DEPENDENCIES ...@@ -874,6 +878,7 @@ DEPENDENCIES
jquery-ui-rails (~> 5.0.0) jquery-ui-rails (~> 5.0.0)
jwt jwt
kaminari (~> 0.17.0) kaminari (~> 0.17.0)
knapsack
letter_opener_web (~> 1.3.0) letter_opener_web (~> 1.3.0)
licensee (~> 8.0.0) licensee (~> 8.0.0)
loofah (~> 2.0.3) loofah (~> 2.0.3)
......
...@@ -3,8 +3,11 @@ ...@@ -3,8 +3,11 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__) require File.expand_path('../config/application', __FILE__)
require 'knapsack'
relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__) relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__)
require relative_url_conf if File.exist?("#{relative_url_conf}.rb") require relative_url_conf if File.exist?("#{relative_url_conf}.rb")
Gitlab::Application.load_tasks Gitlab::Application.load_tasks
Knapsack.load_tasks
...@@ -11,6 +11,7 @@ ENV['RAILS_ENV'] = 'test' ...@@ -11,6 +11,7 @@ ENV['RAILS_ENV'] = 'test'
require './config/environment' require './config/environment'
require 'rspec/expectations' require 'rspec/expectations'
require 'sidekiq/testing/inline' require 'sidekiq/testing/inline'
require 'knapsack'
require_relative 'capybara' require_relative 'capybara'
require_relative 'db_cleaner' require_relative 'db_cleaner'
...@@ -20,6 +21,8 @@ require_relative 'rerun' ...@@ -20,6 +21,8 @@ require_relative 'rerun'
require Rails.root.join('spec', 'support', f) require Rails.root.join('spec', 'support', f)
end end
Knapsack::Adapters::CucumberAdapter.bind
Dir["#{Rails.root}/features/steps/shared/*.rb"].each { |file| require file } Dir["#{Rails.root}/features/steps/shared/*.rb"].each { |file| require file }
WebMock.allow_net_connect! WebMock.allow_net_connect!
......
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
...@@ -15,6 +15,10 @@ require 'rspec/rails' ...@@ -15,6 +15,10 @@ require 'rspec/rails'
require 'shoulda/matchers' require 'shoulda/matchers'
require 'sidekiq/testing/inline' require 'sidekiq/testing/inline'
require 'rspec/retry' require 'rspec/retry'
require 'knapsack'
require_relative 'knapsack_merger'
Knapsack::Adapters::RSpecAdapter.bind
# Requires supporting ruby files with custom matchers and macros, etc, # Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories. # in spec/support/ and its subdirectories.
......
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