diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-01-06 23:16:10 +0100 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-01-06 23:16:10 +0100 |
commit | 79f2bcd0eca5694e726664a2fa9246ee42e745f6 (patch) | |
tree | 3359c4af3bd7083f42c563c86b4b673eeb4b1f29 | |
parent | 152d35b3a7351a7e248ad0ea7c6215a965d943d3 (diff) | |
download | bundler-enforce_windows_ci.tar.gz |
Split test gem installation to a separate taskenforce_windows_ci
We run into a race condition when testing in parallel when all
processors install test gems to their test folder (due to shared gem
cache). So I figure we can instead run this setup sequentially
beforehand.
-rw-r--r-- | .github/workflows/windows.yml | 2 | ||||
-rw-r--r-- | Rakefile | 9 | ||||
-rw-r--r-- | spec/support/rubygems_ext.rb | 37 |
3 files changed, 39 insertions, 9 deletions
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3f2aaa208b..00e0fc0385 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -25,7 +25,7 @@ jobs: ruby-version: ${{ matrix.ruby }} - name: Install dependencies - run: bin/rake spec:deps + run: bin/rake spec:parallel_deps shell: bash - name: Run specs @@ -34,6 +34,15 @@ namespace :spec do desc "Ensure spec dependencies are installed" task :deps do Spec::Rubygems.dev_setup + + Spec::Rubygems.install_test_deps + end + + desc "Ensure spec dependencies for running in parallel are installed" + task :parallel_deps do + Spec::Rubygems.dev_setup + + Spec::Rubygems.install_parallel_test_deps end task :clean do diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index d41ee64bec..b57a725de4 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -51,15 +51,9 @@ module Spec end def setup - require "fileutils" - - Gem.clear_paths - - ENV["BUNDLE_PATH"] = nil - ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s - ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR) + install_test_deps - install_gems(DEPS) + require "fileutils" FileUtils.mkdir_p(Path.home) FileUtils.mkdir_p(Path.tmpdir) @@ -71,6 +65,33 @@ module Spec Gem::DefaultUserInteraction.ui = Gem::SilentUI.new end + def install_parallel_test_deps + require "parallel" + + prev_env_test_number = ENV["TEST_ENV_NUMBER"] + + begin + Parallel.processor_count.times do |n| + ENV["TEST_ENV_NUMBER"] = (n + 1).to_s + + install_test_deps + end + ensure + ENV["TEST_ENV_NUMBER"] = prev_env_test_number + end + end + + def install_test_deps + puts "Clearing paths.." + Gem.clear_paths + + ENV["BUNDLE_PATH"] = nil + ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s + ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR) + + install_gems(DEPS) + end + private def gem_load_and_activate(gem_name, bin_container) |