Skip to content

Commit

Permalink
update supported versions scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
quinna-h committed Jan 14, 2025
1 parent b2bf14b commit a757be9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
45 changes: 29 additions & 16 deletions .github/scripts/find_gem_version_bounds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def process_gemfile(gemfile_name, runtime)
definition.dependencies.each do |dependency|
gem_name = dependency.name
version = dependency.requirement.to_s
update_gem_versions(runtime, gem_name, version)
unspecified = version.strip == '' || version == ">= 0"
if unspecified
puts "#{gem_name} uses latest"
end
update_gem_versions(runtime, gem_name, version, unspecified)
end
rescue Bundler::GemfileError => e
puts "Error reading Gemfile: #{e.message}"
Expand All @@ -65,30 +69,36 @@ def process_lockfile(gemfile_name, runtime)
parser.specs.each do |spec|
gem_name = spec.name
version = spec.version.to_s
update_gem_versions(runtime, gem_name, version)
update_gem_versions(runtime, gem_name, version, false)
end
end

def update_gem_versions(runtime, gem_name, version)
return unless version_valid?(version)

gem_version = Gem::Version.new(version)
def update_gem_versions(runtime, gem_name, version, unspecified)
return unless version_valid?(version, unspecified)

gem_version = Gem::Version.new(version) unless unspecified
# Update minimum gems
if @min_gems[runtime][gem_name].nil? || gem_version < Gem::Version.new(@min_gems[runtime][gem_name])
@min_gems[runtime][gem_name] = version
if not unspecified
if @min_gems[runtime][gem_name].nil? || gem_version < Gem::Version.new(@min_gems[runtime][gem_name])
@min_gems[runtime][gem_name] = version
end
end

# Update maximum gems
if @max_gems[runtime][gem_name].nil? || gem_version > Gem::Version.new(@max_gems[runtime][gem_name])
@max_gems[runtime][gem_name] = version
if unspecified
puts "Setting gem #{gem_name} to infinity"
@max_gems[runtime][gem_name] = Float::INFINITY
else
if @max_gems[runtime][gem_name].nil? || (@max_gems[runtime][gem_name] != Float::INFINITY && gem_version > Gem::Version.new(@max_gems[runtime][gem_name]))
@max_gems[runtime][gem_name] = version
end
end
end

# Helper: Validate the version format
def version_valid?(version)
def version_valid?(version, unspecified)
return true if unspecified
return false if version.nil? || version.strip.empty?

Gem::Version.new(version)
true
rescue ArgumentError
Expand Down Expand Up @@ -116,16 +126,16 @@ def include_hardcoded_versions
# `httpx` is maintained externally
@integration_json_mapping['httpx'] = [
'0.11', # Min version Ruby
'0.11', # Max version Ruby
nil, # Min version JRuby
nil, # Max version Ruby
'0.11', # Min version JRuby
nil # Max version JRuby
]

# `makara` is part of `activerecord`
@integration_json_mapping['makara'] = [
'0.3.5', # Min version Ruby
'0.3.5', # Max version Ruby
nil, # Min version JRuby
nil, # Max version Ruby
'0.3.5', # Min version JRuby
nil # Max version JRuby
]
end
Expand All @@ -142,6 +152,9 @@ def resolve_integration_name(integration)

def write_output
@integration_json_mapping = @integration_json_mapping.sort.to_h
@integration_json_mapping.each do |integration, versions|
versions.map! { |v| v == Float::INFINITY ? 'infinity' : v }
end
File.write("gem_output.json", JSON.pretty_generate(@integration_json_mapping))
end
end
Expand Down
14 changes: 12 additions & 2 deletions .github/scripts/generate_table_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@
header = "| Integration | Ruby Min | Ruby Max | JRuby Min | JRuby Max |\n"
separator = "|-------------|----------|-----------|----------|----------|\n"
rows = data.map do |integration_name, versions|
ruby_min, ruby_max, jruby_min, jruby_max = versions.map { |v| v || "None" }
"| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
ruby_min, ruby_max, jruby_min, jruby_max = versions.map do |v|
if v == "infinity"
"latest"
else
v || "None" # This handles nil values by replacing them with "None"
end
end
"| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
end
# rows = data.map do |integration_name, versions|
# ruby_min, ruby_max, jruby_min, jruby_max = versions.map { |v| v || "None" }
# "| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
# end

File.open(output_file, 'w') do |file|
file.puts comment
Expand Down

0 comments on commit a757be9

Please sign in to comment.