-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into di-instrumentation
- Loading branch information
Showing
4 changed files
with
66 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
461 | ||
462 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,50 @@ | ||
require 'open3' | ||
|
||
require_relative 'appraisal_conversion' | ||
|
||
task :dep => :dependency | ||
task :dependency => %w[dependency:lock] | ||
namespace :dependency do | ||
# rubocop:disable Style/MultilineBlockChain | ||
Dir.glob(AppraisalConversion.gemfile_pattern).each do |gemfile| | ||
# desc "Lock the dependencies for #{gemfile}" | ||
task gemfile do | ||
# Replacement for `bundle exec appraisal list` | ||
desc "List dependencies for #{AppraisalConversion.runtime_identifier}" | ||
task :list do |t, args| | ||
pattern = args.extras.any? ? args.extras : AppraisalConversion.gemfile_pattern | ||
|
||
gemfiles = Dir.glob(pattern, base: AppraisalConversion.root_path) | ||
|
||
puts "Ahoy! Here is a list of gemfiles you are looking for:\n\n" | ||
|
||
puts "========================================\n" | ||
puts gemfiles | ||
puts "========================================\n" | ||
|
||
puts "You can do a bunch of cool stuff by assigning a gemfile path to the BUNDLE_GEMFILE environment variable, like:\n" | ||
puts "`BUNDLE_GEMFILE=#{gemfiles.sample} bundle install`\n\n" | ||
end | ||
|
||
# Replacement for `bundle exec appraisal bundle lock` | ||
desc "Lock dependencies for #{AppraisalConversion.runtime_identifier}" | ||
task :lock do |t, args| | ||
pattern = args.extras.any? ? args.extras : AppraisalConversion.gemfile_pattern | ||
|
||
gemfiles = Dir.glob(pattern) | ||
|
||
gemfiles.each do |gemfile| | ||
Bundler.with_unbundled_env do | ||
command = +'bundle lock' | ||
command << ' --add-platform x86_64-linux aarch64-linux' unless RUBY_PLATFORM == 'java' | ||
output, = Open3.capture2e({ 'BUNDLE_GEMFILE' => gemfile.to_s }, command) | ||
sh({ 'BUNDLE_GEMFILE' => gemfile.to_s }, command) | ||
end | ||
end | ||
end | ||
|
||
puts output | ||
# Replacement for `bundle exec appraisal install` | ||
desc "Install dependencies for #{AppraisalConversion.runtime_identifier}" | ||
task :install => :lock do |t, args| | ||
pattern = args.extras.any? ? args.extras : AppraisalConversion.gemfile_pattern | ||
|
||
gemfiles = Dir.glob(pattern) | ||
|
||
gemfiles.each do |gemfile| | ||
Bundler.with_unbundled_env do | ||
sh({ 'BUNDLE_GEMFILE' => gemfile.to_s }, 'bundle check || bundle install') | ||
end | ||
end | ||
end.tap do |gemfiles| | ||
desc "Lock the dependencies for #{AppraisalConversion.runtime_identifier}" | ||
# WHY can't we use `multitask :lock => gemfiles` here? | ||
# | ||
# Running bundler in parallel has various race conditions | ||
# | ||
# Race condition with the file system, particularly worse with JRuby. | ||
# For instance, `Errno::ENOENT: No such file or directory - bundle` is raised with JRuby 9.2 | ||
|
||
# Even with CRuby, `simplcov` declaration with `github` in Gemfile causes | ||
# race condition for the local gem cache with the following error: | ||
|
||
# ``` | ||
# [/usr/local/bundle/bundler/gems/simplecov-3bb6b7ee58bf/simplecov.gemspec] isn't a Gem::Specification (NilClass instead). | ||
# ``` | ||
|
||
# and | ||
|
||
# ``` | ||
# fatal: Unable to create '/usr/local/bundle/bundler/gems/simplecov-3bb6b7ee58bf/.git/index.lock': File exists. | ||
# Another git process seems to be running in this repository, e.g. | ||
# an editor opened by 'git commit'. Please make sure all processes | ||
# are terminated then try again. If it still fails, a git process | ||
# may have crashed in this repository earlier: | ||
# remove the file manually to continue. | ||
# ``` | ||
task :lock => gemfiles | ||
end | ||
# rubocop:enable Style/MultilineBlockChain | ||
end |