Skip to content

Commit d8536e1

Browse files
hsbtclaude
andcommitted
Vendor compact_index during install_test_deps
The earlier `rake vendor:compact_index` hook into `dev:deps` and the hard-copy step in ruby-core.yml fell apart in ruby/ruby's test-bundler runner, which sets TMPDIR per process and does not invoke our rake tasks. Pull the fetch logic into `Spec::Rubygems.install_vendored_compact_index` and call it from `install_test_deps` so every test setup path - local `bin/rspec`, `bin/parallel_rspec`, GHA bundler.yml, and ruby/ruby's test-bundler - lands the files at `Path.tmp_root.join("compact_index")` exactly where the artifice already looks. The standalone rake task and its workflow hop are no longer needed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 4bafea5 commit d8536e1

2 files changed

Lines changed: 28 additions & 31 deletions

File tree

Rakefile

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,14 @@ require "rake/testtask"
99
require_relative "spec/support/rubygems_ext"
1010

1111
desc "Setup Rubygems dev environment"
12-
task setup: [:"dev:deps", "vendor:compact_index"] do
12+
task setup: [:"dev:deps"] do
1313
Dir.glob("tool/bundler/*_gems.rb").each do |file|
1414
name = File.basename(file, ".rb")
1515
next if name == "dev_gems"
1616
Spec::Rubygems.dev_bundle "lock", gemfile: file
1717
end
1818
end
1919

20-
namespace :vendor do
21-
# Pinned to rubygems/rubygems.org#6504 so `rake setup` stays reproducible.
22-
# Override with REF=<sha> to test against a newer compact_index.
23-
desc "Sync vendored compact_index from rubygems/rubygems.org"
24-
task :compact_index do
25-
require "open-uri"
26-
require "fileutils"
27-
28-
ref = ENV["REF"] || "7c68a7b39761c61a66f9299f85b889ec39afc02c"
29-
repo = "rubygems/rubygems.org"
30-
paths = %w[
31-
lib/compact_index.rb
32-
lib/compact_index/dependency.rb
33-
lib/compact_index/gem.rb
34-
lib/compact_index/gem_version.rb
35-
lib/compact_index/versions_file.rb
36-
]
37-
38-
target_root = Spec::Path.tmp_root.join("compact_index")
39-
paths.each do |path|
40-
url = "https://raw.githubusercontent.com/#{repo}/#{ref}/#{path}"
41-
puts "Fetching #{url}"
42-
content = URI.parse(url).open(&:read)
43-
target = File.join(target_root, path)
44-
FileUtils.mkdir_p(File.dirname(target))
45-
File.write(target, content)
46-
end
47-
end
48-
end
49-
5020
desc "Update Rubygems dev environment"
5121
task :update do
5222
Spec::Rubygems.dev_bundle "update", "--all"

spec/support/rubygems_ext.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,33 @@ def install_test_deps
7373

7474
require_relative "helpers"
7575
Helpers.install_dev_bundler
76+
77+
install_vendored_compact_index
78+
end
79+
80+
# Vendor `rubygems/rubygems.org#lib/compact_index/` under `tmp/compact_index/`
81+
# so the artifice can serve compact-index responses without a runtime gem
82+
# dependency. Pinned to a reviewed commit; override with COMPACT_INDEX_REF.
83+
def install_vendored_compact_index
84+
target_root = Path.tmp_root.join("compact_index")
85+
return if File.exist?(target_root.join("lib/compact_index.rb"))
86+
87+
require "open-uri"
88+
require "fileutils"
89+
90+
ref = ENV["COMPACT_INDEX_REF"] || "7c68a7b39761c61a66f9299f85b889ec39afc02c"
91+
%w[
92+
lib/compact_index.rb
93+
lib/compact_index/dependency.rb
94+
lib/compact_index/gem.rb
95+
lib/compact_index/gem_version.rb
96+
lib/compact_index/versions_file.rb
97+
].each do |path|
98+
url = "https://raw.githubusercontent.com/rubygems/rubygems.org/#{ref}/#{path}"
99+
target = target_root.join(path)
100+
FileUtils.mkdir_p(File.dirname(target))
101+
File.write(target, URI.parse(url).open(&:read))
102+
end
76103
end
77104

78105
def check_source_control_changes(success_message:, error_message:)

0 commit comments

Comments
 (0)