From 0a1fccb2ed0e0479dbaa4c22726d5c7a440f014c Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 20:17:15 -0500 Subject: Try to use knapsack --- .gitlab-ci.yml | 87 ++++++++++++++++++++++++------------------------- Gemfile | 1 + Gemfile.lock | 5 +++ Rakefile | 3 ++ features/support/env.rb | 3 ++ spec/knapsack_merger.rb | 41 +++++++++++++++++++++++ spec/spec_helper.rb | 4 +++ 7 files changed, 99 insertions(+), 45 deletions(-) create mode 100644 spec/knapsack_merger.rb 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. -- cgit v1.2.1 From 28469ac712c37584a709fc33a8cfaa25a810711c Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 20:34:35 -0500 Subject: Touch reports --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a819610c41e..f2252e9018f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,6 +31,7 @@ before_script: RAILS_ENV: "test" SIMPLECOV: "true" script: + - touch knapsack_rspec_report.json - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} @@ -43,6 +44,7 @@ before_script: RAILS_ENV: "test" SIMPLECOV: "true" script: + - touch knapsack_cucumber_report.json - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} -- cgit v1.2.1 From 5ebc2a53ef536982f93fb7d32dd616a1162c07b3 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 20:41:17 -0500 Subject: Use build stage --- .gitlab-ci.yml | 55 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f2252e9018f..d7b99cf27bb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,8 @@ variables: MYSQL_ALLOW_EMPTY_PASSWORD: "1" # retry tests only in CI environment RSPEC_RETRY_RETRY_COUNT: "3" + RAILS_ENV: "test" + SIMPLECOV: "true" before_script: - source ./scripts/prepare_build.sh @@ -23,15 +25,11 @@ before_script: - touch log/application.log - touch log/test.log - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - - RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate + - bundle exec rake db:drop db:create db:schema:load db:migrate .rspec_tests: &rspec_tests stage: test - variables: - RAILS_ENV: "test" - SIMPLECOV: "true" script: - - touch knapsack_rspec_report.json - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} @@ -40,11 +38,7 @@ before_script: .spinach_tests: &spinach_tests stage: test - variables: - RAILS_ENV: "test" - SIMPLECOV: "true" script: - - touch knapsack_cucumber_report.json - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} @@ -52,9 +46,22 @@ before_script: - bundle exec rake knapsack:cucumber stages: +- build - test - notifications +prepare: + stage: build + script: + - bundle exec rake assets:precompile + - echo "{}" > knapsack_rspec_report.json + - echo "{}" > knapsack_cucumber_report.json + artifacts: + paths: + - assets/public/ + - knapsack_rspec_report.json + - knapsack_cucumber_report.json + spec 0 10: *rspec_tests spec 1 10: *rspec_tests spec 2 10: *rspec_tests @@ -80,7 +87,7 @@ spinach 9 10: *spinach_tests teaspoon: stage: test script: - - RAILS_ENV=test bundle exec teaspoon + - bundle exec teaspoon rubocop: stage: test @@ -117,7 +124,7 @@ bundler:audit: db-migrate-reset: stage: test script: - - RAILS_ENV=test bundle exec rake db:migrate:reset + - bundle exec rake db:migrate:reset # Ruby 2.2 jobs @@ -127,8 +134,8 @@ spec:feature:ruby22: only: - master script: - - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null - - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature + - bundle exec rake assets:precompile 2>/dev/null + - bundle exec rake spec:feature cache: key: "ruby22" paths: @@ -140,7 +147,7 @@ spec:api:ruby22: only: - master script: - - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api + - bundle exec rake spec:api cache: key: "ruby22" paths: @@ -152,7 +159,7 @@ spec:models:ruby22: only: - master script: - - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models + - bundle exec rake spec:models cache: key: "ruby22" paths: @@ -164,7 +171,7 @@ spec:lib:ruby22: only: - master script: - - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib + - bundle exec rake spec:lib cache: key: "ruby22" paths: @@ -176,7 +183,7 @@ spec:services:ruby22: only: - master script: - - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services + - bundle exec rake spec:services cache: key: "ruby22" paths: @@ -188,7 +195,7 @@ spec:other:ruby22: only: - master script: - - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other + - bundle exec rake spec:other cache: key: "ruby22" paths: @@ -200,8 +207,8 @@ spinach:project:half:ruby22: 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 + - bundle exec rake assets:precompile 2>/dev/null + - bundle exec rake spinach:project:half cache: key: "ruby22" paths: @@ -213,8 +220,8 @@ spinach:project:rest:ruby22: 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 + - bundle exec rake assets:precompile 2>/dev/null + - bundle exec rake spinach:project:rest cache: key: "ruby22" paths: @@ -226,8 +233,8 @@ spinach:other:ruby22: only: - master script: - - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null - - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other + - bundle exec rake assets:precompile 2>/dev/null + - bundle exec rake spinach:other cache: key: "ruby22" paths: -- cgit v1.2.1 From 71edcf59ee1f8bf7047ca293d5693642feeb3669 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 20:51:09 -0500 Subject: Improve .gitlab-ci.yml --- .gitlab-ci.yml | 122 +++++++++++++++++++++------------------------------------ 1 file changed, 44 insertions(+), 78 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d7b99cf27bb..dc81a698551 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,35 +15,13 @@ variables: RSPEC_RETRY_RETRY_COUNT: "3" RAILS_ENV: "test" SIMPLECOV: "true" + USE_DB: "true" before_script: - source ./scripts/prepare_build.sh - - ruby -v - - which ruby - - retry gem install bundler --no-ri --no-rdoc - cp config/gitlab.yml.example config/gitlab.yml - - touch log/application.log - - touch log/test.log - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - - bundle exec rake db:drop db:create db:schema:load db:migrate - -.rspec_tests: &rspec_tests - stage: test - script: - - 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 - -.spinach_tests: &spinach_tests - stage: test - script: - - 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 + - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' stages: - build @@ -52,6 +30,8 @@ stages: prepare: stage: build + variables: + USE_DB: "false" script: - bundle exec rake assets:precompile - echo "{}" > knapsack_rspec_report.json @@ -62,57 +42,48 @@ prepare: - knapsack_rspec_report.json - knapsack_cucumber_report.json -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: +.knapsack: &knapsack stage: test script: - - 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 + - JOB_NAME=( $CI_BUILD_NAME ) + - export CI_NODE_INDEX=${JOB_NAME[1]} + - export CI_NODE_TOTAL=${JOB_NAME[2]} + - bundle exec rake knapsack:${JOB_NAME[0]} + +.exec: &exec + stage: test + script: + - bundle exec $CI_BUILD_NAME + +rspec 0 10: *knapsack +rspec 1 10: *knapsack +rspec 2 10: *knapsack +rspec 3 10: *knapsack +rspec 4 10: *knapsack +rspec 5 10: *knapsack +rspec 6 10: *knapsack +rspec 7 10: *knapsack +rspec 8 10: *knapsack +rspec 9 10: *knapsack + +spinach 0 10: *knapsack +spinach 1 10: *knapsack +spinach 2 10: *knapsack +spinach 3 10: *knapsack +spinach 4 10: *knapsack +spinach 5 10: *knapsack +spinach 6 10: *knapsack +spinach 7 10: *knapsack +spinach 8 10: *knapsack +spinach 9 10: *knapsack + +teaspoon: *exec +rubocop: *exec +rake scss_lint: *exec +rake brakeman: *exec +rake flog: *exec +rake flay: *exec +rake db:migrate:reset: *exec bundler:audit: stage: test @@ -121,11 +92,6 @@ bundler:audit: script: - "bundle exec bundle-audit check --update --ignore OSVDB-115941" -db-migrate-reset: - stage: test - script: - - bundle exec rake db:migrate:reset - # Ruby 2.2 jobs spec:feature:ruby22: -- cgit v1.2.1 From e77c7116cc83775c0f20f0c106b92a56681208a2 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 20:52:19 -0500 Subject: Fix assets --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc81a698551..99ec069a533 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,7 @@ prepare: - echo "{}" > knapsack_cucumber_report.json artifacts: paths: - - assets/public/ + - public/assets/ - knapsack_rspec_report.json - knapsack_cucumber_report.json -- cgit v1.2.1 From f768d2ccd4506be132bf6903a22d5f5748dec24b Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 21:04:26 -0500 Subject: add bundler --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 99ec069a533..3896c37c335 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,7 @@ variables: before_script: - source ./scripts/prepare_build.sh - cp config/gitlab.yml.example config/gitlab.yml + - retry gem install bundler --no-ri --no-rdoc - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' -- cgit v1.2.1 From 1276bc6c069dca8410ec39ab880bf5a0b61eca9f Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 23:34:54 -0500 Subject: Test --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3896c37c335..29359e935e9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ variables: before_script: - source ./scripts/prepare_build.sh - cp config/gitlab.yml.example config/gitlab.yml - - retry gem install bundler --no-ri --no-rdoc + - retry gem install bundler - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' -- cgit v1.2.1 From 713bbed74e2d144d5e92969fd942621c166bf319 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 23:45:16 -0500 Subject: Test --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29359e935e9..20c86aa00fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,6 +29,11 @@ stages: - test - notifications +test-bundler: + stage: build + script: + - bundle exec bundle --version + prepare: stage: build variables: -- cgit v1.2.1 From 2494569d59a8f2fa4c61f62a06f0afe739635a6d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 21 May 2016 23:57:25 -0500 Subject: Test --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20c86aa00fa..50233a2d8ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ variables: before_script: - source ./scripts/prepare_build.sh - cp config/gitlab.yml.example config/gitlab.yml - - retry gem install bundler + #- retry gem install bundler - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' @@ -31,7 +31,10 @@ stages: test-bundler: stage: build + variables: + USE_DB: "false" script: + - retry gem install bundler - bundle exec bundle --version prepare: -- cgit v1.2.1 From 3e61c8feb448bf44b025e7e7b02935b73ea52765 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 00:31:38 -0500 Subject: Test --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 50233a2d8ac..2aaafdf0d92 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,7 @@ variables: before_script: - source ./scripts/prepare_build.sh - cp config/gitlab.yml.example config/gitlab.yml + - bundle --version #- retry gem install bundler - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' -- cgit v1.2.1 From 20dc6a708b4bad9507412e3a96c1c0bd25cf6fc4 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 19:27:34 -0500 Subject: Use knapsack directly --- .gitlab-ci.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2aaafdf0d92..837aed3ae0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,6 @@ before_script: - source ./scripts/prepare_build.sh - cp config/gitlab.yml.example config/gitlab.yml - bundle --version - #- retry gem install bundler - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' @@ -30,20 +29,12 @@ stages: - test - notifications -test-bundler: - stage: build - variables: - USE_DB: "false" - script: - - retry gem install bundler - - bundle exec bundle --version - prepare: stage: build variables: USE_DB: "false" script: - - bundle exec rake assets:precompile + #- bundle exec rake assets:precompile - echo "{}" > knapsack_rspec_report.json - echo "{}" > knapsack_cucumber_report.json artifacts: @@ -58,7 +49,8 @@ prepare: - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} - - bundle exec rake knapsack:${JOB_NAME[0]} + - gem install knapsack + - knapsack ${JOB_NAME[0]} .exec: &exec stage: test -- cgit v1.2.1 From 8d8d2759efaba594ec010a030bed94785016e274 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 20:23:40 -0500 Subject: WIP --- .gitlab-ci.yml | 2 +- features/support/env.rb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 837aed3ae0a..a5065693b5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ prepare: variables: USE_DB: "false" script: - #- bundle exec rake assets:precompile + - bundle exec rake assets:precompile - echo "{}" > knapsack_rspec_report.json - echo "{}" > knapsack_cucumber_report.json artifacts: diff --git a/features/support/env.rb b/features/support/env.rb index 6ebd012a40f..5a34159ec92 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -21,8 +21,6 @@ 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! -- cgit v1.2.1 From 77f8deec2ccbde0e502ecf35e1484f2c2e4e8a54 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 20:34:36 -0500 Subject: Use own version of knapsack which supports spinach tests --- Gemfile | 2 +- Gemfile.lock | 4 ++-- Rakefile | 2 +- features/support/env.rb | 4 +++- spec/spec_helper.rb | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index b9ae1aecb50..f4602008ecf 100644 --- a/Gemfile +++ b/Gemfile @@ -313,7 +313,7 @@ group :test do gem 'webmock', '~> 1.21.0' gem 'test_after_commit', '~> 0.4.2' gem 'sham_rack' - gem 'knapsack' + gem 'knapsack-gitlab' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 930a0f3f8d2..c04a3b1351d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -358,7 +358,7 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.10.0) - knapsack (1.9.0) + knapsack-gitlab (1.9.0) rake timecop (>= 0.1.0) launchy (2.4.3) @@ -878,7 +878,7 @@ DEPENDENCIES jquery-ui-rails (~> 5.0.0) jwt kaminari (~> 0.17.0) - knapsack + knapsack-gitlab letter_opener_web (~> 1.3.0) licensee (~> 8.0.0) loofah (~> 2.0.3) diff --git a/Rakefile b/Rakefile index 16261bf8ae2..bcfcba634d2 100755 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) -require 'knapsack' +require 'knapsack-gitlab' relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__) require relative_url_conf if File.exist?("#{relative_url_conf}.rb") diff --git a/features/support/env.rb b/features/support/env.rb index 5a34159ec92..b4b3e7359b4 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -11,12 +11,14 @@ ENV['RAILS_ENV'] = 'test' require './config/environment' require 'rspec/expectations' require 'sidekiq/testing/inline' -require 'knapsack' +require 'knapsack-gitlab' require_relative 'capybara' require_relative 'db_cleaner' require_relative 'rerun' +Knapsack::Adapters::SpinachAdapter.bind + %w(select2_helper test_env repo_helpers).each do |f| require Rails.root.join('spec', 'support', f) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 84b9ee75f6a..f6d8dd42249 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,7 +15,7 @@ require 'rspec/rails' require 'shoulda/matchers' require 'sidekiq/testing/inline' require 'rspec/retry' -require 'knapsack' +require 'knapsack-gitlab' require_relative 'knapsack_merger' Knapsack::Adapters::RSpecAdapter.bind -- cgit v1.2.1 From e275b6d2510fc94ea32e94acb44429cfcec28543 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 20:40:56 -0500 Subject: fix yml --- .gitlab-ci.yml | 2 +- Rakefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a5065693b5a..61136564623 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,7 @@ before_script: - cp config/gitlab.yml.example config/gitlab.yml - bundle --version - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" + - retry gem install knapsack-gitlab - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' stages: @@ -49,7 +50,6 @@ prepare: - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} - - gem install knapsack - knapsack ${JOB_NAME[0]} .exec: &exec diff --git a/Rakefile b/Rakefile index bcfcba634d2..16261bf8ae2 100755 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) -require 'knapsack-gitlab' +require 'knapsack' relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__) require relative_url_conf if File.exist?("#{relative_url_conf}.rb") -- cgit v1.2.1 From 9df2613a4e22741f8c0dfd6ff053adc7b0ff7a69 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 21:52:21 -0500 Subject: Fix knapsack usage --- .gitlab-ci.yml | 2 +- Gemfile.lock | 2 +- Rakefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61136564623..d573d80cdb8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ prepare: - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} - - knapsack ${JOB_NAME[0]} + - knapsack-gitlab ${JOB_NAME[0]} .exec: &exec stage: test diff --git a/Gemfile.lock b/Gemfile.lock index c04a3b1351d..0f75c231d4e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -358,7 +358,7 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.10.0) - knapsack-gitlab (1.9.0) + knapsack-gitlab (1.9.2) rake timecop (>= 0.1.0) launchy (2.4.3) diff --git a/Rakefile b/Rakefile index 16261bf8ae2..bcfcba634d2 100755 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) -require 'knapsack' +require 'knapsack-gitlab' relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__) require relative_url_conf if File.exist?("#{relative_url_conf}.rb") -- cgit v1.2.1 From fb404466b697ee9e0dc914710115c74718e614ab Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 22:03:19 -0500 Subject: Use spinach record --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d573d80cdb8..3e63c4a45d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,12 +37,12 @@ prepare: script: - bundle exec rake assets:precompile - echo "{}" > knapsack_rspec_report.json - - echo "{}" > knapsack_cucumber_report.json + - echo "{}" > knapsack_spinach_report.json artifacts: paths: - public/assets/ - knapsack_rspec_report.json - - knapsack_cucumber_report.json + - knapsack_spinach_report.json .knapsack: &knapsack stage: test -- cgit v1.2.1 From 2defc128bc46d327a19763ce72bdb90d26e27d8f Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 22:07:22 -0500 Subject: Use more concurrency --- .gitlab-ci.yml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3e63c4a45d6..8b5db89c94b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,16 +57,26 @@ prepare: script: - bundle exec $CI_BUILD_NAME -rspec 0 10: *knapsack -rspec 1 10: *knapsack -rspec 2 10: *knapsack -rspec 3 10: *knapsack -rspec 4 10: *knapsack -rspec 5 10: *knapsack -rspec 6 10: *knapsack -rspec 7 10: *knapsack -rspec 8 10: *knapsack -rspec 9 10: *knapsack +rspec 0 20: *knapsack +rspec 1 20: *knapsack +rspec 2 20: *knapsack +rspec 3 20: *knapsack +rspec 4 20: *knapsack +rspec 5 20: *knapsack +rspec 6 20: *knapsack +rspec 7 20: *knapsack +rspec 8 20: *knapsack +rspec 9 20: *knapsack +rspec 10 20: *knapsack +rspec 11 20: *knapsack +rspec 12 20: *knapsack +rspec 13 20: *knapsack +rspec 14 20: *knapsack +rspec 15 20: *knapsack +rspec 16 20: *knapsack +rspec 17 20: *knapsack +rspec 18 20: *knapsack +rspec 19 20: *knapsack spinach 0 10: *knapsack spinach 1 10: *knapsack -- cgit v1.2.1 From 432b96640fb2955d118f43ae2463347745cb8386 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 22 May 2016 22:39:21 -0500 Subject: More spinaches --- .gitlab-ci.yml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b5db89c94b..d0bce69cf5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,16 +78,26 @@ rspec 17 20: *knapsack rspec 18 20: *knapsack rspec 19 20: *knapsack -spinach 0 10: *knapsack -spinach 1 10: *knapsack -spinach 2 10: *knapsack -spinach 3 10: *knapsack -spinach 4 10: *knapsack -spinach 5 10: *knapsack -spinach 6 10: *knapsack -spinach 7 10: *knapsack -spinach 8 10: *knapsack -spinach 9 10: *knapsack +spinach 0 20: *knapsack +spinach 1 20: *knapsack +spinach 2 20: *knapsack +spinach 3 20: *knapsack +spinach 4 20: *knapsack +spinach 5 20: *knapsack +spinach 6 20: *knapsack +spinach 7 20: *knapsack +spinach 8 20: *knapsack +spinach 9 20: *knapsack +spinach 10 20: *knapsack +spinach 11 20: *knapsack +spinach 12 20: *knapsack +spinach 13 20: *knapsack +spinach 14 20: *knapsack +spinach 15 20: *knapsack +spinach 16 20: *knapsack +spinach 17 20: *knapsack +spinach 18 20: *knapsack +spinach 19 20: *knapsack teaspoon: *exec rubocop: *exec -- cgit v1.2.1 From 95c3a927b319c8495c28e6431152e5ca0c5df30b Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 17:15:00 +0200 Subject: Use knapsack 1.11.0 --- .gitlab-ci.yml | 21 +++++++++++++-------- Gemfile | 2 +- Gemfile.lock | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0bce69cf5a..cf85820abdf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,27 +22,27 @@ before_script: - cp config/gitlab.yml.example config/gitlab.yml - bundle --version - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - - retry gem install knapsack-gitlab + - retry gem install knapsack - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' stages: -- build +- prepare - test - notifications prepare: - stage: build + stage: prepare variables: USE_DB: "false" script: - bundle exec rake assets:precompile - - echo "{}" > knapsack_rspec_report.json - - echo "{}" > knapsack_spinach_report.json + - mkdir knapsack/ + - echo "{}" > knapsack/rspec_report.json + - echo "{}" > knapsack/spinach_report.json artifacts: paths: - public/assets/ - - knapsack_rspec_report.json - - knapsack_spinach_report.json + - knapsack/ .knapsack: &knapsack stage: test @@ -50,7 +50,12 @@ prepare: - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} - - knapsack-gitlab ${JOB_NAME[0]} + - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json + - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH} + - knapsack ${JOB_NAME[0]} + artifacts: + paths: + - knapsack/ .exec: &exec stage: test diff --git a/Gemfile b/Gemfile index f4602008ecf..b9ae1aecb50 100644 --- a/Gemfile +++ b/Gemfile @@ -313,7 +313,7 @@ group :test do gem 'webmock', '~> 1.21.0' gem 'test_after_commit', '~> 0.4.2' gem 'sham_rack' - gem 'knapsack-gitlab' + gem 'knapsack' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 0f75c231d4e..8bfdf8ea9bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -358,7 +358,7 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.10.0) - knapsack-gitlab (1.9.2) + knapsack (1.11.0) rake timecop (>= 0.1.0) launchy (2.4.3) @@ -878,7 +878,7 @@ DEPENDENCIES jquery-ui-rails (~> 5.0.0) jwt kaminari (~> 0.17.0) - knapsack-gitlab + knapsack letter_opener_web (~> 1.3.0) licensee (~> 8.0.0) loofah (~> 2.0.3) -- cgit v1.2.1 From 792670f4ce467f278b5cdfd609a221bbbe26187d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 17:35:00 +0200 Subject: Merge knapsack reports and upload them to external server --- .gitlab-ci.yml | 19 ++++++++++++++++++- scripts/merge-reports | 29 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 scripts/merge-reports diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf85820abdf..6fc410b4b51 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,6 +28,7 @@ before_script: stages: - prepare - test +- post-test - notifications prepare: @@ -36,7 +37,7 @@ prepare: USE_DB: "false" script: - bundle exec rake assets:precompile - - mkdir knapsack/ + - mkdir -p knapsack/ - echo "{}" > knapsack/rspec_report.json - echo "{}" > knapsack/spinach_report.json artifacts: @@ -57,6 +58,22 @@ prepare: paths: - knapsack/ +post-tests: + stage: post-test + variables: + USE_DB: "false" + script: + - scripts/merge-reports knapsack/rspec_report.json knapsack/rspec_node_*.json + - scripts/merge-reports knapsack/spinach_report.json knapsack/spinach_node_*.json + - rm -f knapsack/*_node_*.json + cache: + key: "knapsack" + paths: + - knapsack/ + artifacts: + paths: + - knapsack/ + .exec: &exec stage: test script: diff --git a/scripts/merge-reports b/scripts/merge-reports new file mode 100755 index 00000000000..f7b574001ac --- /dev/null +++ b/scripts/merge-reports @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +require 'json' +require 'yaml' + +main_report_file = ARGV.shift +unless main_report_file + puts 'usage: merge_reports [extra reports...]' + exit 1 +end + +puts "Loading #{main_report_file}..." +main_report = JSON.parse(File.read(main_report_file)) +new_report = main_report.dup + +ARGV.each do |report_file| + report = JSON.parse(File.read(report_file)) + + # Remove existing values + updates = report.delete_if do |key, value| + main_report[key] && main_report[key] == value + end + new_report.merge!(updates) + + puts "Merged #{report_file} adding #{updates.size} results." +end + +File.write(main_report_file, JSON.pretty_generate(new_report)) +puts "Saved #{main_report_file}." -- cgit v1.2.1 From 86498d4d99472edcb70ab1631f463133995a8cbf Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 17:39:53 +0200 Subject: Use knapsack everywhere --- Rakefile | 2 +- features/support/env.rb | 2 +- spec/spec_helper.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index bcfcba634d2..16261bf8ae2 100755 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) -require 'knapsack-gitlab' +require 'knapsack' relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__) require relative_url_conf if File.exist?("#{relative_url_conf}.rb") diff --git a/features/support/env.rb b/features/support/env.rb index b4b3e7359b4..4552db8ad77 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -11,7 +11,7 @@ ENV['RAILS_ENV'] = 'test' require './config/environment' require 'rspec/expectations' require 'sidekiq/testing/inline' -require 'knapsack-gitlab' +require 'knapsack' require_relative 'capybara' require_relative 'db_cleaner' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f6d8dd42249..84b9ee75f6a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,7 +15,7 @@ require 'rspec/rails' require 'shoulda/matchers' require 'sidekiq/testing/inline' require 'rspec/retry' -require 'knapsack-gitlab' +require 'knapsack' require_relative 'knapsack_merger' Knapsack::Adapters::RSpecAdapter.bind -- cgit v1.2.1 From d8e90d03b7b8dddeca54245b6f2662aa39b5cda8 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 21:53:04 +0200 Subject: Generate knapsack reports --- .gitlab-ci.yml | 1 + app/controllers/projects/artifacts_controller.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6fc410b4b51..9af4b5fc7ae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,6 +52,7 @@ prepare: - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json + - export KNAPSACK_GENERATE_REPORT=true - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH} - knapsack ${JOB_NAME[0]} artifacts: diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index cfea1266516..832d7deb57d 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -37,7 +37,7 @@ class Projects::ArtifactsController < Projects::ApplicationController private def build - @build ||= project.builds.unscoped.find_by!(id: params[:build_id]) + @build ||= project.builds.find_by!(id: params[:build_id]) end def artifacts_file -- cgit v1.2.1 From ea731cac08efb8b2a4edbc7c76523ae5a5b17070 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 22:54:25 +0200 Subject: Preserve knapsack state --- .gitlab-ci.yml | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9af4b5fc7ae..e3319843656 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ before_script: - source ./scripts/prepare_build.sh - cp config/gitlab.yml.example config/gitlab.yml - bundle --version - - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" + - '[ "$USE_BUNDLE_INSTALL" != "true" ] || retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"' - retry gem install knapsack - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' @@ -31,18 +31,26 @@ stages: - post-test - notifications -prepare: +precompile: stage: prepare variables: USE_DB: "false" script: - bundle exec rake assets:precompile - - mkdir -p knapsack/ - - echo "{}" > knapsack/rspec_report.json - - echo "{}" > knapsack/spinach_report.json artifacts: paths: - public/assets/ + +.knapsack_state: &knapsack_state + variables: + USE_DB: "false" + USE_BUNDLE_INSTALL: "false" + cache: + key: "knapsack" + paths: + - knapsack/ + artifacts: + paths: - knapsack/ .knapsack: &knapsack @@ -59,21 +67,21 @@ prepare: paths: - knapsack/ -post-tests: +knapsack: + <<: *knapsack_state + stage: prepare + script: + - mkdir -p knapsack/ + - '[[ -f knapsack/rspec_report.json ]] || echo "{}" > knapsack/rspec_report.json' + - '[[ -f knapsack/spinach_report.json ]] || echo "{}" > knapsack/spinach_report.json' + +update-knapsack: + <<: *knapsack_state stage: post-test - variables: - USE_DB: "false" script: - scripts/merge-reports knapsack/rspec_report.json knapsack/rspec_node_*.json - scripts/merge-reports knapsack/spinach_report.json knapsack/spinach_node_*.json - rm -f knapsack/*_node_*.json - cache: - key: "knapsack" - paths: - - knapsack/ - artifacts: - paths: - - knapsack/ .exec: &exec stage: test -- cgit v1.2.1 From 9a201adddf0f5bdf10ff5cda65f6d58ef904df4b Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 23:03:58 +0200 Subject: USE_BUNDLE_INSTALL --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e3319843656..dc04f3f298f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,7 @@ variables: RAILS_ENV: "test" SIMPLECOV: "true" USE_DB: "true" + USE_BUNDLE_INSTALL: "true" before_script: - source ./scripts/prepare_build.sh -- cgit v1.2.1 From 82f7831d734805188c84e687aced459564549325 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 3 Jun 2016 23:05:15 +0200 Subject: Don't start services if they are not needed --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc04f3f298f..9774602cbdc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,7 @@ stages: precompile: stage: prepare + services: [] variables: USE_DB: "false" script: @@ -43,6 +44,7 @@ precompile: - public/assets/ .knapsack_state: &knapsack_state + services: [] variables: USE_DB: "false" USE_BUNDLE_INSTALL: "false" -- cgit v1.2.1 -- cgit v1.2.1 From e6567bc13c3c92ed581e916306ecfb758e311f19 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sat, 4 Jun 2016 00:24:33 +0200 Subject: Use gitlab-build-images for precache some of the dependencies --- .gitlab-ci.yml | 34 ++++++++++++---------------------- scripts/prepare_build.sh | 14 -------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9774602cbdc..85bf783ace6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ -image: "ruby:2.1" +image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.1 services: - mysql:latest - - redis:latest + - redis:alpine cache: key: "ruby21" @@ -112,26 +112,16 @@ rspec 17 20: *knapsack rspec 18 20: *knapsack rspec 19 20: *knapsack -spinach 0 20: *knapsack -spinach 1 20: *knapsack -spinach 2 20: *knapsack -spinach 3 20: *knapsack -spinach 4 20: *knapsack -spinach 5 20: *knapsack -spinach 6 20: *knapsack -spinach 7 20: *knapsack -spinach 8 20: *knapsack -spinach 9 20: *knapsack -spinach 10 20: *knapsack -spinach 11 20: *knapsack -spinach 12 20: *knapsack -spinach 13 20: *knapsack -spinach 14 20: *knapsack -spinach 15 20: *knapsack -spinach 16 20: *knapsack -spinach 17 20: *knapsack -spinach 18 20: *knapsack -spinach 19 20: *knapsack +spinach 0 10: *knapsack +spinach 1 10: *knapsack +spinach 2 10: *knapsack +spinach 3 10: *knapsack +spinach 4 10: *knapsack +spinach 5 10: *knapsack +spinach 6 10: *knapsack +spinach 7 10: *knapsack +spinach 8 10: *knapsack +spinach 9 10: *knapsack teaspoon: *exec rubocop: *exec diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index 247383aa46c..9540d7d128f 100755 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -12,20 +12,6 @@ retry() { } if [ -f /.dockerenv ] || [ -f ./dockerinit ]; then - mkdir -p vendor - - # Install phantomjs package - pushd vendor - if [ ! -e phantomjs_1.9.8-0jessie_amd64.deb ]; then - wget -q https://gitlab.com/axil/phantomjs-debian/raw/master/phantomjs_1.9.8-0jessie_amd64.deb - fi - dpkg -i phantomjs_1.9.8-0jessie_amd64.deb - popd - - # Try to install packages - retry 'apt-get update -yqqq; apt-get -o dir::cache::archives="vendor/apt" install -y -qq --force-yes \ - libicu-dev libkrb5-dev cmake nodejs postgresql-client mysql-client unzip' - cp config/database.yml.mysql config/database.yml sed -i 's/username:.*/username: root/g' config/database.yml sed -i 's/password:.*/password:/g' config/database.yml -- cgit v1.2.1 From f5f65d69138f6c348a69a486f38ef5dc693fe7d2 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 6 Jun 2016 10:55:13 +0200 Subject: Refactor all testing suites --- .gitlab-ci.yml | 204 +++++++++++++++++++-------------------------------------- 1 file changed, 66 insertions(+), 138 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 85bf783ace6..d8d8557a465 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,16 +32,7 @@ stages: - post-test - notifications -precompile: - stage: prepare - services: [] - variables: - USE_DB: "false" - script: - - bundle exec rake assets:precompile - artifacts: - paths: - - public/assets/ +# Prepare and merge knapsack tests .knapsack_state: &knapsack_state services: [] @@ -56,20 +47,6 @@ precompile: paths: - knapsack/ -.knapsack: &knapsack - stage: test - script: - - JOB_NAME=( $CI_BUILD_NAME ) - - export CI_NODE_INDEX=${JOB_NAME[1]} - - export CI_NODE_TOTAL=${JOB_NAME[2]} - - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json - - export KNAPSACK_GENERATE_REPORT=true - - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH} - - knapsack ${JOB_NAME[0]} - artifacts: - paths: - - knapsack/ - knapsack: <<: *knapsack_state stage: prepare @@ -86,10 +63,22 @@ update-knapsack: - scripts/merge-reports knapsack/spinach_report.json knapsack/spinach_node_*.json - rm -f knapsack/*_node_*.json -.exec: &exec +# Execute all testing suites + +.knapsack: &knapsack stage: test script: - - bundle exec $CI_BUILD_NAME + - bundle exec rake assets:precompile 2>/dev/null + - JOB_NAME=( $CI_BUILD_NAME ) + - export CI_NODE_INDEX=${JOB_NAME[1]} + - export CI_NODE_TOTAL=${JOB_NAME[2]} + - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json + - export KNAPSACK_GENERATE_REPORT=true + - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH} + - knapsack ${JOB_NAME[0]} + artifacts: + paths: + - knapsack/ rspec 0 20: *knapsack rspec 1 20: *knapsack @@ -123,137 +112,76 @@ spinach 7 10: *knapsack spinach 8 10: *knapsack spinach 9 10: *knapsack -teaspoon: *exec -rubocop: *exec -rake scss_lint: *exec -rake brakeman: *exec -rake flog: *exec -rake flay: *exec -rake db:migrate:reset: *exec +# Execute all testing suites against Ruby 2.2 -bundler:audit: - stage: test +.knapsack-ruby22: &knapsack-ruby22 + <<: *knapsack + image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.2 only: - master - script: - - "bundle exec bundle-audit check --update --ignore OSVDB-115941" - -# Ruby 2.2 jobs - -spec:feature:ruby22: - stage: test - image: ruby:2.2 - only: - - master - script: - - bundle exec rake assets:precompile 2>/dev/null - - bundle exec rake spec:feature - cache: - key: "ruby22" - paths: - - vendor - -spec:api:ruby22: - stage: test - image: ruby:2.2 - only: - - master - script: - - bundle exec rake spec:api cache: key: "ruby22" paths: - vendor -spec:models:ruby22: - stage: test - image: ruby:2.2 - only: - - master - script: - - bundle exec rake spec:models - cache: - key: "ruby22" - paths: - - vendor - -spec:lib:ruby22: - stage: test - image: ruby:2.2 - only: - - master - script: - - bundle exec rake spec:lib - cache: - key: "ruby22" - paths: - - vendor +rspec 0 20 ruby22: *knapsack-ruby22 +rspec 1 20 ruby22: *knapsack-ruby22 +rspec 2 20 ruby22: *knapsack-ruby22 +rspec 3 20 ruby22: *knapsack-ruby22 +rspec 4 20 ruby22: *knapsack-ruby22 +rspec 5 20 ruby22: *knapsack-ruby22 +rspec 6 20 ruby22: *knapsack-ruby22 +rspec 7 20 ruby22: *knapsack-ruby22 +rspec 8 20 ruby22: *knapsack-ruby22 +rspec 9 20 ruby22: *knapsack-ruby22 +rspec 10 20 ruby22: *knapsack-ruby22 +rspec 11 20 ruby22: *knapsack-ruby22 +rspec 12 20 ruby22: *knapsack-ruby22 +rspec 13 20 ruby22: *knapsack-ruby22 +rspec 14 20 ruby22: *knapsack-ruby22 +rspec 15 20 ruby22: *knapsack-ruby22 +rspec 16 20 ruby22: *knapsack-ruby22 +rspec 17 20 ruby22: *knapsack-ruby22 +rspec 18 20 ruby22: *knapsack-ruby22 +rspec 19 20 ruby22: *knapsack-ruby22 + +spinach 0 10 ruby22: *knapsack-ruby22 +spinach 1 10 ruby22: *knapsack-ruby22 +spinach 2 10 ruby22: *knapsack-ruby22 +spinach 3 10 ruby22: *knapsack-ruby22 +spinach 4 10 ruby22: *knapsack-ruby22 +spinach 5 10 ruby22: *knapsack-ruby22 +spinach 6 10 ruby22: *knapsack-ruby22 +spinach 7 10 ruby22: *knapsack-ruby22 +spinach 8 10 ruby22: *knapsack-ruby22 +spinach 9 10 ruby22: *knapsack-ruby22 + +# Other generic tests -spec:services:ruby22: - stage: test - image: ruby:2.2 - only: - - master - script: - - bundle exec rake spec:services - cache: - key: "ruby22" - paths: - - vendor - -spec:other:ruby22: +.exec: &exec stage: test - image: ruby:2.2 - only: - - master script: - - bundle exec rake spec:other - cache: - key: "ruby22" - paths: - - vendor + - bundle exec $CI_BUILD_NAME -spinach:project:half:ruby22: - stage: test - image: ruby:2.2 - only: - - master - script: - - bundle exec rake assets:precompile 2>/dev/null - - bundle exec rake spinach:project:half - cache: - key: "ruby22" - paths: - - vendor +teaspoon: *exec +rubocop: *exec +rake scss_lint: *exec +rake brakeman: *exec +rake flog: *exec +rake flay: *exec +rake db:migrate:reset: *exec -spinach:project:rest:ruby22: +bundler:audit: stage: test - image: ruby:2.2 only: - - master + - master script: - - bundle exec rake assets:precompile 2>/dev/null - - bundle exec rake spinach:project:rest - cache: - key: "ruby22" - paths: - - vendor + - "bundle exec bundle-audit check --update --ignore OSVDB-115941" -spinach:other:ruby22: - stage: test - image: ruby:2.2 - only: - - master - script: - - bundle exec rake assets:precompile 2>/dev/null - - bundle exec rake spinach:other - cache: - key: "ruby22" - paths: - - vendor +# Notify slack in the end notify:slack: - stage: notifications + stage: post-test script: - ./scripts/notify_slack.sh "#builds" "Build on \`$CI_BUILD_REF_NAME\` failed! Commit \`$(git log -1 --oneline)\` See " when: on_failure -- cgit v1.2.1 From 72947148e54cda37723adad4cad73311e0c926d7 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 6 Jun 2016 12:17:37 +0200 Subject: Don't install knapsack --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d8d8557a465..ac522160d69 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,7 +23,6 @@ before_script: - cp config/gitlab.yml.example config/gitlab.yml - bundle --version - '[ "$USE_BUNDLE_INSTALL" != "true" ] || retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"' - - retry gem install knapsack - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' stages: -- cgit v1.2.1 From aebfdcd8513b5513f8631f7e67d7f2900f093278 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 6 Jun 2016 20:19:39 +0200 Subject: Install bundler --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac522160d69..7bece719b00 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -74,6 +74,7 @@ update-knapsack: - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json - export KNAPSACK_GENERATE_REPORT=true - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH} + - bundle exec gem install bundler - knapsack ${JOB_NAME[0]} artifacts: paths: -- cgit v1.2.1 From b09a329fd8b314fc48114ce15d451a18d3fcb70f Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 10:31:02 +0200 Subject: Use ruby:2.1 and ruby:2.2 images --- .gitlab-ci.yml | 4 ++-- scripts/prepare_build.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 172fbaf52b6..23bc2c2f837 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.1 +image: "ruby:2.1" services: - mysql:latest @@ -116,7 +116,7 @@ spinach 9 10: *knapsack .knapsack-ruby22: &knapsack-ruby22 <<: *knapsack - image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.2 + image: "ruby:2.2" only: - master cache: diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index 9540d7d128f..247383aa46c 100755 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -12,6 +12,20 @@ retry() { } if [ -f /.dockerenv ] || [ -f ./dockerinit ]; then + mkdir -p vendor + + # Install phantomjs package + pushd vendor + if [ ! -e phantomjs_1.9.8-0jessie_amd64.deb ]; then + wget -q https://gitlab.com/axil/phantomjs-debian/raw/master/phantomjs_1.9.8-0jessie_amd64.deb + fi + dpkg -i phantomjs_1.9.8-0jessie_amd64.deb + popd + + # Try to install packages + retry 'apt-get update -yqqq; apt-get -o dir::cache::archives="vendor/apt" install -y -qq --force-yes \ + libicu-dev libkrb5-dev cmake nodejs postgresql-client mysql-client unzip' + cp config/database.yml.mysql config/database.yml sed -i 's/username:.*/username: root/g' config/database.yml sed -i 's/password:.*/password:/g' config/database.yml -- cgit v1.2.1 From 0f97357145fa951e206536f11ca1d52efabe4675 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 10:45:02 +0200 Subject: Install knapsack --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 23bc2c2f837..53184f8f906 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,7 @@ before_script: - cp config/gitlab.yml.example config/gitlab.yml - bundle --version - '[ "$USE_BUNDLE_INSTALL" != "true" ] || retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"' + - retry gem install knapsack - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate' stages: @@ -74,7 +75,6 @@ update-knapsack: - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json - export KNAPSACK_GENERATE_REPORT=true - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH} - - bundle exec gem install bundler - knapsack ${JOB_NAME[0]} artifacts: paths: -- cgit v1.2.1 From 498f8d13d003b1d9a50babfd45911ef55e905ba5 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 11:23:53 +0200 Subject: Fix license_finder --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 53184f8f906..476815de71b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -170,7 +170,7 @@ rake brakeman: *exec rake flog: *exec rake flay: *exec rake db:migrate:reset: *exec -license-finder: *exec +license_finder: *exec bundler:audit: stage: test -- cgit v1.2.1 From 03a7569ea6952b47c3f25294e94cb3abf1877d5d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 13:06:24 +0200 Subject: Rerun failed spinach tests --- .gitlab-ci.yml | 164 +++++++++++++++++++++++++++-------------------- scripts/prepare_build.sh | 10 ++- 2 files changed, 101 insertions(+), 73 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 476815de71b..095c9005d1f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ stages: - knapsack/ knapsack: - <<: *knapsack_state + <<: *rspec-knapsack_state stage: prepare script: - mkdir -p knapsack/ @@ -56,7 +56,7 @@ knapsack: - '[[ -f knapsack/spinach_report.json ]] || echo "{}" > knapsack/spinach_report.json' update-knapsack: - <<: *knapsack_state + <<: *rspec-knapsack_state stage: post-test script: - scripts/merge-reports knapsack/rspec_report.json knapsack/rspec_node_*.json @@ -65,57 +65,73 @@ update-knapsack: # Execute all testing suites -.knapsack: &knapsack +.rspec-knapsack: &knapsack stage: test script: - bundle exec rake assets:precompile 2>/dev/null - JOB_NAME=( $CI_BUILD_NAME ) - export CI_NODE_INDEX=${JOB_NAME[1]} - export CI_NODE_TOTAL=${JOB_NAME[2]} - - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json + - export KNAPSACK_REPORT_PATH=knapsack/rspec_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json - export KNAPSACK_GENERATE_REPORT=true - - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH} - - knapsack ${JOB_NAME[0]} + - cp knapsack/rspec_report.json ${KNAPSACK_REPORT_PATH} + - knapsack rspec artifacts: paths: - knapsack/ -rspec 0 20: *knapsack -rspec 1 20: *knapsack -rspec 2 20: *knapsack -rspec 3 20: *knapsack -rspec 4 20: *knapsack -rspec 5 20: *knapsack -rspec 6 20: *knapsack -rspec 7 20: *knapsack -rspec 8 20: *knapsack -rspec 9 20: *knapsack -rspec 10 20: *knapsack -rspec 11 20: *knapsack -rspec 12 20: *knapsack -rspec 13 20: *knapsack -rspec 14 20: *knapsack -rspec 15 20: *knapsack -rspec 16 20: *knapsack -rspec 17 20: *knapsack -rspec 18 20: *knapsack -rspec 19 20: *knapsack - -spinach 0 10: *knapsack -spinach 1 10: *knapsack -spinach 2 10: *knapsack -spinach 3 10: *knapsack -spinach 4 10: *knapsack -spinach 5 10: *knapsack -spinach 6 10: *knapsack -spinach 7 10: *knapsack -spinach 8 10: *knapsack -spinach 9 10: *knapsack +.spinach-knapsack: &knapsack + stage: test + script: + - bundle exec rake assets:precompile 2>/dev/null + - JOB_NAME=( $CI_BUILD_NAME ) + - export CI_NODE_INDEX=${JOB_NAME[1]} + - export CI_NODE_TOTAL=${JOB_NAME[2]} + - export KNAPSACK_REPORT_PATH=knapsack/spinach_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json + - export KNAPSACK_GENERATE_REPORT=true + - cp knapsack/spinach_report.json ${KNAPSACK_REPORT_PATH} + - knapsack spinach[-r rerun] + # retry failed tests 3 times + - retry '[ ! -e tmp/spinach-rerun.txt ] || bin/spinach -r rerun $(cat tmp/spinach-rerun.txt)' + artifacts: + paths: + - knapsack/ + +rspec 0 20: *rspec-knapsack +rspec 1 20: *rspec-knapsack +rspec 2 20: *rspec-knapsack +rspec 3 20: *rspec-knapsack +rspec 4 20: *rspec-knapsack +rspec 5 20: *rspec-knapsack +rspec 6 20: *rspec-knapsack +rspec 7 20: *rspec-knapsack +rspec 8 20: *rspec-knapsack +rspec 9 20: *rspec-knapsack +rspec 10 20: *rspec-knapsack +rspec 11 20: *rspec-knapsack +rspec 12 20: *rspec-knapsack +rspec 13 20: *rspec-knapsack +rspec 14 20: *rspec-knapsack +rspec 15 20: *rspec-knapsack +rspec 16 20: *rspec-knapsack +rspec 17 20: *rspec-knapsack +rspec 18 20: *rspec-knapsack +rspec 19 20: *rspec-knapsack + +spinach 0 10: *spinach-knapsack +spinach 1 10: *spinach-knapsack +spinach 2 10: *spinach-knapsack +spinach 3 10: *spinach-knapsack +spinach 4 10: *spinach-knapsack +spinach 5 10: *spinach-knapsack +spinach 6 10: *spinach-knapsack +spinach 7 10: *spinach-knapsack +spinach 8 10: *spinach-knapsack +spinach 9 10: *spinach-knapsack # Execute all testing suites against Ruby 2.2 -.knapsack-ruby22: &knapsack-ruby22 - <<: *knapsack +.ruby-22: &ruby22 image: "ruby:2.2" only: - master @@ -124,37 +140,45 @@ spinach 9 10: *knapsack paths: - vendor -rspec 0 20 ruby22: *knapsack-ruby22 -rspec 1 20 ruby22: *knapsack-ruby22 -rspec 2 20 ruby22: *knapsack-ruby22 -rspec 3 20 ruby22: *knapsack-ruby22 -rspec 4 20 ruby22: *knapsack-ruby22 -rspec 5 20 ruby22: *knapsack-ruby22 -rspec 6 20 ruby22: *knapsack-ruby22 -rspec 7 20 ruby22: *knapsack-ruby22 -rspec 8 20 ruby22: *knapsack-ruby22 -rspec 9 20 ruby22: *knapsack-ruby22 -rspec 10 20 ruby22: *knapsack-ruby22 -rspec 11 20 ruby22: *knapsack-ruby22 -rspec 12 20 ruby22: *knapsack-ruby22 -rspec 13 20 ruby22: *knapsack-ruby22 -rspec 14 20 ruby22: *knapsack-ruby22 -rspec 15 20 ruby22: *knapsack-ruby22 -rspec 16 20 ruby22: *knapsack-ruby22 -rspec 17 20 ruby22: *knapsack-ruby22 -rspec 18 20 ruby22: *knapsack-ruby22 -rspec 19 20 ruby22: *knapsack-ruby22 - -spinach 0 10 ruby22: *knapsack-ruby22 -spinach 1 10 ruby22: *knapsack-ruby22 -spinach 2 10 ruby22: *knapsack-ruby22 -spinach 3 10 ruby22: *knapsack-ruby22 -spinach 4 10 ruby22: *knapsack-ruby22 -spinach 5 10 ruby22: *knapsack-ruby22 -spinach 6 10 ruby22: *knapsack-ruby22 -spinach 7 10 ruby22: *knapsack-ruby22 -spinach 8 10 ruby22: *knapsack-ruby22 -spinach 9 10 ruby22: *knapsack-ruby22 +.rspec-knapsack-ruby22: &rspec-knapsack-ruby22 + <<: *rspec-knapsack + <<: *ruby-22 + +.spinach-knapsack-ruby22: &spinach-knapsack-ruby22 + <<: *rspec-knapsack + <<: *ruby-22 + +rspec 0 20 ruby22: *rspec-knapsack-ruby22 +rspec 1 20 ruby22: *rspec-knapsack-ruby22 +rspec 2 20 ruby22: *rspec-knapsack-ruby22 +rspec 3 20 ruby22: *rspec-knapsack-ruby22 +rspec 4 20 ruby22: *rspec-knapsack-ruby22 +rspec 5 20 ruby22: *rspec-knapsack-ruby22 +rspec 6 20 ruby22: *rspec-knapsack-ruby22 +rspec 7 20 ruby22: *rspec-knapsack-ruby22 +rspec 8 20 ruby22: *rspec-knapsack-ruby22 +rspec 9 20 ruby22: *rspec-knapsack-ruby22 +rspec 10 20 ruby22: *rspec-knapsack-ruby22 +rspec 11 20 ruby22: *rspec-knapsack-ruby22 +rspec 12 20 ruby22: *rspec-knapsack-ruby22 +rspec 13 20 ruby22: *rspec-knapsack-ruby22 +rspec 14 20 ruby22: *rspec-knapsack-ruby22 +rspec 15 20 ruby22: *rspec-knapsack-ruby22 +rspec 16 20 ruby22: *rspec-knapsack-ruby22 +rspec 17 20 ruby22: *rspec-knapsack-ruby22 +rspec 18 20 ruby22: *rspec-knapsack-ruby22 +rspec 19 20 ruby22: *rspec-knapsack-ruby22 + +spinach 0 10 ruby22: *spinach-knapsack-ruby22 +spinach 1 10 ruby22: *spinach-knapsack-ruby22 +spinach 2 10 ruby22: *spinach-knapsack-ruby22 +spinach 3 10 ruby22: *spinach-knapsack-ruby22 +spinach 4 10 ruby22: *spinach-knapsack-ruby22 +spinach 5 10 ruby22: *spinach-knapsack-ruby22 +spinach 6 10 ruby22: *spinach-knapsack-ruby22 +spinach 7 10 ruby22: *spinach-knapsack-ruby22 +spinach 8 10 ruby22: *spinach-knapsack-ruby22 +spinach 9 10 ruby22: *spinach-knapsack-ruby22 # Other generic tests diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index 247383aa46c..d6fb1a34e8c 100755 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -1,12 +1,16 @@ #!/bin/bash retry() { - for i in $(seq 1 3); do + if eval "$@"; then + return 0 + fi + + for i in 2 1; do + sleep 3s + echo "Retrying $i..." if eval "$@"; then return 0 fi - sleep 3s - echo "Retrying..." done return 1 } -- cgit v1.2.1 From 9b76bb30e834d2fc78f628cd16b00f2e77f305fe Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 13:10:40 +0200 Subject: Fix .gitlab-ci.yml --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 095c9005d1f..764b82889ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ stages: # Prepare and merge knapsack tests -.knapsack_state: &knapsack_state +.knapsack-state: &knapsack-state services: [] variables: USE_DB: "false" @@ -48,7 +48,7 @@ stages: - knapsack/ knapsack: - <<: *rspec-knapsack_state + <<: *knapsack-state stage: prepare script: - mkdir -p knapsack/ @@ -56,7 +56,7 @@ knapsack: - '[[ -f knapsack/spinach_report.json ]] || echo "{}" > knapsack/spinach_report.json' update-knapsack: - <<: *rspec-knapsack_state + <<: *knapsack-state stage: post-test script: - scripts/merge-reports knapsack/rspec_report.json knapsack/rspec_node_*.json @@ -65,7 +65,7 @@ update-knapsack: # Execute all testing suites -.rspec-knapsack: &knapsack +.rspec-knapsack: &rspec-knapsack stage: test script: - bundle exec rake assets:precompile 2>/dev/null @@ -80,7 +80,7 @@ update-knapsack: paths: - knapsack/ -.spinach-knapsack: &knapsack +.spinach-knapsack: &spinach-knapsack stage: test script: - bundle exec rake assets:precompile 2>/dev/null @@ -131,7 +131,7 @@ spinach 9 10: *spinach-knapsack # Execute all testing suites against Ruby 2.2 -.ruby-22: &ruby22 +.ruby-22: &ruby-22 image: "ruby:2.2" only: - master -- cgit v1.2.1 From 59376bb3604924fd9e91311eab24ab6454363cfa Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 14:35:17 +0200 Subject: Fix knapsack spinach execution --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 764b82889ef..d098bf73ff8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -90,7 +90,7 @@ update-knapsack: - export KNAPSACK_REPORT_PATH=knapsack/spinach_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json - export KNAPSACK_GENERATE_REPORT=true - cp knapsack/spinach_report.json ${KNAPSACK_REPORT_PATH} - - knapsack spinach[-r rerun] + - knapsack spinach "-r rerun" # retry failed tests 3 times - retry '[ ! -e tmp/spinach-rerun.txt ] || bin/spinach -r rerun $(cat tmp/spinach-rerun.txt)' artifacts: -- cgit v1.2.1 From ca05ea6b732cad9d7b9d809f6b66ba4fca904857 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 15:15:32 +0200 Subject: Remove knapsack_merger since we don't use it anyway --- spec/knapsack_merger.rb | 41 ----------------------------------------- spec/spec_helper.rb | 1 - 2 files changed, 42 deletions(-) delete mode 100644 spec/knapsack_merger.rb diff --git a/spec/knapsack_merger.rb b/spec/knapsack_merger.rb deleted file mode 100644 index c6bcefe8464..00000000000 --- a/spec/knapsack_merger.rb +++ /dev/null @@ -1,41 +0,0 @@ -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 84b9ee75f6a..a20f4c05971 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,7 +16,6 @@ require 'shoulda/matchers' require 'sidekiq/testing/inline' require 'rspec/retry' require 'knapsack' -require_relative 'knapsack_merger' Knapsack::Adapters::RSpecAdapter.bind -- cgit v1.2.1 From 12dd7bd7e59c8ce95c29f4ab2f08a6d9c513b734 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jun 2016 15:42:03 +0200 Subject: Remove stage notifications [ci skip] --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d098bf73ff8..fc1e43fcd44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,6 @@ stages: - prepare - test - post-test -- notifications # Prepare and merge knapsack tests -- cgit v1.2.1