-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundler: Run v1 native helpers with bundler v1 #3211
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rspec/its" | ||
require "webmock/rspec" | ||
require "byebug" | ||
|
||
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__)) | ||
$LOAD_PATH.unshift(File.expand_path("../monkey_patches", __dir__)) | ||
|
||
# Bundler monkey patches | ||
require "definition_ruby_version_patch" | ||
require "definition_bundler_version_patch" | ||
require "git_source_patch" | ||
|
||
require "functions" | ||
|
||
RSpec.configure do |config| | ||
config.color = true | ||
config.order = :rand | ||
config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true } | ||
config.raise_errors_for_deprecations! | ||
end | ||
|
||
# Duplicated in lib/dependabot/bundler/file_updater/lockfile_updater.rb | ||
# TODO: Stop sanitizing the lockfile once we have bundler 2 installed | ||
LOCKFILE_ENDING = /(?<ending>\s*(?:RUBY VERSION|BUNDLED WITH).*)/m.freeze | ||
|
||
def project_dependency_files(project) | ||
project_path = File.expand_path(File.join("../../spec/fixtures/projects/bundler1", project)) | ||
Dir.chdir(project_path) do | ||
# NOTE: Include dotfiles (e.g. .npmrc) | ||
files = Dir.glob("**/*", File::FNM_DOTMATCH) | ||
files = files.select { |f| File.file?(f) } | ||
files.map do |filename| | ||
content = File.read(filename) | ||
if filename == "Gemfile.lock" | ||
content = content.gsub(LOCKFILE_ENDING, "") | ||
end | ||
{ | ||
name: filename, | ||
content: content | ||
} | ||
end | ||
end | ||
end | ||
|
||
def fixture(*name) | ||
File.read(File.join("../../spec/fixtures", File.join(*name))) | ||
end |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bundler/compact_index_client" | ||
require "bundler/compact_index_client/updater" | ||
|
||
TMP_DIR_PATH = File.expand_path("../tmp", __dir__) | ||
|
||
RSpec.shared_context "in a temporary bundler directory" do | ||
let(:project_name) { "gemfile" } | ||
|
||
let(:tmp_path) do | ||
Dir.mkdir(TMP_DIR_PATH) unless Dir.exist?(TMP_DIR_PATH) | ||
dir = Dir.mktmpdir("native_helper_spec_", TMP_DIR_PATH) | ||
Pathname.new(dir).expand_path | ||
end | ||
|
||
before do | ||
project_dependency_files(project_name).each do |file| | ||
File.write(File.join(tmp_path, file[:name]), file[:content]) | ||
end | ||
end | ||
|
||
def in_tmp_folder(&block) | ||
Dir.chdir(tmp_path, &block) | ||
end | ||
end | ||
|
||
RSpec.shared_context "without caching rubygems" do | ||
before do | ||
# Stub Bundler to stop it using a cached versions of Rubygems | ||
allow_any_instance_of(Bundler::CompactIndexClient::Updater). | ||
to receive(:etag_for).and_return("") | ||
end | ||
end | ||
|
||
RSpec.shared_context "stub rubygems compact index" do | ||
include_context "without caching rubygems" | ||
|
||
before do | ||
# Stub the Rubygems index | ||
stub_request(:get, "https://index.rubygems.org/versions"). | ||
to_return( | ||
status: 200, | ||
body: fixture("ruby", "rubygems_responses", "index") | ||
) | ||
|
||
# Stub the Rubygems response for each dependency we have a fixture for | ||
fixtures = | ||
Dir[File.join("../../spec", "fixtures", "ruby", "rubygems_responses", "info-*")] | ||
fixtures.each do |path| | ||
dep_name = path.split("/").last.gsub("info-", "") | ||
stub_request(:get, "https://index.rubygems.org/info/#{dep_name}"). | ||
to_return( | ||
status: 200, | ||
body: fixture("ruby", "rubygems_responses", "info-#{dep_name}") | ||
) | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
bundler/spec/fixtures/projects/bundler1/multiple_blocking/Gemfile
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "activesupport", "5.0.0" | ||
gem "actionview", "5.0.0" | ||
gem "actionmailer", "5.0.0" |
70 changes: 70 additions & 0 deletions
70
bundler/spec/fixtures/projects/bundler1/multiple_blocking/Gemfile.lock
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionmailer (5.0.0) | ||
actionpack (= 5.0.0) | ||
actionview (= 5.0.0) | ||
activejob (= 5.0.0) | ||
mail (~> 2.5, >= 2.5.4) | ||
rails-dom-testing (~> 2.0) | ||
actionpack (5.0.0) | ||
actionview (= 5.0.0) | ||
activesupport (= 5.0.0) | ||
rack (~> 2.0) | ||
rack-test (~> 0.6.3) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.2) | ||
actionview (5.0.0) | ||
activesupport (= 5.0.0) | ||
builder (~> 3.1) | ||
erubis (~> 2.7.0) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.2) | ||
activejob (5.0.0) | ||
activesupport (= 5.0.0) | ||
globalid (>= 0.3.6) | ||
activesupport (5.0.0) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (~> 0.7) | ||
minitest (~> 5.1) | ||
tzinfo (~> 1.1) | ||
builder (3.2.4) | ||
concurrent-ruby (1.1.7) | ||
crass (1.0.6) | ||
erubis (2.7.0) | ||
globalid (0.4.2) | ||
activesupport (>= 4.2.0) | ||
i18n (0.9.5) | ||
concurrent-ruby (~> 1.0) | ||
loofah (2.7.0) | ||
crass (~> 1.0.2) | ||
nokogiri (>= 1.5.9) | ||
mail (2.7.1) | ||
mini_mime (>= 0.1.1) | ||
mini_mime (1.0.2) | ||
mini_portile2 (2.4.0) | ||
minitest (5.14.2) | ||
nokogiri (1.10.10) | ||
mini_portile2 (~> 2.4.0) | ||
rack (2.2.3) | ||
rack-test (0.6.3) | ||
rack (>= 1.0) | ||
rails-dom-testing (2.0.3) | ||
activesupport (>= 4.2.0) | ||
nokogiri (>= 1.6) | ||
rails-html-sanitizer (1.3.0) | ||
loofah (~> 2.3) | ||
thread_safe (0.3.6) | ||
tzinfo (1.2.7) | ||
thread_safe (~> 0.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
actionmailer (= 5.0.0) | ||
actionview (= 5.0.0) | ||
activesupport (= 5.0.0) | ||
|
||
BUNDLED WITH | ||
2.1.4 |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
source "https://username:[email protected]/" do | ||
gem 'sidekiq-pro' | ||
end |
26 changes: 26 additions & 0 deletions
26
bundler/spec/fixtures/projects/bundler1/sidekiq_pro/Gemfile.lock
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
remote: https://username:[email protected]/ | ||
specs: | ||
concurrent-ruby (1.0.5) | ||
connection_pool (2.2.1) | ||
rack (1.4.7) | ||
rack-protection (1.5.3) | ||
rack | ||
redis (3.3.3) | ||
sidekiq (4.2.9) | ||
concurrent-ruby (~> 1.0) | ||
connection_pool (~> 2.2, >= 2.2.0) | ||
rack-protection (>= 1.5.0) | ||
redis (~> 3.2, >= 3.2.1) | ||
sidekiq-pro (3.4.4) | ||
sidekiq (>= 4.1.5) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
sidekiq-pro! | ||
|
||
BUNDLED WITH | ||
1.15.3 |
3 changes: 3 additions & 0 deletions
3
bundler/spec/fixtures/projects/bundler1/specified_default_source_no_lockfile/Gemfile
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://[email protected]/greysteil/' | ||
|
||
gem 'business' |
7 changes: 7 additions & 0 deletions
7
bundler/spec/fixtures/projects/bundler1/specified_source_no_lockfile/Gemfile
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'statesman' | ||
|
||
source 'https://[email protected]/greysteil/' do | ||
gem 'business' | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's a big deal right for this PR, but I guess we should add
bundler2
to the matrix rather than mess with this existing key?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, was also thinking we could run them in in the same suite a second step as I think they run quickly. Each matrix ends up building the entire image as it's set up currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, that makes sense!