bitfab 0.10.4 → 0.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5d6df92ce06e91ff963c8dc0e78af3a0f591c51b53330c1c8630bb5d66e7663
4
- data.tar.gz: 199d4883cfad921563b3b5786d2db5b017d4b618e000c7d259ed9f69be3eb7ba
3
+ metadata.gz: b789df310c91a7e9130f3bdb6a35e6237a8ddadede4df49a5f7dc4afc0525e91
4
+ data.tar.gz: 0cd79b9c9bc8bf15ef926625c0aa1aba8f3cf1798062c0d077e371d98b9f6aba
5
5
  SHA512:
6
- metadata.gz: 02c87809df7f4039dd608d3e60ddc0ff85b791d834ea7dc5557a368987d5dba1a174705074a26a9df80d4a8bb7c4ff7493f4c8ac03beb457629d896768a70567
7
- data.tar.gz: 579f94120498658ceeb5129b3a21a9d1477d816be9216963c168e0c8747aef0687298f632539f33ace2960db53a19a9ab7847f776d27d971e1b006ad1ebbc909
6
+ metadata.gz: fbf62eeabc5741c36ef1b867730f548039f20331d6591ccae7a66cc48882cd4638877edc1b80d57c3a326827edfbedff1d3ec226ed3b4e3358f9041e3405ea5f
7
+ data.tar.gz: 579cb384585a42160d5f1c9941cbf0762f53d35ffda7f109cb40c4c52a291a02d446e113ca664a2c84a08916481fe86912eb386a58956fb5651ff1a6dc108771
data/lib/bitfab/client.rb CHANGED
@@ -36,9 +36,18 @@ module Bitfab
36
36
  # @param limit [Integer] maximum number of traces to replay (default: 5)
37
37
  # @param trace_ids [Array<String>, nil] optional list of trace IDs to filter
38
38
  # @param max_concurrency [Integer, nil] max threads for parallel replay (default: 10)
39
+ # @param code_change_description [String, nil] optional rationale for the
40
+ # code change being tested in this replay (stored on the experiment)
41
+ # @param code_change_files [Array<Hash>, nil] optional list of edited files,
42
+ # each as { path:, before:, after: } (use "" for new/deleted files)
39
43
  # @return [Hash] with :items, :test_run_id, :test_run_url
40
- def replay(receiver, method_name, trace_function_key:, limit: 5, trace_ids: nil, max_concurrency: 10)
41
- Replay.run(self, receiver, method_name, trace_function_key:, limit:, trace_ids:, max_concurrency:)
44
+ def replay(receiver, method_name, trace_function_key:, limit: 5, trace_ids: nil, max_concurrency: 10,
45
+ code_change_description: nil, code_change_files: nil)
46
+ Replay.run(
47
+ self, receiver, method_name,
48
+ trace_function_key:, limit:, trace_ids:, max_concurrency:,
49
+ code_change_description:, code_change_files:
50
+ )
42
51
  end
43
52
 
44
53
  # Execute a block inside a span context, sending trace data on completion.
@@ -98,12 +98,19 @@ module Bitfab
98
98
 
99
99
  # Start a replay session by fetching historical traces.
100
100
  # Blocking call. Returns hash with testRunId, testRunUrl, and items array.
101
- def start_replay(trace_function_key, limit, trace_ids: nil)
101
+ #
102
+ # @param code_change_description [String, nil] optional rationale for the
103
+ # code change being tested in this replay
104
+ # @param code_change_files [Array<Hash>, nil] optional list of edited files,
105
+ # each as { path:, before:, after: } (use "" for new/deleted files)
106
+ def start_replay(trace_function_key, limit, trace_ids: nil, code_change_description: nil, code_change_files: nil)
102
107
  payload = {
103
108
  "traceFunctionKey" => trace_function_key,
104
109
  "limit" => limit
105
110
  }
106
111
  payload["traceIds"] = trace_ids if trace_ids
112
+ payload["codeChangeDescription"] = code_change_description unless code_change_description.nil?
113
+ payload["codeChangeFiles"] = normalize_code_change_files(code_change_files) unless code_change_files.nil?
107
114
 
108
115
  request("/api/sdk/replay/start", payload, timeout: 30)
109
116
  end
@@ -129,6 +136,18 @@ module Bitfab
129
136
 
130
137
  private
131
138
 
139
+ # Normalize each entry to a hash with stable string keys, accepting either
140
+ # symbol-keyed or string-keyed hashes from callers.
141
+ def normalize_code_change_files(files)
142
+ files.map do |file|
143
+ {
144
+ "path" => file[:path] || file["path"],
145
+ "before" => file[:before] || file["before"],
146
+ "after" => file[:after] || file["after"]
147
+ }
148
+ end
149
+ end
150
+
132
151
  def headers
133
152
  {
134
153
  "Content-Type" => "application/json",
data/lib/bitfab/replay.rb CHANGED
@@ -42,11 +42,22 @@ module Bitfab
42
42
  # @param limit [Integer] maximum number of traces to replay (default: 5)
43
43
  # @param trace_ids [Array<String>, nil] optional list of trace IDs to filter
44
44
  # @param max_concurrency [Integer, nil] max threads for parallel replay (default: 10)
45
+ # @param code_change_description [String, nil] optional rationale for the
46
+ # code change being tested in this replay (stored on the experiment)
47
+ # @param code_change_files [Array<Hash>, nil] optional list of edited files,
48
+ # each as { path:, before:, after: } (empty string for new/deleted files)
45
49
  # @return [Hash] with :items, :test_run_id, :test_run_url
46
- def run(client, receiver, method_name, trace_function_key:, limit: 5, trace_ids: nil, max_concurrency: 10)
50
+ def run(client, receiver, method_name, trace_function_key:, limit: 5, trace_ids: nil, max_concurrency: 10,
51
+ code_change_description: nil, code_change_files: nil)
47
52
  http_client = client.instance_variable_get(:@http_client)
48
53
 
49
- replay_data = http_client.start_replay(trace_function_key, limit, trace_ids:)
54
+ replay_data = http_client.start_replay(
55
+ trace_function_key,
56
+ limit,
57
+ trace_ids:,
58
+ code_change_description:,
59
+ code_change_files:
60
+ )
50
61
  test_run_id = replay_data["testRunId"]
51
62
  test_run_url = replay_data["testRunUrl"]
52
63
  server_items = replay_data["items"] || []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.10.4"
4
+ VERSION = "0.10.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team