From 06c5b7a16ae8a2ca97f8854f49834ebb039001ee Mon Sep 17 00:00:00 2001 From: quinna-h Date: Tue, 28 Jan 2025 15:24:29 -0500 Subject: [PATCH 1/9] update supported versions script --- .github/scripts/generate_table_versions.rb | 23 ------------------- .../workflows/generate-supported-versions.yml | 7 +++--- 2 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 .github/scripts/generate_table_versions.rb diff --git a/.github/scripts/generate_table_versions.rb b/.github/scripts/generate_table_versions.rb deleted file mode 100644 index 958e54a53a8..00000000000 --- a/.github/scripts/generate_table_versions.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'json' - -input_file = 'gem_output.json' -output_file = 'integration_versions.md' - -data = JSON.parse(File.read(input_file)) - -comment = "# Integrations\n\n" -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 do |v| - v || "None" - end - "| #{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 diff --git a/.github/workflows/generate-supported-versions.yml b/.github/workflows/generate-supported-versions.yml index ae64be78c6f..e910586e96d 100644 --- a/.github/workflows/generate-supported-versions.yml +++ b/.github/workflows/generate-supported-versions.yml @@ -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 @@ -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. From ec535a85bc1a52c8197c18953f13f450d51faa61 Mon Sep 17 00:00:00 2001 From: quinna-h Date: Tue, 28 Jan 2025 15:25:21 -0500 Subject: [PATCH 2/9] consolidate generate table logic into existing script --- .github/scripts/find_gem_version_bounds.rb | 40 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/scripts/find_gem_version_bounds.rb b/.github/scripts/find_gem_version_bounds.rb index 6663c957182..4b83d464030 100644 --- a/.github/scripts/find_gem_version_bounds.rb +++ b/.github/scripts/find_gem_version_bounds.rb @@ -25,7 +25,7 @@ def process parse_gemfiles process_integrations include_hardcoded_versions - write_output + write_markdown_output end private @@ -131,10 +131,42 @@ 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 + + COMMENT + header = "| Integration | Ruby Min | Ruby Max | JRuby Min | JRuby Max |\n" + separator = "|--------------------------|----------|----------|-----------|-----------|\n" + column_widths = { + integration: 24, + ruby_min: 8, + ruby_max: 8, + jruby_min: 9, + jruby_max: 9 + } + rows = @integration_json_mapping.map do |name, versions| + integration_name = name.ljust(column_widths[:integration]) + ruby_min = (versions[0] || "None").ljust(column_widths[:ruby_min]) + ruby_max = (versions[1] || "None").ljust(column_widths[:ruby_max]) + jruby_min = (versions[2] || "None").ljust(column_widths[:jruby_min]) + jruby_max = (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 \ No newline at end of file From 50667d2b01dc4b1a6f70c3c8e8320e3f0077b470 Mon Sep 17 00:00:00 2001 From: quinna-h Date: Tue, 28 Jan 2025 16:29:28 -0500 Subject: [PATCH 3/9] update httpx and makara --- .github/scripts/find_gem_version_bounds.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/scripts/find_gem_version_bounds.rb b/.github/scripts/find_gem_version_bounds.rb index 4b83d464030..d8083cc2088 100644 --- a/.github/scripts/find_gem_version_bounds.rb +++ b/.github/scripts/find_gem_version_bounds.rb @@ -114,10 +114,10 @@ def include_hardcoded_versions # `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 @@ -138,6 +138,7 @@ def write_markdown_output ### 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 header = "| Integration | Ruby Min | Ruby Max | JRuby Min | JRuby Max |\n" @@ -149,12 +150,14 @@ def write_markdown_output jruby_min: 9, jruby_max: 9 } - rows = @integration_json_mapping.map do |name, versions| + 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]) - ruby_max = (versions[1] || "None").ljust(column_widths[:ruby_max]) + 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] || "None").ljust(column_widths[:jruby_max]) + 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 From f5a39a5a2b0fb611d8edb52f0a6a861a450d3c91 Mon Sep 17 00:00:00 2001 From: quinna-h Date: Wed, 29 Jan 2025 10:04:14 -0500 Subject: [PATCH 4/9] update columns --- .github/scripts/find_gem_version_bounds.rb | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/scripts/find_gem_version_bounds.rb b/.github/scripts/find_gem_version_bounds.rb index d8083cc2088..acfb0049fc3 100644 --- a/.github/scripts/find_gem_version_bounds.rb +++ b/.github/scripts/find_gem_version_bounds.rb @@ -106,10 +106,10 @@ 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` @@ -141,15 +141,27 @@ def write_markdown_output For a list of available integrations, and their supported version ranges, refer to the following: --> COMMENT - header = "| Integration | Ruby Min | Ruby Max | JRuby Min | JRuby Max |\n" - separator = "|--------------------------|----------|----------|-----------|-----------|\n" column_widths = { integration: 24, - ruby_min: 8, - ruby_max: 8, - jruby_min: 9, - jruby_max: 9 + 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(" | ") + " |" + separator = "|-" + adjusted_widths.map { |_, width| "-" * width }.join("-|-") + "-|" rows = @integration_json_mapping .sort_by { |name, _versions| name.downcase } .map do |name, versions| From add9483d0268927345c5e8ebb8088386056705d1 Mon Sep 17 00:00:00 2001 From: quinna-h Date: Wed, 29 Jan 2025 12:42:47 -0500 Subject: [PATCH 5/9] add validation --- .github/scripts/find_gem_version_bounds.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/scripts/find_gem_version_bounds.rb b/.github/scripts/find_gem_version_bounds.rb index acfb0049fc3..f4db063c358 100644 --- a/.github/scripts/find_gem_version_bounds.rb +++ b/.github/scripts/find_gem_version_bounds.rb @@ -6,6 +6,7 @@ lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'datadog' +require 'logger' class GemfileProcessor SPECIAL_CASES = { @@ -14,6 +15,14 @@ class GemfileProcessor EXCLUDED_INTEGRATIONS = ["configuration", "propagation", "utils"].freeze def initialize(directory: 'gemfiles/', contrib_dir: 'lib/datadog/tracing/contrib/') + logger = Logger.new($stdout) + unless Dir.exist?(directory) + logger.warn("Directory #{directory} does not exist") + end + + unless Dir.exist?(contrib_dir) + logger.warn("Directory #{contrib_dir} does not exist") + end @directory = directory @contrib_dir = contrib_dir @min_gems = { 'ruby' => {}, 'jruby' => {} } @@ -33,6 +42,7 @@ def process def parse_gemfiles(directory = 'gemfiles/') gemfiles = Dir.glob(File.join(@directory, '*')) + # Dir.exist?(gemfiles) # validate directory exists gemfiles.each do |gemfile_name| runtime = File.basename(gemfile_name).split('_').first # ruby or jruby next unless %w[ruby jruby].include?(runtime) From b0f21ac126776001a96c8be1544236340f33aefe Mon Sep 17 00:00:00 2001 From: quinna-h Date: Wed, 29 Jan 2025 12:48:22 -0500 Subject: [PATCH 6/9] rename script --- ...{find_gem_version_bounds.rb => update_supported_versions.rb} | 0 .github/workflows/generate-supported-versions.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/scripts/{find_gem_version_bounds.rb => update_supported_versions.rb} (100%) diff --git a/.github/scripts/find_gem_version_bounds.rb b/.github/scripts/update_supported_versions.rb similarity index 100% rename from .github/scripts/find_gem_version_bounds.rb rename to .github/scripts/update_supported_versions.rb diff --git a/.github/workflows/generate-supported-versions.yml b/.github/workflows/generate-supported-versions.yml index e910586e96d..9dcfc3e090e 100644 --- a/.github/workflows/generate-supported-versions.yml +++ b/.github/workflows/generate-supported-versions.yml @@ -24,7 +24,7 @@ jobs: ruby-version: "3.3" - name: Update latest - run: bundle exec ruby .github/scripts/find_gem_version_bounds.rb + run: bundle exec ruby .github/scripts/update_supported_versions.rb - run: git diff From 4362592e13260b7bf3c6b845c14f2fa97d4e3e51 Mon Sep 17 00:00:00 2001 From: quinna-h Date: Wed, 29 Jan 2025 13:23:02 -0500 Subject: [PATCH 7/9] add top level warn --- .github/scripts/update_supported_versions.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/scripts/update_supported_versions.rb b/.github/scripts/update_supported_versions.rb index f4db063c358..423960ef1df 100644 --- a/.github/scripts/update_supported_versions.rb +++ b/.github/scripts/update_supported_versions.rb @@ -6,7 +6,6 @@ lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'datadog' -require 'logger' class GemfileProcessor SPECIAL_CASES = { @@ -15,13 +14,12 @@ class GemfileProcessor EXCLUDED_INTEGRATIONS = ["configuration", "propagation", "utils"].freeze def initialize(directory: 'gemfiles/', contrib_dir: 'lib/datadog/tracing/contrib/') - logger = Logger.new($stdout) unless Dir.exist?(directory) - logger.warn("Directory #{directory} does not exist") + warn("Directory #{directory} does not exist") end unless Dir.exist?(contrib_dir) - logger.warn("Directory #{contrib_dir} does not exist") + warn("Directory #{contrib_dir} does not exist") end @directory = directory @contrib_dir = contrib_dir From bfa69536cec61f47521f0c01d5f9771665be7254 Mon Sep 17 00:00:00 2001 From: quinna-h Date: Wed, 29 Jan 2025 14:54:18 -0500 Subject: [PATCH 8/9] update comment in markdown --- .github/scripts/update_supported_versions.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/scripts/update_supported_versions.rb b/.github/scripts/update_supported_versions.rb index 423960ef1df..7e68016e5d7 100644 --- a/.github/scripts/update_supported_versions.rb +++ b/.github/scripts/update_supported_versions.rb @@ -143,6 +143,9 @@ def write_markdown_output output_file = 'docs/integration_versions.md' comment = <<~COMMENT