datadog-ci 1.0.0.beta3 → 1.0.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 335897204d48926d8c0e3ab1ef8e7c6247a88b12627e27e021614f1b368ab788
4
- data.tar.gz: db5b4ac716d7e0f28712cb7fef86c1f438f2a8b5fa28af0bb67ef91d3758d1c0
3
+ metadata.gz: 8d82afa69ce303c4d7652a9455b4f19c6e89fe5afda868a10bf2b42c765bc06d
4
+ data.tar.gz: 5b2c939c277b4f0b712fcdd3d361cef50302e9947feac333b49bfcea5cd83e4d
5
5
  SHA512:
6
- metadata.gz: c2ebd289964298131bed28406316a48992aaec8e54a6fb21f58ffb6c3d2c523f49fbc5aedf83c9f72a5b8ba45c54cce6df46b8d83eae6ce42804a8901954b61c
7
- data.tar.gz: dd1fcd1c56179c0ab933d166801f69cb843efe67449ad69e7491ee674ff3325fcb9b1adb814881a80137d24de6fa264103ad02d71b73c814acf84a56b706a707
6
+ metadata.gz: f315f6d11021a34dc32815ffa1fea4ffddd4e894253aa8c69225d40fb10930e50949a5bd11237aa9f15f60bca171e4781efbf24e1edce24f239b513819c41741
7
+ data.tar.gz: 80df3261fb5fbb357d4bdcec7b530de26ece4316ba5f289e9254b1e8fcc6129d58e9cf2cada61e81a98500c2aea03aa6410e0a25696148c782c74e99da44fc95
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.0.beta5] - 2024-05-23
4
+
5
+ ### Changed
6
+
7
+ * accept gzipped responses from API ([#170][])
8
+
9
+ ### Fixed
10
+
11
+ * Fix Knapsack Pro integration ([#180][])
12
+
13
+ ## [1.0.0.beta4] - 2024-05-14
14
+
15
+ ### Added
16
+
17
+ * Knapsack Pro 7/RSpec 3 support ([#172][])
18
+ * add settings option to ignore code coverage for bundled gems location ([#174][])
19
+ * log an error message if tracing is disabled but test visibility is enabled ([#175][])
20
+
21
+ ### Removed
22
+
23
+ * remove deprecated use alias ([#173][])
24
+
3
25
  ## [1.0.0.beta3] - 2024-04-30
4
26
 
5
27
  ### Added
@@ -226,7 +248,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
226
248
 
227
249
  - Ruby versions < 2.7 no longer supported ([#8][])
228
250
 
229
- [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.3...main
251
+ [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta5...main
252
+ [1.0.0.beta5]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta4...v1.0.0.beta5
253
+ [1.0.0.beta4]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta3...v1.0.0.beta4
230
254
  [1.0.0.beta3]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta2...v1.0.0.beta3
231
255
  [1.0.0.beta2]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta1...v1.0.0.beta2
232
256
  [1.0.0.beta1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.3...v1.0.0.beta1
@@ -321,3 +345,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
321
345
  [#166]: https://github.com/DataDog/datadog-ci-rb/issues/166
322
346
  [#167]: https://github.com/DataDog/datadog-ci-rb/issues/167
323
347
  [#168]: https://github.com/DataDog/datadog-ci-rb/issues/168
348
+ [#170]: https://github.com/DataDog/datadog-ci-rb/issues/170
349
+ [#172]: https://github.com/DataDog/datadog-ci-rb/issues/172
350
+ [#173]: https://github.com/DataDog/datadog-ci-rb/issues/173
351
+ [#174]: https://github.com/DataDog/datadog-ci-rb/issues/174
352
+ [#175]: https://github.com/DataDog/datadog-ci-rb/issues/175
353
+ [#180]: https://github.com/DataDog/datadog-ci-rb/issues/180
@@ -5,10 +5,35 @@
5
5
  #define DD_COV_TARGET_FILES 1
6
6
  #define DD_COV_TARGET_LINES 2
7
7
 
8
+ static int is_prefix(VALUE prefix, const char *str)
9
+ {
10
+ if (prefix == Qnil)
11
+ {
12
+ return 0;
13
+ }
14
+
15
+ const char *c_prefix = RSTRING_PTR(prefix);
16
+ if (c_prefix == NULL)
17
+ {
18
+ return 0;
19
+ }
20
+
21
+ long prefix_len = RSTRING_LEN(prefix);
22
+ if (strncmp(c_prefix, str, prefix_len) == 0)
23
+ {
24
+ return 1;
25
+ }
26
+ else
27
+ {
28
+ return 0;
29
+ }
30
+ }
31
+
8
32
  // Data structure
9
33
  struct dd_cov_data
10
34
  {
11
35
  VALUE root;
36
+ VALUE ignored_path;
12
37
  int mode;
13
38
  VALUE coverage;
14
39
  };
@@ -18,6 +43,7 @@ static void dd_cov_mark(void *ptr)
18
43
  struct dd_cov_data *dd_cov_data = ptr;
19
44
  rb_gc_mark_movable(dd_cov_data->coverage);
20
45
  rb_gc_mark_movable(dd_cov_data->root);
46
+ rb_gc_mark_movable(dd_cov_data->ignored_path);
21
47
  }
22
48
 
23
49
  static void dd_cov_free(void *ptr)
@@ -32,6 +58,7 @@ static void dd_cov_compact(void *ptr)
32
58
  struct dd_cov_data *dd_cov_data = ptr;
33
59
  dd_cov_data->coverage = rb_gc_location(dd_cov_data->coverage);
34
60
  dd_cov_data->root = rb_gc_location(dd_cov_data->root);
61
+ dd_cov_data->ignored_path = rb_gc_location(dd_cov_data->ignored_path);
35
62
  }
36
63
 
37
64
  const rb_data_type_t dd_cov_data_type = {
@@ -49,6 +76,7 @@ static VALUE dd_cov_allocate(VALUE klass)
49
76
  VALUE obj = TypedData_Make_Struct(klass, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
50
77
  dd_cov_data->coverage = rb_hash_new();
51
78
  dd_cov_data->root = Qnil;
79
+ dd_cov_data->ignored_path = Qnil;
52
80
  dd_cov_data->mode = DD_COV_TARGET_FILES;
53
81
  return obj;
54
82
  }
@@ -66,6 +94,8 @@ static VALUE dd_cov_initialize(int argc, VALUE *argv, VALUE self)
66
94
  rb_raise(rb_eArgError, "root is required");
67
95
  }
68
96
 
97
+ VALUE rb_ignored_path = rb_hash_lookup(opt, ID2SYM(rb_intern("ignored_path")));
98
+
69
99
  VALUE rb_mode = rb_hash_lookup(opt, ID2SYM(rb_intern("mode")));
70
100
  if (!RTEST(rb_mode) || rb_mode == ID2SYM(rb_intern("files")))
71
101
  {
@@ -84,6 +114,7 @@ static VALUE dd_cov_initialize(int argc, VALUE *argv, VALUE self)
84
114
  TypedData_Get_Struct(self, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
85
115
 
86
116
  dd_cov_data->root = rb_root;
117
+ dd_cov_data->ignored_path = rb_ignored_path;
87
118
  dd_cov_data->mode = mode;
88
119
 
89
120
  return Qnil;
@@ -100,20 +131,15 @@ static void dd_cov_update_line_coverage(rb_event_flag_t event, VALUE data, VALUE
100
131
  return;
101
132
  }
102
133
 
103
- if (dd_cov_data->root == Qnil)
134
+ // if given filename is not located under the root, we skip it
135
+ if (is_prefix(dd_cov_data->root, filename) == 0)
104
136
  {
105
137
  return;
106
138
  }
107
139
 
108
- char *c_root = RSTRING_PTR(dd_cov_data->root);
109
- if (c_root == NULL)
110
- {
111
- return;
112
- }
113
- long root_len = RSTRING_LEN(dd_cov_data->root);
114
- // check that root is a prefix of the filename
115
- // so this file is located under the given root
116
- if (strncmp(c_root, filename, root_len) != 0)
140
+ // if ignored_path is provided and given filename is located under the ignored_path, we skip it too
141
+ // this is useful for ignoring bundled gems location
142
+ if (RTEST(dd_cov_data->ignored_path) && is_prefix(dd_cov_data->ignored_path, filename) == 1)
117
143
  {
118
144
  return;
119
145
  }
@@ -43,6 +43,16 @@ module Datadog
43
43
  end
44
44
 
45
45
  def activate_ci!(settings)
46
+ unless settings.tracing.enabled
47
+ Datadog.logger.error(
48
+ "CI visibility requires tracing to be enabled. Disabling CI visibility. " \
49
+ "NOTE: if you didn't disable tracing intentionally, add `c.tracing.enabled = true` to " \
50
+ "your Datadog.configure block."
51
+ )
52
+ settings.ci.enabled = false
53
+ return
54
+ end
55
+
46
56
  # Configure ddtrace library for CI visibility mode
47
57
  # Deactivate telemetry
48
58
  settings.telemetry.enabled = false
@@ -107,7 +117,8 @@ module Datadog
107
117
  dd_env: settings.env,
108
118
  config_tags: custom_configuration_tags,
109
119
  coverage_writer: coverage_writer,
110
- enabled: settings.ci.enabled && settings.ci.itr_enabled
120
+ enabled: settings.ci.enabled && settings.ci.itr_enabled,
121
+ bundle_location: settings.ci.itr_code_coverage_excluded_bundle_path
111
122
  )
112
123
 
113
124
  git_tree_uploader = Git::TreeUploader.new(api: test_visibility_api)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../ext/settings"
4
+ require_relative "../utils/bundle"
4
5
 
5
6
  module Datadog
6
7
  module CI
@@ -67,6 +68,14 @@ module Datadog
67
68
  o.default true
68
69
  end
69
70
 
71
+ option :itr_code_coverage_excluded_bundle_path do |o|
72
+ o.type :string, nilable: true
73
+ o.env CI::Ext::Settings::ENV_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH
74
+ o.default do
75
+ Datadog::CI::Utils::Bundle.location
76
+ end
77
+ end
78
+
70
79
  define_method(:instrument) do |integration_name, options = {}, &block|
71
80
  return unless enabled
72
81
 
@@ -89,9 +98,6 @@ module Datadog
89
98
  fetch_integration(integration_name).configuration
90
99
  end
91
100
 
92
- # @deprecated Will be removed on datadog-ci-rb 1.0.
93
- alias_method :use, :instrument
94
-
95
101
  option :trace_flush
96
102
 
97
103
  option :writer_options do |o|
@@ -17,6 +17,7 @@ module Datadog
17
17
 
18
18
  module InstanceMethods
19
19
  def run(*)
20
+ return super if ::RSpec.configuration.dry_run?
20
21
  return super unless datadog_configuration[:enabled]
21
22
 
22
23
  test_name = full_description.strip
@@ -16,6 +16,7 @@ module Datadog
16
16
  # Instance methods for configuration
17
17
  module ClassMethods
18
18
  def run(reporter = ::RSpec::Core::NullReporter)
19
+ return super if ::RSpec.configuration.dry_run?
19
20
  return super unless datadog_configuration[:enabled]
20
21
  return super unless top_level?
21
22
 
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "knapsack_pro/extensions/rspec_extension"
4
+
5
+ require_relative "runner"
6
+
7
+ module Datadog
8
+ module CI
9
+ module Contrib
10
+ module RSpec
11
+ module KnapsackPro
12
+ module Extension
13
+ def self.included(base)
14
+ base.singleton_class.prepend(ClassMethods)
15
+ end
16
+
17
+ module ClassMethods
18
+ def setup!
19
+ super
20
+
21
+ ::RSpec::Core::Runner.include(Datadog::CI::Contrib::RSpec::KnapsackPro::Runner)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module CI
5
+ module Contrib
6
+ module RSpec
7
+ module KnapsackPro
8
+ module Patcher
9
+ def self.patch
10
+ if defined?(::KnapsackPro::Extensions::RSpecExtension::Runner) &&
11
+ ::RSpec::Core::Runner.ancestors.include?(::KnapsackPro::Extensions::RSpecExtension::Runner)
12
+ # knapsack already patched rspec runner
13
+ require_relative "runner"
14
+ ::RSpec::Core::Runner.include(KnapsackPro::Runner)
15
+ else
16
+ # knapsack didn't patch rspec runner yet
17
+ require_relative "extension"
18
+ ::KnapsackPro::Extensions::RSpecExtension.include(KnapsackPro::Extension)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../ext/test"
4
+ require_relative "../ext"
5
+
6
+ module Datadog
7
+ module CI
8
+ module Contrib
9
+ module RSpec
10
+ module KnapsackPro
11
+ module Runner
12
+ def self.included(base)
13
+ base.prepend(InstanceMethods)
14
+ end
15
+
16
+ module InstanceMethods
17
+ def knapsack__run_specs(*)
18
+ return super if ::RSpec.configuration.dry_run?
19
+ return super unless datadog_configuration[:enabled]
20
+
21
+ test_session = CI.start_test_session(
22
+ tags: {
23
+ CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
24
+ CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::RSpec::Integration.version.to_s
25
+ },
26
+ service: datadog_configuration[:service_name]
27
+ )
28
+
29
+ test_module = CI.start_test_module(Ext::FRAMEWORK)
30
+
31
+ result = super
32
+ return result unless test_module && test_session
33
+
34
+ if result != 0
35
+ test_module.failed!
36
+ test_session.failed!
37
+ else
38
+ test_module.passed!
39
+ test_session.passed!
40
+ end
41
+ test_module.finish
42
+ test_session.finish
43
+
44
+ result
45
+ end
46
+
47
+ private
48
+
49
+ def datadog_configuration
50
+ Datadog.configuration.ci[:rspec]
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -21,19 +21,37 @@ module Datadog
21
21
  end
22
22
 
23
23
  def patch
24
+ # ci-queue test runner instrumentation
25
+ # https://github.com/Shopify/ci-queue
24
26
  if ci_queue?
25
27
  ::RSpec::Queue::Runner.include(Runner)
26
28
  end
27
29
 
30
+ if knapsack_pro?
31
+ # Knapsack Pro test runner instrumentation
32
+ # https://github.com/KnapsackPro/knapsack_pro-ruby
33
+ require_relative "knapsack_pro/patcher"
34
+ Datadog::CI::Contrib::RSpec::KnapsackPro::Patcher.patch
35
+ end
36
+
37
+ # default rspec test runner instrumentation
28
38
  ::RSpec::Core::Runner.include(Runner)
39
+
29
40
  ::RSpec::Core::Example.include(Example)
30
41
  ::RSpec::Core::ExampleGroup.include(ExampleGroup)
31
42
  end
32
43
 
33
44
  def ci_queue?
34
- # ::RSpec::Queue::Runner is a ci-queue runner
35
45
  defined?(::RSpec::Queue::Runner)
36
46
  end
47
+
48
+ def knapsack_pro?
49
+ knapsack_version = Gem.loaded_specs["knapsack_pro"]&.version
50
+
51
+ # additional instrumentation is needed for KnapsackPro version 7 and later
52
+ defined?(::KnapsackPro) &&
53
+ knapsack_version && knapsack_version >= Gem::Version.new("7")
54
+ end
37
55
  end
38
56
  end
39
57
  end
@@ -15,6 +15,7 @@ module Datadog
15
15
 
16
16
  module InstanceMethods
17
17
  def run_specs(*)
18
+ return super if ::RSpec.configuration.dry_run?
18
19
  return super unless datadog_configuration[:enabled]
19
20
 
20
21
  test_session = CI.start_test_session(
@@ -23,6 +23,11 @@ module Datadog
23
23
  TAG_NODE_NAME = "ci.node.name"
24
24
  TAG_CI_ENV_VARS = "_dd.ci.env_vars"
25
25
 
26
+ POSSIBLE_BUNDLE_LOCATIONS = [
27
+ "vendor/bundle",
28
+ ".bundle"
29
+ ].freeze
30
+
26
31
  module_function
27
32
 
28
33
  def tags(env)
@@ -12,6 +12,7 @@ module Datadog
12
12
  ENV_FORCE_TEST_LEVEL_VISIBILITY = "DD_CIVISIBILITY_FORCE_TEST_LEVEL_VISIBILITY"
13
13
  ENV_ITR_ENABLED = "DD_CIVISIBILITY_ITR_ENABLED"
14
14
  ENV_GIT_METADATA_UPLOAD_ENABLED = "DD_CIVISIBILITY_GIT_METADATA_UPLOAD_ENABLED"
15
+ ENV_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH = "DD_CIVISIBILITY_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH"
15
16
 
16
17
  # Source: https://docs.datadoghq.com/getting_started/site/
17
18
  DD_SITE_ALLOWLIST = [
@@ -7,6 +7,7 @@ module Datadog
7
7
  DEFAULT_DD_SITE = "datadoghq.com"
8
8
 
9
9
  HEADER_DD_API_KEY = "DD-API-KEY"
10
+ HEADER_ACCEPT_ENCODING = "Accept-Encoding"
10
11
  HEADER_CONTENT_TYPE = "Content-Type"
11
12
  HEADER_CONTENT_ENCODING = "Content-Encoding"
12
13
  HEADER_EVP_SUBDOMAIN = "X-Datadog-EVP-Subdomain"
@@ -48,6 +49,8 @@ module Datadog
48
49
  CONTENT_TYPE_JSON = "application/json"
49
50
  CONTENT_TYPE_MULTIPART_FORM_DATA = "multipart/form-data"
50
51
  CONTENT_ENCODING_GZIP = "gzip"
52
+
53
+ GZIP_MAGIC_NUMBER = "\x1F\x8B".b
51
54
  end
52
55
  end
53
56
  end
@@ -30,20 +30,27 @@ module Datadog
30
30
  config_tags: {},
31
31
  api: nil,
32
32
  coverage_writer: nil,
33
- enabled: false
33
+ enabled: false,
34
+ bundle_location: nil
34
35
  )
35
36
  @enabled = enabled
36
37
  @api = api
37
38
  @dd_env = dd_env
38
39
  @config_tags = config_tags || {}
39
40
 
41
+ @bundle_location = if bundle_location && !File.absolute_path?(bundle_location)
42
+ File.join(Git::LocalRepository.root, bundle_location)
43
+ else
44
+ bundle_location
45
+ end
46
+
40
47
  @test_skipping_enabled = false
41
48
  @code_coverage_enabled = false
42
49
 
43
50
  @coverage_writer = coverage_writer
44
51
 
45
52
  @correlation_id = nil
46
- @skippable_tests = []
53
+ @skippable_tests = Set.new
47
54
 
48
55
  @skipped_tests_count = 0
49
56
  @mutex = Mutex.new
@@ -177,7 +184,10 @@ module Datadog
177
184
  end
178
185
 
179
186
  def coverage_collector
180
- Thread.current[:dd_coverage_collector] ||= Coverage::DDCov.new(root: Git::LocalRepository.root)
187
+ Thread.current[:dd_coverage_collector] ||= Coverage::DDCov.new(
188
+ root: Git::LocalRepository.root,
189
+ ignored_path: @bundle_location
190
+ )
181
191
  end
182
192
 
183
193
  def load_datadog_cov!
@@ -26,7 +26,14 @@ module Datadog
26
26
  def api_request(path:, payload:, headers: {}, verb: "post")
27
27
  super
28
28
 
29
- perform_request(@api_http, path: path, payload: payload, headers: headers, verb: verb)
29
+ perform_request(
30
+ @api_http,
31
+ path: path,
32
+ payload: payload,
33
+ headers: headers,
34
+ verb: verb,
35
+ accept_compressed_response: true
36
+ )
30
37
  end
31
38
 
32
39
  def citestcov_request(path:, payload:, headers: {}, verb: "post")
@@ -37,12 +44,13 @@ module Datadog
37
44
 
38
45
  private
39
46
 
40
- def perform_request(http_client, path:, payload:, headers:, verb:)
47
+ def perform_request(http_client, path:, payload:, headers:, verb:, accept_compressed_response: false)
41
48
  http_client.request(
42
49
  path: path,
43
50
  payload: payload,
44
51
  headers: headers_with_default(headers),
45
- verb: verb
52
+ verb: verb,
53
+ accept_compressed_response: accept_compressed_response
46
54
  )
47
55
  end
48
56
 
@@ -16,6 +16,18 @@ module Datadog
16
16
  gzip_writer.close
17
17
  sio.string
18
18
  end
19
+
20
+ def decompress(input)
21
+ sio = StringIO.new(input)
22
+ gzip_reader = Zlib::GzipReader.new(
23
+ sio,
24
+ external_encoding: Encoding::UTF_8,
25
+ internal_encoding: Encoding::UTF_8
26
+ )
27
+ gzip_reader.read || ""
28
+ ensure
29
+ gzip_reader&.close
30
+ end
19
31
  end
20
32
  end
21
33
  end
@@ -32,12 +32,24 @@ module Datadog
32
32
  @compress = compress.nil? ? false : compress
33
33
  end
34
34
 
35
- def request(path:, payload:, headers:, verb: "post", retries: MAX_RETRIES, backoff: INITIAL_BACKOFF)
35
+ def request(
36
+ path:,
37
+ payload:,
38
+ headers:,
39
+ verb: "post",
40
+ retries: MAX_RETRIES,
41
+ backoff: INITIAL_BACKOFF,
42
+ accept_compressed_response: false
43
+ )
36
44
  if compress
37
45
  headers[Ext::Transport::HEADER_CONTENT_ENCODING] = Ext::Transport::CONTENT_ENCODING_GZIP
38
46
  payload = Gzip.compress(payload)
39
47
  end
40
48
 
49
+ if accept_compressed_response
50
+ headers[Ext::Transport::HEADER_ACCEPT_ENCODING] = Ext::Transport::CONTENT_ENCODING_GZIP
51
+ end
52
+
41
53
  Datadog.logger.debug do
42
54
  "Sending #{verb} request: host=#{host}; port=#{port}; ssl_enabled=#{ssl}; " \
43
55
  "compression_enabled=#{compress}; path=#{path}; payload_size=#{payload.size}"
@@ -91,12 +103,32 @@ module Datadog
91
103
  @adapter ||= Datadog::Core::Transport::HTTP::Adapters::Net.new(settings)
92
104
  end
93
105
 
94
- # this is needed because Datadog::Tracing::Writer is not fully compatiple with Datadog::Core::Transport
95
- # TODO: remove when CI implements its own worker
106
+ # adds compatibility with Datadog::Tracing transport and
107
+ # provides ungzipping capabilities
96
108
  class ResponseDecorator < ::SimpleDelegator
109
+ def payload
110
+ return @decompressed_payload if defined?(@decompressed_payload)
111
+
112
+ if gzipped?(__getobj__.payload)
113
+ Datadog.logger.debug("Decompressing gzipped response payload")
114
+ @decompressed_payload = Gzip.decompress(__getobj__.payload)
115
+ else
116
+ __getobj__.payload
117
+ end
118
+ end
119
+
97
120
  def trace_count
98
121
  0
99
122
  end
123
+
124
+ def gzipped?(payload)
125
+ return false if payload.nil? || payload.empty?
126
+
127
+ first_bytes = payload[0, 2]
128
+ return false if first_bytes.nil? || first_bytes.empty?
129
+
130
+ first_bytes.b == Datadog::CI::Ext::Transport::GZIP_MAGIC_NUMBER
131
+ end
100
132
  end
101
133
 
102
134
  class AdapterSettings
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../ext/environment"
4
+ require_relative "../git/local_repository"
5
+
6
+ module Datadog
7
+ module CI
8
+ module Utils
9
+ module Bundle
10
+ def self.location
11
+ require "bundler"
12
+ bundle_path = Bundler.bundle_path.to_s
13
+ bundle_path if bundle_path&.start_with?(Datadog::CI::Git::LocalRepository.root)
14
+ rescue => e
15
+ Datadog.logger.warn("Failed to find bundled gems location: #{e}")
16
+
17
+ Ext::Environment::POSSIBLE_BUNDLE_LOCATIONS.each do |location|
18
+ path = File.join(Datadog::CI::Git::LocalRepository.root, location)
19
+ return path if File.directory?(path)
20
+ end
21
+ nil
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -6,7 +6,7 @@ module Datadog
6
6
  MAJOR = "1"
7
7
  MINOR = "0"
8
8
  PATCH = "0"
9
- PRE = "beta3"
9
+ PRE = "beta5"
10
10
  BUILD = nil
11
11
  # PRE and BUILD above are modified for dev gems during gem build GHA workflow
12
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta3
4
+ version: 1.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-30 00:00:00.000000000 Z
11
+ date: 2024-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: datadog
@@ -88,6 +88,9 @@ files:
88
88
  - lib/datadog/ci/contrib/rspec/example_group.rb
89
89
  - lib/datadog/ci/contrib/rspec/ext.rb
90
90
  - lib/datadog/ci/contrib/rspec/integration.rb
91
+ - lib/datadog/ci/contrib/rspec/knapsack_pro/extension.rb
92
+ - lib/datadog/ci/contrib/rspec/knapsack_pro/patcher.rb
93
+ - lib/datadog/ci/contrib/rspec/knapsack_pro/runner.rb
91
94
  - lib/datadog/ci/contrib/rspec/patcher.rb
92
95
  - lib/datadog/ci/contrib/rspec/runner.rb
93
96
  - lib/datadog/ci/contrib/settings.rb
@@ -156,6 +159,7 @@ files:
156
159
  - lib/datadog/ci/transport/gzip.rb
157
160
  - lib/datadog/ci/transport/http.rb
158
161
  - lib/datadog/ci/transport/remote_settings_api.rb
162
+ - lib/datadog/ci/utils/bundle.rb
159
163
  - lib/datadog/ci/utils/configuration.rb
160
164
  - lib/datadog/ci/utils/git.rb
161
165
  - lib/datadog/ci/utils/parsing.rb
@@ -170,7 +174,7 @@ metadata:
170
174
  changelog_uri: https://github.com/DataDog/datadog-ci-rb/blob/main/CHANGELOG.md
171
175
  homepage_uri: https://github.com/DataDog/datadog-ci-rb
172
176
  source_code_uri: https://github.com/DataDog/datadog-ci-rb
173
- post_install_message:
177
+ post_install_message:
174
178
  rdoc_options: []
175
179
  require_paths:
176
180
  - lib
@@ -188,8 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
192
  - !ruby/object:Gem::Version
189
193
  version: 2.0.0
190
194
  requirements: []
191
- rubygems_version: 3.5.9
192
- signing_key:
195
+ rubygems_version: 3.4.19
196
+ signing_key:
193
197
  specification_version: 4
194
198
  summary: Datadog CI visibility for your ruby application
195
199
  test_files: []