Skip to content

Commit 3c87889

Browse files
authored
supported versions workflow: fix parsing and modify gem names (#4294)
1 parent 3e81a5a commit 3c87889

File tree

4 files changed

+15
-38
lines changed

4 files changed

+15
-38
lines changed

.github/scripts/find_gem_version_bounds.rb

+11-33
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class GemfileProcessor
1111
SPECIAL_CASES = {
12-
"opensearch" => "OpenSearch" # special case because opensearch = OpenSearch not Opensearch
12+
"opensearch" => "OpenSearch", # special case because opensearch = OpenSearch not Opensearch
1313
}.freeze
1414
EXCLUDED_INTEGRATIONS = ["configuration", "propagation", "utils"].freeze
1515

@@ -37,32 +37,13 @@ def parse_gemfiles(directory = 'gemfiles/')
3737
runtime = File.basename(gemfile_name).split('_').first # ruby or jruby
3838
next unless %w[ruby jruby].include?(runtime)
3939
# parse the gemfile
40-
if gemfile_name.end_with?(".gemfile")
41-
process_gemfile(gemfile_name, runtime)
42-
elsif gemfile_name.end_with?('.gemfile.lock')
40+
if gemfile_name.end_with?('.gemfile.lock')
4341
process_lockfile(gemfile_name, runtime)
4442
end
4543
end
4644

4745
end
4846

49-
def process_gemfile(gemfile_name, runtime)
50-
begin
51-
definition = Bundler::Definition.build(gemfile_name, nil, nil)
52-
definition.dependencies.each do |dependency|
53-
gem_name = dependency.name
54-
version = dependency.requirement.to_s
55-
unspecified = version.strip == '' || version == ">= 0"
56-
if unspecified
57-
puts "#{gem_name} uses latest"
58-
end
59-
update_gem_versions(runtime, gem_name, version, unspecified)
60-
end
61-
rescue Bundler::GemfileError => e
62-
puts "Error reading Gemfile: #{e.message}"
63-
end
64-
end
65-
6647
def process_lockfile(gemfile_name, runtime)
6748
lockfile_contents = File.read(gemfile_name)
6849
parser = Bundler::LockfileParser.new(lockfile_contents)
@@ -86,7 +67,6 @@ def update_gem_versions(runtime, gem_name, version, unspecified)
8667

8768
# Update maximum gems
8869
if unspecified
89-
puts "Setting gem #{gem_name} to infinity"
9070
@max_gems[runtime][gem_name] = Float::INFINITY
9171
else
9272
if @max_gems[runtime][gem_name].nil? || (@max_gems[runtime][gem_name] != Float::INFINITY && gem_version > Gem::Version.new(@max_gems[runtime][gem_name]))
@@ -102,6 +82,7 @@ def version_valid?(version, unspecified)
10282
Gem::Version.new(version)
10383
true
10484
rescue ArgumentError
85+
puts "#{version} is invalid format."
10586
false
10687
end
10788

@@ -125,18 +106,18 @@ def process_integrations
125106
def include_hardcoded_versions
126107
# `httpx` is maintained externally
127108
@integration_json_mapping['httpx'] = [
128-
'0.11', # Min version Ruby
129-
nil, # Max version Ruby
130-
'0.11', # Min version JRuby
131-
nil # Max version JRuby
109+
'0.11', # Min version Ruby
110+
'infinity', # Max version Ruby
111+
'0.11', # Min version JRuby
112+
'infinity' # Max version JRuby
132113
]
133114

134115
# `makara` is part of `activerecord`
135116
@integration_json_mapping['makara'] = [
136-
'0.3.5', # Min version Ruby
137-
nil, # Max version Ruby
138-
'0.3.5', # Min version JRuby
139-
nil # Max version JRuby
117+
'0.3.5', # Min version Ruby
118+
'infinity', # Max version Ruby
119+
'0.3.5', # Min version JRuby
120+
'infinity' # Max version JRuby
140121
]
141122
end
142123

@@ -152,9 +133,6 @@ def resolve_integration_name(integration)
152133

153134
def write_output
154135
@integration_json_mapping = @integration_json_mapping.sort.to_h
155-
@integration_json_mapping.each do |integration, versions|
156-
versions.map! { |v| v == Float::INFINITY ? 'infinity' : v }
157-
end
158136
File.write("gem_output.json", JSON.pretty_generate(@integration_json_mapping))
159137
end
160138
end

.github/scripts/generate_table_versions.rb

-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
separator = "|-------------|----------|-----------|----------|----------|\n"
1111
rows = data.map do |integration_name, versions|
1212
ruby_min, ruby_max, jruby_min, jruby_max = versions.map do |v|
13-
if v == "infinity"
14-
"latest"
15-
else
1613
v || "None"
17-
end
1814
end
1915
"| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
2016
end

lib/datadog/tracing/contrib/aws/integration.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Integration
1717
# @public_api Changing the integration name or integration options can cause breaking changes
1818
register_as :aws, auto_patch: true
1919
def self.gem_name
20-
'aws-sdk-core'
20+
'aws-sdk'
2121
end
2222

2323
def self.version

lib/datadog/tracing/contrib/http/integration.rb

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Integration
2222

2323
# @public_api Changing the integration name or integration options can cause breaking changes
2424
register_as :http, auto_patch: true
25+
def self.gem_name
26+
'net-http'
27+
end
2528

2629
def self.version
2730
Gem::Version.new(RUBY_VERSION)

0 commit comments

Comments
 (0)