Skip to content
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

supported versions workflow: fix parsing and modify gem names #4294

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 11 additions & 33 deletions .github/scripts/find_gem_version_bounds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class GemfileProcessor
SPECIAL_CASES = {
"opensearch" => "OpenSearch" # special case because opensearch = OpenSearch not Opensearch
"opensearch" => "OpenSearch", # special case because opensearch = OpenSearch not Opensearch
}.freeze
EXCLUDED_INTEGRATIONS = ["configuration", "propagation", "utils"].freeze

Expand Down Expand Up @@ -37,32 +37,13 @@ def parse_gemfiles(directory = 'gemfiles/')
runtime = File.basename(gemfile_name).split('_').first # ruby or jruby
next unless %w[ruby jruby].include?(runtime)
# parse the gemfile
if gemfile_name.end_with?(".gemfile")
process_gemfile(gemfile_name, runtime)
elsif gemfile_name.end_with?('.gemfile.lock')
if gemfile_name.end_with?('.gemfile.lock')
process_lockfile(gemfile_name, runtime)
end
end

end

def process_gemfile(gemfile_name, runtime)
begin
definition = Bundler::Definition.build(gemfile_name, nil, nil)
definition.dependencies.each do |dependency|
gem_name = dependency.name
version = dependency.requirement.to_s
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}"
end
end

def process_lockfile(gemfile_name, runtime)
lockfile_contents = File.read(gemfile_name)
parser = Bundler::LockfileParser.new(lockfile_contents)
Expand All @@ -86,7 +67,6 @@ def update_gem_versions(runtime, gem_name, version, unspecified)

# Update maximum gems
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]))
Expand All @@ -102,6 +82,7 @@ def version_valid?(version, unspecified)
Gem::Version.new(version)
true
rescue ArgumentError
puts "#{version} is invalid format."
false
end

Expand All @@ -125,18 +106,18 @@ def process_integrations
def include_hardcoded_versions
# `httpx` is maintained externally
@integration_json_mapping['httpx'] = [
'0.11', # Min version Ruby
nil, # Max version Ruby
'0.11', # Min version JRuby
nil # Max version JRuby
'0.11', # Min version Ruby
'infinity', # Max version Ruby
'0.11', # Min version JRuby
'infinity' # Max version JRuby
]

# `makara` is part of `activerecord`
@integration_json_mapping['makara'] = [
'0.3.5', # Min version Ruby
nil, # Max version Ruby
'0.3.5', # Min version JRuby
nil # Max version JRuby
'0.3.5', # Min version Ruby
'infinity', # Max version Ruby
'0.3.5', # Min version JRuby
'infinity' # Max version JRuby
]
end

Expand All @@ -152,9 +133,6 @@ 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
4 changes: 0 additions & 4 deletions .github/scripts/generate_table_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
separator = "|-------------|----------|-----------|----------|----------|\n"
rows = data.map do |integration_name, versions|
ruby_min, ruby_max, jruby_min, jruby_max = versions.map do |v|
if v == "infinity"
"latest"
else
v || "None"
end
end
"| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/tracing/contrib/aws/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Integration
# @public_api Changing the integration name or integration options can cause breaking changes
register_as :aws, auto_patch: true
def self.gem_name
'aws-sdk-core'
'aws-sdk'
end

def self.version
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/http/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :http, auto_patch: true
def self.gem_name
'net-http'
end

def self.version
Gem::Version.new(RUBY_VERSION)
Expand Down
Loading