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

Merged
merged 46 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3f4560a
add supported version script and table
quinna-h Dec 9, 2024
1980b6f
update script
quinna-h Dec 9, 2024
1b2986e
rubocop lint
quinna-h Dec 9, 2024
5bee321
modify script locations, add description to md table
quinna-h Dec 11, 2024
b2818a9
improve table output
quinna-h Dec 11, 2024
53b807f
wip
quinna-h Dec 11, 2024
df5640a
refactor code
quinna-h Dec 18, 2024
2b15400
wip
quinna-h Dec 18, 2024
112db1f
Merge branch 'master' into quinna.halim/add-supported-versions-table
quinna-h Dec 18, 2024
3b5aae2
add supported versions
quinna-h Dec 18, 2024
4ada6cf
add branch for testing
quinna-h Dec 18, 2024
b4526e2
remove json to avoid merge conflict issues
quinna-h Dec 18, 2024
d44249b
update PR body
quinna-h Dec 19, 2024
514be2c
Update .github/scripts/generate_table_versions.rb
quinna-h Dec 20, 2024
65aee38
switch to use gem declarations instead of hardcoded mappings
quinna-h Dec 23, 2024
6fb1de7
linting checks
quinna-h Dec 23, 2024
3b8cff4
cleanup comments
quinna-h Dec 24, 2024
c45330a
refactor code
quinna-h Dec 26, 2024
589bccc
cleanup code
quinna-h Dec 26, 2024
49ce6a8
Merge branch 'master' into quinna.halim/add-supported-versions-table
quinna-h Dec 30, 2024
d015ca2
Combine duplicate option table rows
soulcutter Dec 30, 2024
c24490f
Enable type checking for AgentSettingsResolver/AgentSettings
ivoanjo Jan 2, 2025
7796a9e
Move url building behavior from `AgentBaseUrl` to `AgentSettings`
ivoanjo Jan 2, 2025
2f824ff
Refactor crashtracking to use `AgentSettings#url`
ivoanjo Jan 2, 2025
2716176
[PROF-11078] Fix profiling exception when agent url is an ipv6 address
ivoanjo Jan 2, 2025
e8d7381
Implement `==` for new `AgentSettings` class
ivoanjo Jan 2, 2025
3750e4e
use Ruby 3.4.1 for test-memcheck GHA
anmarchenko Jan 2, 2025
9112473
Update exceptions file with another variant of thread creation memory…
ivoanjo Jan 2, 2025
9daf9a0
Introduce Ruby 3.5 gemfile variant for testing with dev builds
ivoanjo Jan 2, 2025
828f75e
Update list of files used to compute cache checksum
ivoanjo Jan 2, 2025
ae5d2a3
Bump Ruby 3.4 integration image to stable version
ivoanjo Jan 2, 2025
2e10ee4
Remove workaround for strscan issue
ivoanjo Jan 2, 2025
1f4afdc
Add unsafe api calls checker to track down issues such as #4195
ivoanjo Dec 19, 2024
33fc72f
Fix going into Ruby code when looking up otel context
ivoanjo Dec 19, 2024
f200a83
Avoid trying to sample allocations when VM is raising exception
ivoanjo Dec 19, 2024
3dfd113
Update tests with new signatures for test methods
ivoanjo Dec 19, 2024
092fa93
Check if symbol is static before calling SYM2ID on it
ivoanjo Dec 19, 2024
45c7dbe
Document that unsafe api calls checker is only for test code
ivoanjo Dec 19, 2024
4f6eb84
Add 3.4 support
sarahchen6 Jan 2, 2025
831f89f
Update DevelopmentGuide
sarahchen6 Jan 2, 2025
a62ee88
Remove `racc` gem from 3.3 and 3.4 appraisal files
sarahchen6 Jan 2, 2025
f544d4a
[🤖] Lock Dependency: https://github.com/DataDog/dd-trace-rb/actions/r…
ivoanjo Jan 3, 2025
da2860a
Remove strscan specification in 3.4 gemfile
sarahchen6 Jan 2, 2025
d1f47ad
[🤖] Lock Dependency: https://github.com/DataDog/dd-trace-rb/actions/r…
ivoanjo Jan 3, 2025
cb788d7
add hardcoded
quinna-h Jan 7, 2025
3f1112e
Merge branch 'master' into quinna.halim/add-supported-versions-table
quinna-h Jan 8, 2025
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
149 changes: 149 additions & 0 deletions .github/scripts/find_gem_version_bounds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
require 'pathname'
require 'rubygems'
require 'json'
require 'bundler'

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'datadog'

