Skip to content

Commit 310b842

Browse files
quinna-hStrech
andauthored
Update supported versions workflow (#4326)
Co-authored-by: Sergey Fedorov <[email protected]>
1 parent 04efab7 commit 310b842

File tree

3 files changed

+74
-39
lines changed

3 files changed

+74
-39
lines changed

.github/scripts/generate_table_versions.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/scripts/find_gem_version_bounds.rb renamed to .github/scripts/update_supported_versions.rb

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ class GemfileProcessor
1414
EXCLUDED_INTEGRATIONS = ["configuration", "propagation", "utils"].freeze
1515

1616
def initialize(directory: 'gemfiles/', contrib_dir: 'lib/datadog/tracing/contrib/')
17+
unless Dir.exist?(directory)
18+
warn("Directory #{directory} does not exist")
19+
end
20+
21+
unless Dir.exist?(contrib_dir)
22+
warn("Directory #{contrib_dir} does not exist")
23+
end
1724
@directory = directory
1825
@contrib_dir = contrib_dir
1926
@min_gems = { 'ruby' => {}, 'jruby' => {} }
@@ -25,7 +32,7 @@ def process
2532
parse_gemfiles
2633
process_integrations
2734
include_hardcoded_versions
28-
write_output
35+
write_markdown_output
2936
end
3037

3138
private
@@ -106,18 +113,18 @@ def process_integrations
106113
def include_hardcoded_versions
107114
# `httpx` is maintained externally
108115
@integration_json_mapping['httpx'] = [
109-
'0.11', # Min version Ruby
110-
'infinity', # Max version Ruby
111-
'0.11', # Min version JRuby
112-
'infinity' # Max version JRuby
116+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Min version Ruby
117+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Max version Ruby
118+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Min version JRuby
119+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Max version JRuby
113120
]
114121

115122
# `makara` is part of `activerecord`
116123
@integration_json_mapping['makara'] = [
117-
'0.3.5', # Min version Ruby
118-
'infinity', # Max version Ruby
119-
'0.3.5', # Min version JRuby
120-
'infinity' # Max version JRuby
124+
'0.5.1', # Min version Ruby
125+
'0.5.1', # Max version Ruby
126+
'0.5.1', # Min version JRuby
127+
'0.5.1' # Max version JRuby
121128
]
122129
end
123130

@@ -131,10 +138,60 @@ def resolve_integration_name(integration)
131138
integration
132139
end
133140

134-
def write_output
135-
@integration_json_mapping = @integration_json_mapping.sort.to_h
136-
File.write("gem_output.json", JSON.pretty_generate(@integration_json_mapping))
141+
def write_markdown_output
142+
output_file = 'docs/integration_versions.md'
143+
comment = <<~COMMENT
144+
<!--
145+
# Please do NOT manually edit this file.
146+
# This file is generated by `bundle exec ruby .github/scripts/update_supported_versions.rb`
147+
148+
### Supported Versions Table ###
149+
150+
This markdown file is generated from the minimum and maximum versions of the integrations we support, as tested in our `gemfile.lock` lockfiles.
151+
For a list of available integrations, and their supported version ranges, refer to the following:
152+
-->
153+
COMMENT
154+
column_widths = {
155+
integration: 24,
156+
ruby_min: 19,
157+
ruby_max: 19,
158+
jruby_min: 19,
159+
jruby_max: 19
160+
}
161+
columns = {
162+
integration: "Integration",
163+
ruby_min: "Ruby Min",
164+
ruby_max: "Ruby Max",
165+
jruby_min: "JRuby Min",
166+
jruby_max: "JRuby Max"
167+
}
168+
169+
adjusted_widths = columns.transform_values.with_index do |title, index|
170+
[title.length, column_widths.values[index]].max
171+
end
172+
173+
header = "| " + columns.map { |key, title| title.ljust(adjusted_widths[key]) }.join(" | ") + " |"
174+
separator = "|-" + adjusted_widths.map { |_, width| "-" * width }.join("-|-") + "-|"
175+
rows = @integration_json_mapping
176+
.sort_by { |name, _versions| name.downcase }
177+
.map do |name, versions|
178+
integration_name = name.ljust(column_widths[:integration])
179+
ruby_min = (versions[0] || "None").ljust(column_widths[:ruby_min])
180+
ruby_max = (versions[1] == 'infinity' ? 'latest' : versions[1] || 'None').ljust(column_widths[:ruby_max])
181+
jruby_min = (versions[2] || "None").ljust(column_widths[:jruby_min])
182+
jruby_max = (versions[3] == 'infinity' ? 'latest' : versions[3] || 'None').ljust(column_widths[:jruby_max])
183+
184+
"| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
185+
end
186+
187+
File.open(output_file, 'w') do |file|
188+
file.puts comment
189+
file.puts header
190+
file.puts separator
191+
rows.each { |row| file.puts row }
192+
end
137193
end
138194
end
139195

196+
140197
GemfileProcessor.new.process

.github/workflows/generate-supported-versions.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ jobs:
2424
ruby-version: "3.3"
2525

2626
- name: Update latest
27-
run: bundle exec ruby .github/scripts/find_gem_version_bounds.rb
28-
29-
- name: Generate versions table
30-
run: ruby .github/scripts/generate_table_versions.rb
27+
run: bundle exec ruby .github/scripts/update_supported_versions.rb
3128

3229
- run: git diff
3330

@@ -44,6 +41,10 @@ jobs:
4441
delete-branch: true
4542
body: |
4643
This is a PR to update the table for supported integration versions.
44+
The supported versions markdown is generated from the minimum and maximum tested versions of each integration,
45+
as defined from the `gemfile.lock` gem declarations.
46+
4747
Workflow run: [Generate Supported Versions](https://github.com/DataDog/dd-trace-rb/actions/workflows/generate-supported-versions.yml)
48+
4849
This should be tied to tracer releases, or triggered manually.
4950

0 commit comments

Comments
 (0)