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

add supported versions workflow #4210

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
138 changes: 138 additions & 0 deletions find_min_gemfile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
require 'pathname'
require 'rubygems'
require 'json'

def parse_gemfiles(directory = 'gemfiles/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Code Quality Violation

Avoid top-level methods definition. Organize methods in modules/classes. (...read more)

This rule emphasizes the importance of organizing methods within modules or classes in Ruby. In Ruby, it's considered a best practice to wrap methods within classes or modules. This is because it helps in grouping related methods together, which in turn makes the code easier to understand, maintain, and reuse.

Not adhering to this rule can lead to a disorganized codebase, making it hard for other developers to understand and maintain the code. It can also lead to potential name clashes if a method is defined in the global scope.

To avoid violating this rule, always define your methods within a class or a module. For example, instead of writing def some_method; end, you should write class SomeClass def some_method; end end. This not only adheres to the rule but also improves the readability and maintainability of your code.

View in Datadog  Leave us feedback  Documentation

parsed_gems_ruby = {}
parsed_gems_jruby = {}

gemfiles = Dir.glob(File.join(directory, '*'))
gemfiles.each do |gemfile_name|
runtime = File.basename(gemfile_name).split('_').first # ruby or jruby
# puts "Runtime: #{runtime}"
File.foreach(gemfile_name) do |line|
if (gem_details = parse_gemfile_entry(line))
gem_name, version = gem_details
elsif (gem_details = parse_gemfile_lock_entry(line))
gem_name, version = gem_details
else
next
end

# Validate and store the minimum version
if version_valid?(version)
if runtime == 'ruby'
if parsed_gems_ruby[gem_name].nil? || Gem::Version.new(version) < Gem::Version.new(parsed_gems_ruby[gem_name])
parsed_gems_ruby[gem_name] = version
end
end
if runtime == 'jruby'
if parsed_gems_jruby[gem_name].nil? || Gem::Version.new(version) < Gem::Version.new(parsed_gems_jruby[gem_name])
parsed_gems_jruby[gem_name] = version
end
end
else
next
end
end
end

[parsed_gems_ruby, parsed_gems_jruby]
end

# Helper: Parse a Gemfile-style gem declaration
# ex. gem 'ruby-kafka', '~> 5.0'
def parse_gemfile_entry(line)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Code Quality Violation

Avoid top-level methods definition. Organize methods in modules/classes. (...read more)

This rule emphasizes the importance of organizing methods within modules or classes in Ruby. In Ruby, it's considered a best practice to wrap methods within classes or modules. This is because it helps in grouping related methods together, which in turn makes the code easier to understand, maintain, and reuse.

Not adhering to this rule can lead to a disorganized codebase, making it hard for other developers to understand and maintain the code. It can also lead to potential name clashes if a method is defined in the global scope.

To avoid violating this rule, always define your methods within a class or a module. For example, instead of writing def some_method; end, you should write class SomeClass def some_method; end end. This not only adheres to the rule but also improves the readability and maintainability of your code.

View in Datadog  Leave us feedback  Documentation

if (match = line.match(/^\s*gem\s+["']([^"']+)["']\s*,?\s*["']?([^"']*)["']?/))
gem_name, version_constraint = match[1], match[2]
version = extract_version(version_constraint)
[gem_name, version]
end
end

# Helper: Parse a Gemfile.lock-style entry
# matches on ex. actionmailer (= 6.0.6)
def parse_gemfile_lock_entry(line)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Code Quality Violation

Avoid top-level methods definition. Organize methods in modules/classes. (...read more)

This rule emphasizes the importance of organizing methods within modules or classes in Ruby. In Ruby, it's considered a best practice to wrap methods within classes or modules. This is because it helps in grouping related methods together, which in turn makes the code easier to understand, maintain, and reuse.

Not adhering to this rule can lead to a disorganized codebase, making it hard for other developers to understand and maintain the code. It can also lead to potential name clashes if a method is defined in the global scope.

To avoid violating this rule, always define your methods within a class or a module. For example, instead of writing def some_method; end, you should write class SomeClass def some_method; end end. This not only adheres to the rule but also improves the readability and maintainability of your code.

View in Datadog  Leave us feedback  Documentation

if (match = line.match(/^\s*([a-z0-9_-]+)\s+\(([^)]+)\)/))
[match[1], match[2]]
end
end

