diff --git a/.standard_todo.yml b/.standard_todo.yml index 15b48418..6c3441cc 100644 --- a/.standard_todo.yml +++ b/.standard_todo.yml @@ -2,6 +2,8 @@ # Remove from this list as you refactor files. --- ignore: +- lib/datadog/ci/contrib/minitest/integration.rb: + - Style/SafeNavigation - lib/datadog/ci/contrib/cucumber/integration.rb: - Style/SafeNavigation - lib/datadog/ci/contrib/rspec/integration.rb: diff --git a/Appraisals b/Appraisals index ec69fe95..83dcef77 100644 --- a/Appraisals +++ b/Appraisals @@ -83,6 +83,14 @@ def self.with_cucumber_gem(versions:) end end +def self.with_minitest_gem(versions: 5) + Array(versions).each do |v| + appraise "minitest-#{v}" do + gem "minitest", "~> #{v}" + end + end +end + # WIP: Support cucumber 8 # | Cucumber | Ruby required | @@ -111,15 +119,19 @@ elsif ruby_version?("2.6") with_rspec_gem with_cucumber_gem(versions: 3..7) elsif ruby_version?("2.7") + with_minitest_gem with_rspec_gem with_cucumber_gem(versions: 3..7) elsif ruby_version?("3.0") + with_minitest_gem with_rspec_gem with_cucumber_gem(versions: 3..7) elsif ruby_version?("3.1") + with_minitest_gem with_rspec_gem with_cucumber_gem(versions: 3..7) elsif ruby_version?("3.2") + with_minitest_gem with_rspec_gem with_cucumber_gem(versions: 3..7) end diff --git a/Rakefile b/Rakefile index 561ea10b..4967616d 100644 --- a/Rakefile +++ b/Rakefile @@ -34,7 +34,8 @@ namespace :spec do # Datadog CI integrations [ :cucumber, - :rspec + :rspec, + :minitest ].each do |contrib| RSpec::Core::RakeTask.new(contrib) do |t, args| t.pattern = "spec/datadog/ci/contrib/#{contrib}/**/*_spec.rb" @@ -94,4 +95,7 @@ task :ci do declare "❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ jruby" => "bundle exec appraisal cucumber-6 rake spec:cucumber" declare "❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ jruby" => "bundle exec appraisal cucumber-7 rake spec:cucumber" # declare "❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ❌ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ jruby" => "bundle exec appraisal cucumber-8 rake spec:cucumber" + + # Minitest + declare "❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ❌ 2.5 / ❌ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ jruby" => "bundle exec appraisal minitest-5 rake spec:minitest" end diff --git a/gemfiles/jruby_9.4.0.0_minitest_5.gemfile b/gemfiles/jruby_9.4.0.0_minitest_5.gemfile new file mode 100644 index 00000000..130a7ef0 --- /dev/null +++ b/gemfiles/jruby_9.4.0.0_minitest_5.gemfile @@ -0,0 +1,22 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "pry" +gem "rake" +gem "rspec" +gem "os" +gem "climate_control" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "standard", "<= 1.24.3" +gem "yard" +gem "webrick" +gem "minitest", "~> 5" + +group :check do + +end + +gemspec path: "../" diff --git a/gemfiles/jruby_9.4.0.0_minitest_5.gemfile.lock b/gemfiles/jruby_9.4.0.0_minitest_5.gemfile.lock new file mode 100644 index 00000000..153585b6 --- /dev/null +++ b/gemfiles/jruby_9.4.0.0_minitest_5.gemfile.lock @@ -0,0 +1,110 @@ +PATH + remote: .. + specs: + datadog-ci (0.1.0) + ddtrace (~> 1) + +GEM + remote: https://rubygems.org/ + specs: + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + climate_control (1.2.0) + coderay (1.1.3) + ddtrace (1.13.1) + debase-ruby_core_source (= 3.2.1) + libdatadog (~> 3.0.0.1.0) + libddwaf (~> 1.9.0.0.0) + msgpack + debase-ruby_core_source (3.2.1) + diff-lcs (1.5.0) + ffi (1.15.5-java) + json (2.6.3-java) + language_server-protocol (3.17.0.3) + libdatadog (3.0.0.1.0) + libddwaf (1.9.0.0.1-java) + ffi (~> 1.0) + method_source (1.0.0) + minitest (5.19.0) + msgpack (1.7.2-java) + os (1.1.4) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2-java) + coderay (~> 1.1) + method_source (~> 1.0) + spoon (~> 0.0) + racc (1.7.1-java) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.8.1) + rexml (3.2.6) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-collection_matchers (1.2.0) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.44.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.24.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-performance (1.15.2) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) + spoon (0.0.6) + ffi + standard (1.24.3) + language_server-protocol (~> 3.17.0.2) + rubocop (= 1.44.1) + rubocop-performance (= 1.15.2) + thor (1.2.2) + unicode-display_width (2.4.2) + webrick (1.8.1) + yard (0.9.34) + +PLATFORMS + universal-java-11 + +DEPENDENCIES + appraisal + climate_control + datadog-ci! + minitest (~> 5) + os + pry + rake + rspec + rspec-collection_matchers + rspec_junit_formatter + standard (<= 1.24.3) + webrick + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_2.7.6_minitest_5.gemfile b/gemfiles/ruby_2.7.6_minitest_5.gemfile new file mode 100644 index 00000000..130a7ef0 --- /dev/null +++ b/gemfiles/ruby_2.7.6_minitest_5.gemfile @@ -0,0 +1,22 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "pry" +gem "rake" +gem "rspec" +gem "os" +gem "climate_control" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "standard", "<= 1.24.3" +gem "yard" +gem "webrick" +gem "minitest", "~> 5" + +group :check do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_2.7.6_minitest_5.gemfile.lock b/gemfiles/ruby_2.7.6_minitest_5.gemfile.lock new file mode 100644 index 00000000..944feceb --- /dev/null +++ b/gemfiles/ruby_2.7.6_minitest_5.gemfile.lock @@ -0,0 +1,107 @@ +PATH + remote: .. + specs: + datadog-ci (0.1.0) + ddtrace (~> 1) + +GEM + remote: https://rubygems.org/ + specs: + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + climate_control (1.2.0) + coderay (1.1.3) + ddtrace (1.13.1) + debase-ruby_core_source (= 3.2.1) + libdatadog (~> 3.0.0.1.0) + libddwaf (~> 1.9.0.0.0) + msgpack + debase-ruby_core_source (3.2.1) + diff-lcs (1.5.0) + ffi (1.15.5) + json (2.6.3) + language_server-protocol (3.17.0.3) + libdatadog (3.0.0.1.0-aarch64-linux) + libddwaf (1.9.0.0.1-aarch64-linux) + ffi (~> 1.0) + method_source (1.0.0) + minitest (5.19.0) + msgpack (1.7.2) + os (1.1.4) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.8.1) + rexml (3.2.6) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-collection_matchers (1.2.0) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.44.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.24.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-performance (1.15.2) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) + standard (1.24.3) + language_server-protocol (~> 3.17.0.2) + rubocop (= 1.44.1) + rubocop-performance (= 1.15.2) + thor (1.2.2) + unicode-display_width (2.4.2) + webrick (1.8.1) + yard (0.9.34) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + climate_control + datadog-ci! + minitest (~> 5) + os + pry + rake + rspec + rspec-collection_matchers + rspec_junit_formatter + standard (<= 1.24.3) + webrick + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_3.0.4_minitest_5.gemfile b/gemfiles/ruby_3.0.4_minitest_5.gemfile new file mode 100644 index 00000000..130a7ef0 --- /dev/null +++ b/gemfiles/ruby_3.0.4_minitest_5.gemfile @@ -0,0 +1,22 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "pry" +gem "rake" +gem "rspec" +gem "os" +gem "climate_control" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "standard", "<= 1.24.3" +gem "yard" +gem "webrick" +gem "minitest", "~> 5" + +group :check do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.0.4_minitest_5.gemfile.lock b/gemfiles/ruby_3.0.4_minitest_5.gemfile.lock new file mode 100644 index 00000000..944feceb --- /dev/null +++ b/gemfiles/ruby_3.0.4_minitest_5.gemfile.lock @@ -0,0 +1,107 @@ +PATH + remote: .. + specs: + datadog-ci (0.1.0) + ddtrace (~> 1) + +GEM + remote: https://rubygems.org/ + specs: + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + climate_control (1.2.0) + coderay (1.1.3) + ddtrace (1.13.1) + debase-ruby_core_source (= 3.2.1) + libdatadog (~> 3.0.0.1.0) + libddwaf (~> 1.9.0.0.0) + msgpack + debase-ruby_core_source (3.2.1) + diff-lcs (1.5.0) + ffi (1.15.5) + json (2.6.3) + language_server-protocol (3.17.0.3) + libdatadog (3.0.0.1.0-aarch64-linux) + libddwaf (1.9.0.0.1-aarch64-linux) + ffi (~> 1.0) + method_source (1.0.0) + minitest (5.19.0) + msgpack (1.7.2) + os (1.1.4) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.8.1) + rexml (3.2.6) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-collection_matchers (1.2.0) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.44.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.24.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-performance (1.15.2) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) + standard (1.24.3) + language_server-protocol (~> 3.17.0.2) + rubocop (= 1.44.1) + rubocop-performance (= 1.15.2) + thor (1.2.2) + unicode-display_width (2.4.2) + webrick (1.8.1) + yard (0.9.34) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + climate_control + datadog-ci! + minitest (~> 5) + os + pry + rake + rspec + rspec-collection_matchers + rspec_junit_formatter + standard (<= 1.24.3) + webrick + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_3.1.2_minitest_5.gemfile b/gemfiles/ruby_3.1.2_minitest_5.gemfile new file mode 100644 index 00000000..130a7ef0 --- /dev/null +++ b/gemfiles/ruby_3.1.2_minitest_5.gemfile @@ -0,0 +1,22 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "pry" +gem "rake" +gem "rspec" +gem "os" +gem "climate_control" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "standard", "<= 1.24.3" +gem "yard" +gem "webrick" +gem "minitest", "~> 5" + +group :check do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.1.2_minitest_5.gemfile.lock b/gemfiles/ruby_3.1.2_minitest_5.gemfile.lock new file mode 100644 index 00000000..944feceb --- /dev/null +++ b/gemfiles/ruby_3.1.2_minitest_5.gemfile.lock @@ -0,0 +1,107 @@ +PATH + remote: .. + specs: + datadog-ci (0.1.0) + ddtrace (~> 1) + +GEM + remote: https://rubygems.org/ + specs: + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + climate_control (1.2.0) + coderay (1.1.3) + ddtrace (1.13.1) + debase-ruby_core_source (= 3.2.1) + libdatadog (~> 3.0.0.1.0) + libddwaf (~> 1.9.0.0.0) + msgpack + debase-ruby_core_source (3.2.1) + diff-lcs (1.5.0) + ffi (1.15.5) + json (2.6.3) + language_server-protocol (3.17.0.3) + libdatadog (3.0.0.1.0-aarch64-linux) + libddwaf (1.9.0.0.1-aarch64-linux) + ffi (~> 1.0) + method_source (1.0.0) + minitest (5.19.0) + msgpack (1.7.2) + os (1.1.4) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.8.1) + rexml (3.2.6) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-collection_matchers (1.2.0) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.44.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.24.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-performance (1.15.2) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) + standard (1.24.3) + language_server-protocol (~> 3.17.0.2) + rubocop (= 1.44.1) + rubocop-performance (= 1.15.2) + thor (1.2.2) + unicode-display_width (2.4.2) + webrick (1.8.1) + yard (0.9.34) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + climate_control + datadog-ci! + minitest (~> 5) + os + pry + rake + rspec + rspec-collection_matchers + rspec_junit_formatter + standard (<= 1.24.3) + webrick + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_3.2.0_minitest_5.gemfile b/gemfiles/ruby_3.2.0_minitest_5.gemfile new file mode 100644 index 00000000..130a7ef0 --- /dev/null +++ b/gemfiles/ruby_3.2.0_minitest_5.gemfile @@ -0,0 +1,22 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "pry" +gem "rake" +gem "rspec" +gem "os" +gem "climate_control" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "standard", "<= 1.24.3" +gem "yard" +gem "webrick" +gem "minitest", "~> 5" + +group :check do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.2.0_minitest_5.gemfile.lock b/gemfiles/ruby_3.2.0_minitest_5.gemfile.lock new file mode 100644 index 00000000..944feceb --- /dev/null +++ b/gemfiles/ruby_3.2.0_minitest_5.gemfile.lock @@ -0,0 +1,107 @@ +PATH + remote: .. + specs: + datadog-ci (0.1.0) + ddtrace (~> 1) + +GEM + remote: https://rubygems.org/ + specs: + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + climate_control (1.2.0) + coderay (1.1.3) + ddtrace (1.13.1) + debase-ruby_core_source (= 3.2.1) + libdatadog (~> 3.0.0.1.0) + libddwaf (~> 1.9.0.0.0) + msgpack + debase-ruby_core_source (3.2.1) + diff-lcs (1.5.0) + ffi (1.15.5) + json (2.6.3) + language_server-protocol (3.17.0.3) + libdatadog (3.0.0.1.0-aarch64-linux) + libddwaf (1.9.0.0.1-aarch64-linux) + ffi (~> 1.0) + method_source (1.0.0) + minitest (5.19.0) + msgpack (1.7.2) + os (1.1.4) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.8.1) + rexml (3.2.6) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-collection_matchers (1.2.0) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.44.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.24.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-performance (1.15.2) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) + standard (1.24.3) + language_server-protocol (~> 3.17.0.2) + rubocop (= 1.44.1) + rubocop-performance (= 1.15.2) + thor (1.2.2) + unicode-display_width (2.4.2) + webrick (1.8.1) + yard (0.9.34) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + climate_control + datadog-ci! + minitest (~> 5) + os + pry + rake + rspec + rspec-collection_matchers + rspec_junit_formatter + standard (<= 1.24.3) + webrick + yard + +BUNDLED WITH + 2.3.26 diff --git a/lib/datadog/ci.rb b/lib/datadog/ci.rb index 4ca7635d..2de5406c 100644 --- a/lib/datadog/ci.rb +++ b/lib/datadog/ci.rb @@ -17,6 +17,7 @@ class Error < StandardError; end # Integrations require_relative "ci/contrib/cucumber/integration" require_relative "ci/contrib/rspec/integration" +require_relative "ci/contrib/minitest/integration" # Extensions require_relative "ci/extensions" diff --git a/lib/datadog/ci/contrib/cucumber/configuration/settings.rb b/lib/datadog/ci/contrib/cucumber/configuration/settings.rb index 55ea1952..cee5078b 100644 --- a/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +++ b/lib/datadog/ci/contrib/cucumber/configuration/settings.rb @@ -1,4 +1,3 @@ -require "datadog/tracing/contrib/configuration/settings" require_relative "../ext" module Datadog diff --git a/lib/datadog/ci/contrib/minitest/configuration/settings.rb b/lib/datadog/ci/contrib/minitest/configuration/settings.rb new file mode 100644 index 00000000..6acf97b0 --- /dev/null +++ b/lib/datadog/ci/contrib/minitest/configuration/settings.rb @@ -0,0 +1,32 @@ +require_relative "../ext" + +module Datadog + module CI + module Contrib + module Minitest + module Configuration + # Custom settings for the Minitest integration + # TODO: mark as `@public_api` when GA + class Settings < Datadog::Tracing::Contrib::Configuration::Settings + option :enabled do |o| + o.type :bool + o.env Ext::ENV_ENABLED + o.default true + end + + option :service_name do |o| + o.type :string + o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME } + end + + option :operation_name do |o| + o.type :string + o.env Ext::ENV_OPERATION_NAME + o.default Ext::OPERATION_NAME + end + end + end + end + end + end +end diff --git a/lib/datadog/ci/contrib/minitest/ext.rb b/lib/datadog/ci/contrib/minitest/ext.rb new file mode 100644 index 00000000..0ffaf746 --- /dev/null +++ b/lib/datadog/ci/contrib/minitest/ext.rb @@ -0,0 +1,19 @@ +module Datadog + module CI + module Contrib + module Minitest + # Minitest integration constants + # TODO: mark as `@public_api` when GA, to protect from resource and tag name changes. + module Ext + APP = "minitest" + ENV_ENABLED = "DD_TRACE_MINITEST_ENABLED" + ENV_OPERATION_NAME = "DD_TRACE_MINITEST_OPERATION_NAME" + FRAMEWORK = "minitest" + OPERATION_NAME = "minitest.test" + SERVICE_NAME = "minitest" + TEST_TYPE = "test" + end + end + end + end +end diff --git a/lib/datadog/ci/contrib/minitest/hooks.rb b/lib/datadog/ci/contrib/minitest/hooks.rb new file mode 100644 index 00000000..dbcf4511 --- /dev/null +++ b/lib/datadog/ci/contrib/minitest/hooks.rb @@ -0,0 +1,64 @@ +module Datadog + module CI + module Contrib + module Minitest + # Lifecycle hooks to instrument Minitest::Test + module Hooks + def before_setup + super + return unless configuration[:enabled] + + test_name = "#{class_name}##{name}" + + path, = method(name).source_location + test_suite = Pathname.new(path).relative_path_from(Pathname.pwd).to_s + + span = CI::Test.trace( + configuration[:operation_name], + { + span_options: { + resource: test_name, + service: configuration[:service_name] + }, + framework: Ext::FRAMEWORK, + framework_version: CI::Contrib::Minitest::Integration.version.to_s, + test_name: test_name, + test_suite: test_suite, + test_type: Ext::TEST_TYPE + } + ) + + Thread.current[:_datadog_test_span] = span + end + + def after_teardown + span = Thread.current[:_datadog_test_span] + return super unless span + + Thread.current[:_datadog_test_span] = nil + + case result_code + when "." + CI::Test.passed!(span) + when "E", "F" + CI::Test.failed!(span, failure) + when "S" + CI::Test.skipped!(span) + span.set_tag(CI::Ext::Test::TAG_SKIP_REASON, failure.message) + end + + span.finish + + super + end + + private + + def configuration + ::Datadog.configuration.ci[:minitest] + end + end + end + end + end +end diff --git a/lib/datadog/ci/contrib/minitest/integration.rb b/lib/datadog/ci/contrib/minitest/integration.rb new file mode 100644 index 00000000..4be1ae1c --- /dev/null +++ b/lib/datadog/ci/contrib/minitest/integration.rb @@ -0,0 +1,44 @@ +require_relative "configuration/settings" +require_relative "patcher" + +module Datadog + module CI + module Contrib + module Minitest + # Description of Minitest integration + class Integration + include Datadog::Tracing::Contrib::Integration + + MINIMUM_VERSION = Gem::Version.new("5.0.0") + + register_as :minitest, auto_patch: true + + def self.version + Gem.loaded_specs["minitest"] && Gem.loaded_specs["minitest"].version + end + + def self.loaded? + !defined?(::Minitest).nil? + end + + def self.compatible? + super && version >= MINIMUM_VERSION + end + + # test environments should not auto instrument test libraries + def auto_instrument? + false + end + + def new_configuration + Configuration::Settings.new + end + + def patcher + Patcher + end + end + end + end + end +end diff --git a/lib/datadog/ci/contrib/minitest/patcher.rb b/lib/datadog/ci/contrib/minitest/patcher.rb new file mode 100644 index 00000000..b1b0d73b --- /dev/null +++ b/lib/datadog/ci/contrib/minitest/patcher.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require_relative "hooks" + +module Datadog + module CI + module Contrib + module Minitest + # Patcher enables patching of 'minitest' module. + module Patcher + include Datadog::Tracing::Contrib::Patcher + + module_function + + def target_version + Integration.version + end + + def patch + ::Minitest::Test.include(Hooks) + end + end + end + end + end +end diff --git a/lib/datadog/ci/contrib/rspec/configuration/settings.rb b/lib/datadog/ci/contrib/rspec/configuration/settings.rb index 28568a97..7afd1b3f 100644 --- a/lib/datadog/ci/contrib/rspec/configuration/settings.rb +++ b/lib/datadog/ci/contrib/rspec/configuration/settings.rb @@ -1,4 +1,3 @@ -require "datadog/tracing/contrib/configuration/settings" require_relative "../ext" module Datadog diff --git a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb new file mode 100644 index 00000000..fd93f86f --- /dev/null +++ b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb @@ -0,0 +1,356 @@ +require "time" +require "minitest" +require "minitest/spec" + +require_relative "../support/spec_helper" + +RSpec.describe "Minitest hooks" do + include_context "CI mode activated" + + before do + # required to call .runnable_methods + Minitest.seed = 1 + + Datadog.configure do |c| + c.ci.instrument :minitest, service_name: "ltest" + end + end + + it "creates span for test" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def test_foo + end + end + + klass.new(:test_foo).run + + expect(span.span_type).to eq(Datadog::CI::Ext::AppTypes::TYPE_TEST) + expect(span.name).to eq(Datadog::CI::Contrib::Minitest::Ext::OPERATION_NAME) + expect(span.resource).to eq("SomeTest#test_foo") + expect(span.service).to eq("ltest") + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq("SomeTest#test_foo") + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SUITE)).to eq( + "spec/datadog/ci/contrib/minitest/instrumentation_spec.rb" + ) + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SPAN_KIND)).to eq(Datadog::CI::Ext::AppTypes::TYPE_TEST) + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_TYPE)).to eq(Datadog::CI::Contrib::Minitest::Ext::TEST_TYPE) + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_FRAMEWORK)).to eq(Datadog::CI::Contrib::Minitest::Ext::FRAMEWORK) + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_FRAMEWORK_VERSION)).to eq( + Datadog::CI::Contrib::Minitest::Integration.version.to_s + ) + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_STATUS)).to eq(Datadog::CI::Ext::Test::Status::PASS) + end + + it "creates spans for several tests" do + num_tests = 20 + + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + num_tests.times do |i| + define_method("test_#{i}") {} + end + end + + num_tests.times do |i| + klass.new("test_#{i}").run + end + + expect(spans).to have(num_tests).items + end + + it "creates span for spec" do + klass = Class.new(Minitest::Spec) do + def self.name + "SomeSpec" + end + + it "does not fail" do + end + end + + method_name = klass.runnable_methods.first + klass.new(method_name).run + + expect(span.span_type).to eq(Datadog::CI::Ext::AppTypes::TYPE_TEST) + expect(span.resource).to eq("SomeSpec##{method_name}") + expect(span.service).to eq("ltest") + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq("SomeSpec##{method_name}") + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SUITE)).to eq( + "spec/datadog/ci/contrib/minitest/instrumentation_spec.rb" + ) + end + + it "creates spans for several specs" do + num_specs = 20 + + klass = Class.new(Minitest::Spec) do + def self.name + "SomeSpec" + end + + num_specs.times do |i| + it "does not fail #{i}" do + end + end + end + + klass.runnable_methods.each do |method_name| + klass.new(method_name).run + end + + expect(spans).to have(num_specs).items + end + + it "creates spans for example with instrumentation" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def test_foo + Datadog::Tracing.trace("get_time") do + Time.now + end + end + end + + klass.new(:test_foo).run + + expect(spans).to have(2).items + + spans.each do |span| + expect(span.get_tag(Datadog::Tracing::Metadata::Ext::Distributed::TAG_ORIGIN)) + .to eq(Datadog::CI::Ext::Test::CONTEXT_ORIGIN) + end + end + + context "catches failures" do + def expect_failure + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_STATUS)).to eq(Datadog::CI::Ext::Test::Status::FAIL) + expect(span).to have_error + expect(span).to have_error_type + expect(span).to have_error_message + expect(span).to have_error_stack + end + + it "within test" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def test_foo + assert false + end + end + + klass.new(:test_foo).run + + expect_failure + end + + it "within setup" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def setup + assert false + end + + def test_foo + end + end + + klass.new(:test_foo).run + + expect_failure + end + + it "within teardown" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def teardown + assert false + end + + def test_foo + end + end + + klass.new(:test_foo).run + + expect_failure + end + end + + context "catches errors" do + def expect_failure + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_STATUS)).to eq(Datadog::CI::Ext::Test::Status::FAIL) + expect(span).to have_error + expect(span).to have_error_type + expect(span).to have_error_message + expect(span).to have_error_stack + end + + it "within test" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def test_foo + raise "Error!" + end + end + + klass.new(:test_foo).run + + expect_failure + end + + it "within setup" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def setup + raise "Error!" + end + + def test_foo + end + end + + klass.new(:test_foo).run + + expect_failure + end + + it "within teardown" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def teardown + raise "Error!" + end + + def test_foo + end + end + + klass.new(:test_foo).run + + expect_failure + end + end + + context "catches skips" do + def expect_skip + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_STATUS)).to eq(Datadog::CI::Ext::Test::Status::SKIP) + expect(span).to_not have_error + end + + it "with reason" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def test_foo + skip "Skip!" + end + end + + klass.new(:test_foo).run + + expect_skip + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SKIP_REASON)).to eq("Skip!") + end + + it "without reason" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def test_foo + skip + end + end + + klass.new(:test_foo).run + + expect_skip + expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SKIP_REASON)).to eq("Skipped, no message given") + end + + it "within test" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def test_foo + skip "Skip!" + end + end + + klass.new(:test_foo).run + + expect_skip + end + + it "within setup" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def setup + skip "Skip!" + end + + def test_foo + end + end + + klass.new(:test_foo).run + + expect_skip + end + + it "within teardown" do + klass = Class.new(Minitest::Test) do + def self.name + "SomeTest" + end + + def teardown + skip "Skip!" + end + + def test_foo + end + end + + klass.new(:test_foo).run + + expect_skip + end + end +end diff --git a/spec/datadog/ci/contrib/minitest/integration_spec.rb b/spec/datadog/ci/contrib/minitest/integration_spec.rb new file mode 100644 index 00000000..b0ce04a3 --- /dev/null +++ b/spec/datadog/ci/contrib/minitest/integration_spec.rb @@ -0,0 +1,68 @@ +require_relative "../support/spec_helper" + +RSpec.describe Datadog::CI::Contrib::Minitest::Integration do + extend ConfigurationHelpers + + let(:integration) { described_class.new(:minitest) } + + describe ".version" do + subject(:version) { described_class.version } + + context 'when the "minitest" gem is loaded' do + include_context "loaded gems", "minitest" => described_class::MINIMUM_VERSION + it { is_expected.to be_a_kind_of(Gem::Version) } + end + + context 'when "minitest" gem is not loaded' do + include_context "loaded gems", "minitest" => nil + it { is_expected.to be nil } + end + end + + describe ".loaded?" do + subject(:loaded?) { described_class.loaded? } + + context "when Minitest is defined" do + it { is_expected.to be true } + end + end + + describe ".compatible?" do + subject(:compatible?) { described_class.compatible? } + + context 'when "minitest" gem is loaded with a version' do + context "that is less than the minimum" do + include_context "loaded gems", "minitest" => decrement_gem_version(described_class::MINIMUM_VERSION) + it { is_expected.to be false } + end + + context "that meets the minimum version" do + include_context "loaded gems", "minitest" => described_class::MINIMUM_VERSION + it { is_expected.to be true } + end + end + + context "when gem is not loaded" do + include_context "loaded gems", "minitest" => nil + it { is_expected.to be false } + end + end + + describe "#auto_instrument?" do + subject(:auto_instrument?) { integration.auto_instrument? } + + it { is_expected.to be(false) } + end + + describe "#default_configuration" do + subject(:default_configuration) { integration.default_configuration } + + it { is_expected.to be_a_kind_of(Datadog::CI::Contrib::Minitest::Configuration::Settings) } + end + + describe "#patcher" do + subject(:patcher) { integration.patcher } + + it { is_expected.to be Datadog::CI::Contrib::Minitest::Patcher } + end +end diff --git a/spec/datadog/ci/contrib/minitest/patcher_spec.rb b/spec/datadog/ci/contrib/minitest/patcher_spec.rb new file mode 100644 index 00000000..1107bcef --- /dev/null +++ b/spec/datadog/ci/contrib/minitest/patcher_spec.rb @@ -0,0 +1,17 @@ +require_relative "../support/spec_helper" + +require "minitest" + +RSpec.describe Datadog::CI::Contrib::Minitest::Patcher do + describe ".patch" do + subject!(:patch) { described_class.patch } + + let(:test) { Minitest::Test } + + context "is patched" do + it "has a custom bases" do + expect(test.ancestors).to include(Datadog::CI::Contrib::Minitest::Hooks) + end + end + end +end