datadog-ci 1.0.0.beta4 → 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: 035d75d50e0e09c7895bc0e434c5ac1e0655618763ac724a94989833e0c07d61
4
- data.tar.gz: bfbd5d6ff101ef51e59d3546d110f906f178c23602241f85b3a8b413524a9900
3
+ metadata.gz: 8d82afa69ce303c4d7652a9455b4f19c6e89fe5afda868a10bf2b42c765bc06d
4
+ data.tar.gz: 5b2c939c277b4f0b712fcdd3d361cef50302e9947feac333b49bfcea5cd83e4d
5
5
  SHA512:
6
- metadata.gz: c1b6463b913cbff1e20a2c3f4fcaa6c47814ba693eee5682fa41c3baa74f9e92414b4e554ec8407807d6eeb1744f0c76d87bb0889bd0e639c6ebdc3de1dcd180
7
- data.tar.gz: dca4568f30dbaef22e8fac94389e682beb21ba6f92f0578553ff01d2ad289f38d33f899c79bef604f3f83906d6c31b9e64a9495cc3dc986fb321bd810430780d
6
+ metadata.gz: f315f6d11021a34dc32815ffa1fea4ffddd4e894253aa8c69225d40fb10930e50949a5bd11237aa9f15f60bca171e4781efbf24e1edce24f239b513819c41741
7
+ data.tar.gz: 80df3261fb5fbb357d4bdcec7b530de26ece4316ba5f289e9254b1e8fcc6129d58e9cf2cada61e81a98500c2aea03aa6410e0a25696148c782c74e99da44fc95
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## [1.0.0.beta4] - 2024-05-14
4
14
 
5
15
  ### Added
@@ -238,7 +248,8 @@ Currently test suite level visibility is not used by our instrumentation: it wil
238
248
 
239
249
  - Ruby versions < 2.7 no longer supported ([#8][])
240
250
 
241
- [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta4...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
242
253
  [1.0.0.beta4]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta3...v1.0.0.beta4
243
254
  [1.0.0.beta3]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta2...v1.0.0.beta3
244
255
  [1.0.0.beta2]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta1...v1.0.0.beta2
@@ -334,7 +345,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
334
345
  [#166]: https://github.com/DataDog/datadog-ci-rb/issues/166
335
346
  [#167]: https://github.com/DataDog/datadog-ci-rb/issues/167
336
347
  [#168]: https://github.com/DataDog/datadog-ci-rb/issues/168
348
+ [#170]: https://github.com/DataDog/datadog-ci-rb/issues/170
337
349
  [#172]: https://github.com/DataDog/datadog-ci-rb/issues/172
338
350
  [#173]: https://github.com/DataDog/datadog-ci-rb/issues/173
339
351
  [#174]: https://github.com/DataDog/datadog-ci-rb/issues/174
340
- [#175]: https://github.com/DataDog/datadog-ci-rb/issues/175
352
+ [#175]: https://github.com/DataDog/datadog-ci-rb/issues/175
353
+ [#180]: https://github.com/DataDog/datadog-ci-rb/issues/180
@@ -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
 
@@ -8,7 +8,6 @@ module Datadog
8
8
  module CI
9
9
  module Contrib
10
10
  module RSpec
11
- # Instrument RSpec::Core::Example
12
11
  module KnapsackPro
13
12
  module Extension
14
13
  def self.included(base)
@@ -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
@@ -15,6 +15,7 @@ module Datadog
15
15
 
16
16
  module InstanceMethods
17
17
  def knapsack__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(
@@ -27,14 +27,16 @@ module Datadog
27
27
  ::RSpec::Queue::Runner.include(Runner)
28
28
  end
29
29
 
30
- # Knapsack Pro test runner instrumentation
31
- # https://github.com/KnapsackPro/knapsack_pro-ruby
32
30
  if knapsack_pro?
33
- require_relative "knapsack_pro/extension"
34
- ::KnapsackPro::Extensions::RSpecExtension.include(KnapsackPro::Extension)
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
35
  end
36
36
 
37
+ # default rspec test runner instrumentation
37
38
  ::RSpec::Core::Runner.include(Runner)
39
+
38
40
  ::RSpec::Core::Example.include(Example)
39
41
  ::RSpec::Core::ExampleGroup.include(ExampleGroup)
40
42
  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(
@@ -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
@@ -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
@@ -6,7 +6,7 @@ module Datadog
6
6
  MAJOR = "1"
7
7
  MINOR = "0"
8
8
  PATCH = "0"
9
- PRE = "beta4"
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.beta4
4
+ version: 1.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-14 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
@@ -89,6 +89,7 @@ files:
89
89
  - lib/datadog/ci/contrib/rspec/ext.rb
90
90
  - lib/datadog/ci/contrib/rspec/integration.rb
91
91
  - lib/datadog/ci/contrib/rspec/knapsack_pro/extension.rb
92
+ - lib/datadog/ci/contrib/rspec/knapsack_pro/patcher.rb
92
93
  - lib/datadog/ci/contrib/rspec/knapsack_pro/runner.rb
93
94
  - lib/datadog/ci/contrib/rspec/patcher.rb
94
95
  - lib/datadog/ci/contrib/rspec/runner.rb