class GemfileProcessor
SPECIAL_CASES = {
"opensearch" => "OpenSearch" # special case because opensearch = OpenSearch not Opensearch
}.freeze
EXCLUDED_INTEGRATIONS = ["configuration", "propagation", "utils"].freeze

def initialize(directory: 'gemfiles/', contrib_dir: 'lib/datadog/tracing/contrib/')
@directory = directory
@contrib_dir = contrib_dir
@min_gems = { 'ruby' => {}, 'jruby' => {} }
@max_gems = { 'ruby' => {}, 'jruby' => {} }
@integration_json_mapping = {}
end

def process
parse_gemfiles
process_integrations
include_hardcoded_versions
write_output
end

private


def parse_gemfiles(directory = 'gemfiles/')
gemfiles = Dir.glob(File.join(@directory, '*'))
gemfiles.each do |gemfile_name|
runtime = File.basename(gemfile_name).split('_').first # ruby or jruby
next unless %w[ruby jruby].include?(runtime)
# parse the gemfile
if gemfile_name.end_with?(".gemfile")
process_gemfile(gemfile_name, runtime)
elsif gemfile_name.end_with?('.gemfile.lock')
process_lockfile(gemfile_name, runtime)
end
end

end

def process_gemfile(gemfile_name, runtime)
begin
quinna-h marked this conversation as resolved.
Show resolved Hide resolved
definition = Bundler::Definition.build(gemfile_name, nil, nil)
definition.dependencies.each do |dependency|
gem_name = dependency.name
version = dependency.requirement.to_s
update_gem_versions(runtime, gem_name, version)
end
rescue Bundler::GemfileError => e
puts "Error reading Gemfile: #{e.message}"
end
end

def process_lockfile(gemfile_name, runtime)
lockfile_contents = File.read(gemfile_name)
parser = Bundler::LockfileParser.new(lockfile_contents)
parser.specs.each do |spec|
gem_name = spec.name
version = spec.version.to_s
update_gem_versions(runtime, gem_name, version)
end
end

def update_gem_versions(runtime, gem_name, version)
return unless version_valid?(version)

gem_version = Gem::Version.new(version)

# Update minimum gems
if @min_gems[runtime][gem_name].nil? || gem_version < Gem::Version.new(@min_gems[runtime][gem_name])
@min_gems[runtime][gem_name] = version
end

# Update maximum gems
if @max_gems[runtime][gem_name].nil? || gem_version > Gem::Version.new(@max_gems[runtime][gem_name])
@max_gems[runtime][gem_name] = version
end
end

# Helper: Validate the version format
def version_valid?(version)
return false if version.nil? || version.strip.empty?

Gem::Version.new(version)
true
rescue ArgumentError
false
end


def process_integrations
integrations = Datadog::Tracing::Contrib::REGISTRY.map(&:name).map(&:to_s)
integrations.each do |integration|
next if EXCLUDED_INTEGRATIONS.include?(integration)

integration_name = resolve_integration_name(integration)

@integration_json_mapping[integration] = [
@min_gems['ruby'][integration_name],
@max_gems['ruby'][integration_name],
@min_gems['jruby'][integration_name],
@max_gems['jruby'][integration_name]
]
end
end

def include_hardcoded_versions
# `httpx` is maintained externally
@integration_json_mapping['httpx'] = [
'0.11', # Min version Ruby
'0.11', # Max version Ruby
nil, # Min version JRuby
nil # Max version JRuby
]

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

def resolve_integration_name(integration)
mod_name = SPECIAL_CASES[integration] || integration.split('_').map(&:capitalize).join
module_name = "Datadog::Tracing::Contrib::#{mod_name}"
integration_module = Object.const_get(module_name)::Integration
integration_module.respond_to?(:gem_name) ? integration_module.gem_name : integration
rescue NameError, NoMethodError
puts "Fallback for #{integration}: module or gem_name not found."
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))
end
end

