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

Update supported versions workflow #4326

Merged
merged 11 commits into from
Feb 3, 2025
71 changes: 59 additions & 12 deletions .github/scripts/find_gem_version_bounds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def process
parse_gemfiles
process_integrations
include_hardcoded_versions
write_output
write_markdown_output
end

private
Expand Down Expand Up @@ -106,18 +106,18 @@ def process_integrations
def include_hardcoded_versions
# `httpx` is maintained externally
@integration_json_mapping['httpx'] = [
'0.11', # Min version Ruby
'infinity', # Max version Ruby
'0.11', # Min version JRuby
'infinity' # Max version JRuby
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Min version Ruby
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Max version Ruby
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Min version JRuby
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Max version JRuby
]

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

Expand All @@ -131,10 +131,57 @@ def resolve_integration_name(integration)
integration
end

def write_output
@integration_json_mapping = @integration_json_mapping.sort.to_h
File.write("gem_output.json", JSON.pretty_generate(@integration_json_mapping))
def write_markdown_output
output_file = 'docs/integration_versions.md'
comment = <<~COMMENT
<!--
### Supported Versions Table ###

This markdown file is generated from the minimum and maximum versions of the integrations we support, as tested in our `gemfile.lock` lockfiles.
For a list of available integrations, and their supported version ranges, refer to the following:
-->
COMMENT
column_widths = {
integration: 24,
ruby_min: 19,
ruby_max: 19,
jruby_min: 19,
jruby_max: 19
}
columns = {
integration: "Integration",
ruby_min: "Ruby Min",
ruby_max: "Ruby Max",
jruby_min: "JRuby Min",
jruby_max: "JRuby Max"
}

adjusted_widths = columns.transform_values.with_index do |title, index|
[title.length, column_widths.values[index]].max
end

header = "| " + columns.map { |key, title| title.ljust(adjusted_widths[key]) }.join(" | ") + " |"
quinna-h marked this conversation as resolved.
Show resolved Hide resolved
separator = "|-" + adjusted_widths.map { |_, width| "-" * width }.join("-|-") + "-|"
quinna-h marked this conversation as resolved.
Show resolved Hide resolved
rows = @integration_json_mapping
.sort_by { |name, _versions| name.downcase }
.map do |name, versions|
integration_name = name.ljust(column_widths[:integration])
ruby_min = (versions[0] || "None").ljust(column_widths[:ruby_min])
marcotc marked this conversation as resolved.
Show resolved Hide resolved
ruby_max = (versions[1] == 'infinity' ? 'latest' : versions[1] || 'None').ljust(column_widths[:ruby_max])
jruby_min = (versions[2] || "None").ljust(column_widths[:jruby_min])
jruby_max = (versions[3] == 'infinity' ? 'latest' : versions[3] || 'None').ljust(column_widths[:jruby_max])

"| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
end

File.open(output_file, 'w') do |file|
file.puts comment
file.puts header
file.puts separator
rows.each { |row| file.puts row }
end
end
end


GemfileProcessor.new.process
23 changes: 0 additions & 23 deletions .github/scripts/generate_table_versions.rb

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/generate-supported-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
- name: Update latest
run: bundle exec ruby .github/scripts/find_gem_version_bounds.rb

- name: Generate versions table
run: ruby .github/scripts/generate_table_versions.rb

- run: git diff

- name: Create Pull Request
Expand All @@ -44,6 +41,10 @@ jobs:
delete-branch: true
body: |
This is a PR to update the table for supported integration versions.
The supported versions markdown is generated from the minimum and maximum tested versions of each integration,
as defined from the `gemfile.lock` gem declarations.

Workflow run: [Generate Supported Versions](https://github.com/DataDog/dd-trace-rb/actions/workflows/generate-supported-versions.yml)

This should be tied to tracer releases, or triggered manually.

Loading