bitfab 0.60.1 → 0.61.0

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: f62853e60f5e0d5f5bcde434dfa873175c50c0879ee954d45b26d02268e17134
4
- data.tar.gz: 53b70d4037743af17d86dc0ab09ae0aa8071944a9e4fbb683f9e192825e11d57
3
+ metadata.gz: 1a1a8eab8b1b1b24bdb550f90e3d7cdfde97644a6fcd4301855a12664ac34870
4
+ data.tar.gz: b1acc5424fa7900996bb20d403f1374d77efca40a9267dc9d986831992fe8439
5
5
  SHA512:
6
- metadata.gz: 78c14de2fd5df27341e86c07bd06b655fd2f1cac302e038945093435dfec2e04befee758038a771596e48880b51e57ba03ff777694170bde9063c457c5440d15
7
- data.tar.gz: a2bb563689a5eea7210ad97318cf56f22c9556bdd2cfb7def8c9a9c545f06028a779320e5d148a9e921b29b70cf1aab99dbf192ba31d06eb1ba932617e1e23d5
6
+ metadata.gz: e0acbbd123458aff8ac1385c256da5a29bafef8e48a948a5e3de9916e97566d700ffa693695d572cb232e979d5b24b3f8664bd02fa1a3e1659ec01f2ddda80a4
7
+ data.tar.gz: 8714de8dd405dcf831e1f229cb12e9262d21092eac2b9c320804b752f80348e4ba38a613512856ad1b9aa79db8f52d3368eab3777e425b678a3cc05e9c6d54ee
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "open3"
5
+ require "pathname"
6
+ require "tempfile"
7
+
8
+ module Bitfab
9
+ module CloudReplayCli
10
+ HELP = "Direct GitHub replay: --cloud PIPELINE --trace-ids UUID[,UUID] [--registry PATH] [--max-concurrency 1..32] [--cloud-include FILE] [--cloud-dry-run] [--cloud-detach] [--cloud-request-id UUID]. Lifecycle: --cloud-status|--cloud-watch|--cloud-cancel|--cloud-cleanup UUID. Requires git, gh auth login, Python 3.10+, and bitfab:setup cloud."
11
+
12
+ module_function
13
+
14
+ def cloud?(argv)
15
+ argv.any? { |arg| arg == "--cloud" || arg.start_with?("--cloud-") }
16
+ end
17
+
18
+ def run(argv:, stdout:, stderr:)
19
+ if argv.include?("--help") || argv.include?("-h")
20
+ stdout.puts HELP
21
+ return {}
22
+ end
23
+ output, status = Open3.capture2("git", "rev-parse", "--show-toplevel")
24
+ raise ArgumentError, "Cloud replay must run inside a Git repository" unless status.success?
25
+ root = Pathname.new(output.strip).realpath
26
+ helper = root.join(".bitfab", "cloudReplay.py")
27
+ unless helper.file? && helper.realpath == helper
28
+ raise ArgumentError, "Run bitfab:setup cloud first. Expected .bitfab/cloudReplay.py inside this repository."
29
+ end
30
+ Tempfile.create("bitfab-cloud-output") do |file|
31
+ result_status = nil
32
+ Open3.popen3("python3", helper.to_s, *argv) do |input, output_stream, error_stream, thread|
33
+ input.close
34
+ reader = Thread.new { IO.copy_stream(output_stream, file) }
35
+ error_stream.each_line { |line| stderr.write(line) }
36
+ reader.join
37
+ result_status = thread.value
38
+ end
39
+ file.rewind
40
+ result_output = file.read
41
+ unless result_status.success?
42
+ stdout.puts result_output unless result_output.strip.empty?
43
+ raise ArgumentError, "Cloud replay failed. See diagnostics; use the execution UUID to recover a dispatched job."
44
+ end
45
+ result = JSON.parse(result_output)
46
+ stdout.puts JSON.pretty_generate(result)
47
+ result
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,16 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "optparse"
4
+ require_relative "cloud_replay_cli"
4
5
 
5
6
  module Bitfab
6
7
  # Installed command that loads a project-owned registry module.
7
8
  module ReplayCommand
8
9
  USAGE = "Usage: bitfab-replay --registry <path> <pipeline> [replay options]"
9
- HELP = "#{USAGE}\nRun bitfab-replay --registry <path> --help to list replay options."
10
+ HELP = "#{USAGE}\nRun bitfab-replay --registry <path> --help to list replay options.\n#{CloudReplayCli::HELP}"
10
11
 
11
12
  module_function
12
13
 
13
14
  def run(argv: ARGV, stdout: $stdout, stderr: $stderr, registry_loader: nil)
15
+ return CloudReplayCli.run(argv:, stdout:, stderr:) if CloudReplayCli.cloud?(argv)
14
16
  registry_path, replay_argv = parse(argv)
15
17
  loader = registry_loader || method(:load_registry)
16
18
  registry = loader.call(registry_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.60.1"
4
+ VERSION = "0.61.0"
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.60.1
4
+ version: 0.61.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team
@@ -159,6 +159,7 @@ files:
159
159
  - lib/bitfab/assertions.rb
160
160
  - lib/bitfab/baml.rb
161
161
  - lib/bitfab/client.rb
162
+ - lib/bitfab/cloud_replay_cli.rb
162
163
  - lib/bitfab/commit_ref.rb
163
164
  - lib/bitfab/compress.rb
164
165
  - lib/bitfab/connection_pool.rb