# Helper: Validate the version format
def version_valid?(version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Code Quality Violation

Avoid top-level methods definition. Organize methods in modules/classes. (...read more)

This rule emphasizes the importance of organizing methods within modules or classes in Ruby. In Ruby, it's considered a best practice to wrap methods within classes or modules. This is because it helps in grouping related methods together, which in turn makes the code easier to understand, maintain, and reuse.

Not adhering to this rule can lead to a disorganized codebase, making it hard for other developers to understand and maintain the code. It can also lead to potential name clashes if a method is defined in the global scope.

To avoid violating this rule, always define your methods within a class or a module. For example, instead of writing def some_method; end, you should write class SomeClass def some_method; end end. This not only adheres to the rule but also improves the readability and maintainability of your code.

View in Datadog  Leave us feedback  Documentation

version =~ /^\d+(\.\d+)*$/
end

# Helper: Extract the actual version number from a constraint
# Matches on the following version patterns:
# 1. "pessimistic" versions, ex. '~> 1.2.3'
# 2. '>= 1.2.3'
# 3. 1.2.3
def extract_version(constraint)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Code Quality Violation

Avoid top-level methods definition. Organize methods in modules/classes. (...read more)

This rule emphasizes the importance of organizing methods within modules or classes in Ruby. In Ruby, it's considered a best practice to wrap methods within classes or modules. This is because it helps in grouping related methods together, which in turn makes the code easier to understand, maintain, and reuse.

Not adhering to this rule can lead to a disorganized codebase, making it hard for other developers to understand and maintain the code. It can also lead to potential name clashes if a method is defined in the global scope.

To avoid violating this rule, always define your methods within a class or a module. For example, instead of writing def some_method; end, you should write class SomeClass def some_method; end end. This not only adheres to the rule but also improves the readability and maintainability of your code.

View in Datadog  Leave us feedback  Documentation

if constraint =~ /~>\s*([\d.]+(?:[-.\w]*))| # Handles ~> constraints
>=\s*([\d.]+(?:[-.\w]*))| # Handles >= constraints
([\d.]+(?:[-.\w]*)) # Handles plain versions
/x
Regexp.last_match(1) || Regexp.last_match(2) || Regexp.last_match(3)
end
end

def get_integration_names(directory = 'lib/datadog/tracing/contrib/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Code Quality Violation

Avoid top-level methods definition. Organize methods in modules/classes. (...read more)

This rule emphasizes the importance of organizing methods within modules or classes in Ruby. In Ruby, it's considered a best practice to wrap methods within classes or modules. This is because it helps in grouping related methods together, which in turn makes the code easier to understand, maintain, and reuse.

Not adhering to this rule can lead to a disorganized codebase, making it hard for other developers to understand and maintain the code. It can also lead to potential name clashes if a method is defined in the global scope.

To avoid violating this rule, always define your methods within a class or a module. For example, instead of writing def some_method; end, you should write class SomeClass def some_method; end end. This not only adheres to the rule but also improves the readability and maintainability of your code.

View in Datadog  Leave us feedback  Documentation

unless Dir.exist?(directory)
puts "Directory '#{directory}' not found!"
return []
end

# Get all subdirectories inside the specified directory
Dir.children(directory).select do |entry|
File.directory?(File.join(directory, entry))
end
end

mapping = {
"action_mailer" => "actionmailer",
"opensearch" => "opensearch-ruby",
"concurrent_ruby" => "concurrent-ruby",
"action_view" => "actionview",
"action_cable" => "actioncable",
"active_record" => "activerecord",
"mongodb" => "mongo",
"rest_client" => "rest-client",
"active_support" => "activesupport",
"action_pack" => "actionpack",
"active_job" => "activejob",
"httprb" => "http",
"kafka" => "ruby-kafka",
"presto" => "presto-client",
"aws" => "aws-sdk-core"
}

excluded = ["configuration", "propagation", "utils"]
parsed_gems_ruby, parsed_gems_jruby = parse_gemfiles("gemfiles/")
integrations = get_integration_names('lib/datadog/tracing/contrib/')

integration_json_mapping = {}

integrations.each do |integration|
if excluded.include?(integration)
next
end
# puts "integration: #{integration}"
integration_name = mapping[integration] || integration

min_version_jruby = parsed_gems_jruby[integration_name]
min_version_ruby = parsed_gems_ruby[integration_name]

# if min_version_ruby
# puts "minimum version of gem '#{integration_name} for Ruby': #{min_version_ruby}"
# end
# if min_version_jruby
# puts "minimum version of gem '#{integration_name} for JRuby': #{min_version_jruby}"
# end

# mapping jruby, ruby
integration_json_mapping[integration] = [min_version_ruby, min_version_jruby]
integration_json_mapping.replace(integration_json_mapping.sort.to_h)
end

File.write("minimum_gem_output.json", JSON.pretty_generate(integration_json_mapping))
21 changes: 21 additions & 0 deletions generate_table_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import json
import pandas as pd

input_file = 'minimum_gem_output.json'
with open(input_file, 'r') as file:
data = json.load(file)

rows = []
for integration_name, versions in data.items():
ruby_min, jruby_min = versions
rows.append({"Integration": integration_name, "Ruby Min": ruby_min, "JRuby Min": jruby_min})

df = pd.DataFrame(rows)

output_file = 'integration_versions.md'

with open(output_file, 'w') as md_file:
md_file.write("| Integration | Ruby Min | JRuby Min |\n")
md_file.write("|-------------|-----------|----------|\n")
for _, row in df.iterrows():
md_file.write(f"| {row['Integration']} | {row['Ruby Min']} | {row['JRuby Min']} |\n")
50 changes: 50 additions & 0 deletions integration_versions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
| Integration | Ruby Min | JRuby Min |
|-------------|-----------|----------|
| action_cable | 5.2.8.1 | 5.2.8.1 |
| action_mailer | 4.2.11.3 | 5.2.8.1 |
| action_pack | 4.2.11.3 | 5.2.8.1 |
| action_view | 4.2.11.3 | 5.2.8.1 |
| active_job | 4.2.11.3 | 5.2.8.1 |
| active_model_serializers | 0.10.0 | 0.10.0 |
| active_record | 4.2.11.3 | 5 |
| active_support | 4.2.11.3 | 5 |
| aws | 3.181.0 | 3.181.0 |
| concurrent_ruby | 1.2.2 | 1.1.10 |
| dalli | 2.7.11 | 2.7.11 |
| delayed_job | 4.1.11 | 4.1.11 |
| elasticsearch | 7 | 7 |
| ethon | 0.16.0 | 0.14.0 |
| excon | 0.102.0 | 0.102.0 |
| faraday | 0.17 | 0.17 |
| grape | 1.7.0 | 1.7.0 |
| graphql | 1.13.0 | 1.13.0 |
| grpc | 1.38.0 | None |
| hanami | 1 | None |
| http | 5.0.1 | 4 |
| httpclient | 2.8.3 | 2.8.3 |
| httprb | 5.0.1 | 4 |
| kafka | 0.7.10 | 0.7.10 |
| lograge | 0.11 | 0.11 |
| mongodb | 2.8.0 | 2.8.0 |
| mysql2 | 0.5 | None |
| opensearch | 2 | 2 |
| pg | 0.18.4 | None |
| presto | 0.5.14 | 0.5.14 |
| que | 1.0.0 | 1.0.0 |
| racecar | 0.3.5 | 0.3.5 |
| rack | 1 | 1 |
| rails | 4.2.11.3 | 5.2.1 |
| rake | 10.5 | 10.5 |
| redis | 3 | 3 |
| resque | 2.0 | 2.0 |
| rest_client | 2.1.0 | 2.1.0 |
| roda | 2.0.0 | 2.0.0 |
| semantic_logger | 4.0 | 4.0 |
| sequel | 5.83.1 | 5.83.1 |
| shoryuken | 6.0.0 | 6.0.0 |
| sidekiq | 5.2.8 | 6.1.2 |
| sinatra | 2 | 2 |
| sneakers | 2.12.0 | 2.12.0 |
| stripe | 5.15.0 | 5.15.0 |
| sucker_punch | 3.1.0 | 3.1.0 |
| trilogy | 2.6.0 | None |
Loading
Loading