Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,14 @@ require "rake/testtask"
require_relative "spec/support/rubygems_ext"

desc "Setup Rubygems dev environment"
task setup: [:"dev:deps", "vendor:compact_index"] do
task setup: [:"dev:deps"] do
Dir.glob("tool/bundler/*_gems.rb").each do |file|
name = File.basename(file, ".rb")
next if name == "dev_gems"
Spec::Rubygems.dev_bundle "lock", gemfile: file
end
end

namespace :vendor do
# Pinned to rubygems/rubygems.org#6504 so `rake setup` stays reproducible.
# Override with REF=<sha> to test against a newer compact_index.
desc "Sync vendored compact_index from rubygems/rubygems.org"
task :compact_index do
require "open-uri"
require "fileutils"

ref = ENV["REF"] || "7c68a7b39761c61a66f9299f85b889ec39afc02c"
repo = "rubygems/rubygems.org"
paths = %w[
lib/compact_index.rb
lib/compact_index/dependency.rb
lib/compact_index/gem.rb
lib/compact_index/gem_version.rb
lib/compact_index/versions_file.rb
]

target_root = Spec::Path.tmp_root.join("compact_index")
paths.each do |path|
url = "https://raw.githubusercontent.com/#{repo}/#{ref}/#{path}"
puts "Fetching #{url}"
content = URI.parse(url).open(&:read)
target = File.join(target_root, path)
FileUtils.mkdir_p(File.dirname(target))
File.write(target, content)
end
end
end

desc "Update Rubygems dev environment"
task :update do
Spec::Rubygems.dev_bundle "update", "--all"
Expand Down
32 changes: 32 additions & 0 deletions spec/support/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,38 @@ def install_test_deps

require_relative "helpers"
Helpers.install_dev_bundler

install_vendored_compact_index
end

# Vendor `rubygems/rubygems.org#lib/compact_index/` under `tmp/compact_index/`
# so the artifice can serve compact-index responses without a runtime gem
# dependency. Pinned to a reviewed commit; override with COMPACT_INDEX_REF
# to refresh against another ref (the existing vendor copy is discarded).
def install_vendored_compact_index
target_root = Path.tmp_root.join("compact_index")
require "fileutils"

if ENV["COMPACT_INDEX_REF"]
FileUtils.rm_rf(target_root)
elsif File.exist?(target_root.join("lib/compact_index.rb"))
return
end

require "open-uri"
ref = ENV["COMPACT_INDEX_REF"] || "7c68a7b39761c61a66f9299f85b889ec39afc02c"
%w[
lib/compact_index.rb
lib/compact_index/dependency.rb
lib/compact_index/gem.rb
lib/compact_index/gem_version.rb
lib/compact_index/versions_file.rb
].each do |path|
url = "https://raw.githubusercontent.com/rubygems/rubygems.org/#{ref}/#{path}"
target = target_root.join(path)
FileUtils.mkdir_p(File.dirname(target))
File.write(target, URI.parse(url).open(&:read))
end
Comment on lines +88 to +107
end

def check_source_control_changes(success_message:, error_message:)
Expand Down
Loading