summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-06 23:16:10 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-06 23:16:10 +0100
commit79f2bcd0eca5694e726664a2fa9246ee42e745f6 (patch)
tree3359c4af3bd7083f42c563c86b4b673eeb4b1f29
parent152d35b3a7351a7e248ad0ea7c6215a965d943d3 (diff)
downloadbundler-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.yml2
-rw-r--r--Rakefile9
-rw-r--r--spec/support/rubygems_ext.rb37
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
diff --git a/Rakefile b/Rakefile
index 07f74edb71..2fe080eb78 100644
--- a/Rakefile
+++ b/Rakefile
@@ -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)