GemfileProcessor.new.process
21 changes: 21 additions & 0 deletions .github/scripts/generate_table_versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 { |v| v || "None" }
"| #{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
49 changes: 49 additions & 0 deletions .github/workflows/generate-supported-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Generate Supported Versions"

on:
workflow_dispatch:


concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs bundle install
ruby-version: "3.3"

- 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
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GHA_PAT }}
branch: auto-generate/update-supported-versions
title: '[🤖] Update Supported Versions'
base: master
labels: dev/internal, integrations
commit-message: "Test creating supported versions"
delete-branch: true
body: |
This is a PR to update the table for supported integration versions.
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.

3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/action_cable/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :action_cable, auto_patch: false
def self.gem_name
'actioncable'
end

def self.version
Gem.loaded_specs['actioncable'] && Gem.loaded_specs['actioncable'].version
Expand Down
4 changes: 4 additions & 0 deletions lib/datadog/tracing/contrib/action_mailer/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class Integration
# @public_api Changing the integration name or integration options can cause breaking changes
register_as :action_mailer, auto_patch: false

def self.gem_name
'actionmailer'
end

def self.version
Gem.loaded_specs['actionmailer'] && Gem.loaded_specs['actionmailer'].version
end
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/action_pack/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :action_pack, auto_patch: false
def self.gem_name
'actionpack'
end

def self.version
Gem.loaded_specs['actionpack'] && Gem.loaded_specs['actionpack'].version
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/action_view/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :action_view, auto_patch: false
def self.gem_name
'actionview'
end

def self.version
# ActionView is its own gem in Rails 4.1+
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/active_job/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :active_job, auto_patch: false
def self.gem_name
'activejob'
end

def self.version
Gem.loaded_specs['activejob'] && Gem.loaded_specs['activejob'].version
Expand Down
4 changes: 4 additions & 0 deletions lib/datadog/tracing/contrib/active_record/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Integration
# @public_api Changing the integration name or integration options can cause breaking changes
register_as :active_record, auto_patch: false

def self.gem_name
'activerecord'
end

def self.version
Gem.loaded_specs['activerecord'] && Gem.loaded_specs['activerecord'].version
end
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/active_support/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :active_support, auto_patch: false
def self.gem_name
'activesupport'
end

def self.version
Gem.loaded_specs['activesupport'] && Gem.loaded_specs['activesupport'].version
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/aws/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :aws, auto_patch: true
def self.gem_name
'aws-sdk-core'
end

def self.version
if Gem.loaded_specs['aws-sdk']
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/concurrent_ruby/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :concurrent_ruby
def self.gem_name
'concurrent-ruby'
end

def self.version
Gem.loaded_specs['concurrent-ruby'] && Gem.loaded_specs['concurrent-ruby'].version
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/httprb/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :httprb
def self.gem_name
'http'
end

def self.version
Gem.loaded_specs['http'] && Gem.loaded_specs['http'].version
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/kafka/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :kafka, auto_patch: false
def self.gem_name
'ruby-kafka'
end

def self.version
Gem.loaded_specs['ruby-kafka'] && Gem.loaded_specs['ruby-kafka'].version
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/mongodb/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :mongo, auto_patch: true
def self.gem_name
'mongo'
end

def self.version
Gem.loaded_specs['mongo'] && Gem.loaded_specs['mongo'].version
quinna-h marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/opensearch/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :opensearch, auto_patch: true
def self.gem_name
'opensearch-ruby'
end

def self.version
Gem.loaded_specs['opensearch-ruby'] \
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/presto/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :presto
def self.gem_name
'presto-client'
end

def self.version
Gem.loaded_specs['presto-client'] && Gem.loaded_specs['presto-client'].version
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/tracing/contrib/rest_client/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Integration

# @public_api Changing the integration name or integration options can cause breaking changes
register_as :rest_client
def self.gem_name
'rest-client'
end

def self.version
Gem.loaded_specs['rest-client'] && Gem.loaded_specs['rest-client'].version
Expand Down
Loading