buildonce 0.32.0 → 0.33.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 +4 -4
- data/README.md +7 -2
- data/lib/buildonce.rb +85 -8
- data/lib/once/native.rb +3 -0
- data/prebuilds/darwin-arm64/libonce.dylib +0 -0
- data/prebuilds/darwin-x64/libonce.dylib +0 -0
- data/prebuilds/linux-arm64/libonce.so +0 -0
- data/prebuilds/linux-x64/libonce.so +0 -0
- data/prebuilds/win32-x64/once.dll +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1a0860cf2425eddaae411d83154c8379d38072c40309b634b6d998b28cb15a5
|
|
4
|
+
data.tar.gz: 39b47ad58bee6bfdc7abcac5e5365403c8c9de211d6b0510299ad95bad2b9007
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5686e5a4f2f269966f20b20fa2fd71696b4ae9060603a3d9d1421a0bdb2f1bfd1d284f3af8d680a5e52fbf73eaff6dac22fcc10af4c2603bbbd6994088ef0ce
|
|
7
|
+
data.tar.gz: 1ae22f71085fc1d8b4d7c39b7753cf084085350cfe55d9a5fadf5fd920b5aaae6a0d98fb53001e50cb34ecae598bf6d2d275198e43cc5d4cd381e78fe07ca755
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Once Ruby
|
|
1
|
+
# Once Ruby Software Development Kit
|
|
2
2
|
|
|
3
3
|
`buildonce` exposes Once primitives to Ruby. It loads the same
|
|
4
|
-
native Once library used by the other
|
|
4
|
+
native Once library used by the other language libraries and does not expose script
|
|
5
5
|
execution.
|
|
6
6
|
|
|
7
7
|
```ruby
|
|
@@ -16,3 +16,8 @@ raise unless bytes == "hello"
|
|
|
16
16
|
|
|
17
17
|
The gem looks for a bundled native library under `prebuilds/`. Set
|
|
18
18
|
`ONCE_LIBRARY_PATH` to load a custom `libonce` build.
|
|
19
|
+
|
|
20
|
+
Use `Once::Cache.new(workspace_root:)` to share the effective provider
|
|
21
|
+
configured for a repository, or `local_cache_root:` for isolation. Use
|
|
22
|
+
`put_file` and `get_blob_to_file` for large payloads. `Once::ActionKey` builds
|
|
23
|
+
a stable digest from ordered, labeled inputs.
|
data/lib/buildonce.rb
CHANGED
|
@@ -25,6 +25,17 @@ module Once
|
|
|
25
25
|
CacheStats = Struct.new(:blob_count, :blob_bytes, :action_count, :action_bytes, keyword_init: true)
|
|
26
26
|
|
|
27
27
|
class Cache
|
|
28
|
+
def initialize(local_cache_root: nil, workspace_root: nil)
|
|
29
|
+
if local_cache_root && workspace_root
|
|
30
|
+
raise ArgumentError, "local_cache_root and workspace_root cannot be used together"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@selection = {}
|
|
34
|
+
@selection[:local_cache_root] = local_cache_root.to_s if local_cache_root
|
|
35
|
+
@selection[:workspace_root] = workspace_root.to_s if workspace_root
|
|
36
|
+
@selection.freeze
|
|
37
|
+
end
|
|
38
|
+
|
|
28
39
|
def version
|
|
29
40
|
read_native_string(Native.once_version)
|
|
30
41
|
end
|
|
@@ -37,37 +48,56 @@ module Once
|
|
|
37
48
|
|
|
38
49
|
def put_blob(bytes)
|
|
39
50
|
buffer = bytes.to_s.b
|
|
40
|
-
decode_request(:once_cache_put_blob_json, bytes: buffer.bytes)
|
|
51
|
+
decode_request(:once_cache_put_blob_json, selection(bytes: buffer.bytes))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def put_file(path)
|
|
55
|
+
decode_request(:once_cache_put_file_json, selection(path: path.to_s))
|
|
41
56
|
end
|
|
42
57
|
|
|
43
58
|
def get_blob(digest)
|
|
44
|
-
response = decode_request(:once_cache_get_blob_json, digest: digest)
|
|
59
|
+
response = decode_request(:once_cache_get_blob_json, selection(digest: digest))
|
|
45
60
|
response.fetch("bytes").pack("C*")
|
|
46
61
|
end
|
|
47
62
|
|
|
63
|
+
def get_blob_to_file(digest, path)
|
|
64
|
+
decode_request(
|
|
65
|
+
:once_cache_get_blob_to_file_json,
|
|
66
|
+
selection(digest: digest, path: path.to_s),
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
|
|
48
70
|
def has_blob?(digest)
|
|
49
|
-
decode_request(:once_cache_has_blob_json, digest: digest)
|
|
71
|
+
decode_request(:once_cache_has_blob_json, selection(digest: digest))
|
|
50
72
|
end
|
|
51
73
|
|
|
52
74
|
def put_action_result(result, action_digest:)
|
|
53
75
|
decode_request(
|
|
54
76
|
:once_cache_put_action_result_json,
|
|
55
|
-
|
|
56
|
-
|
|
77
|
+
selection(
|
|
78
|
+
action_digest: action_digest,
|
|
79
|
+
result: normalize_action_result(result),
|
|
80
|
+
),
|
|
57
81
|
)
|
|
58
82
|
end
|
|
59
83
|
|
|
60
84
|
def get_action_result(action_digest)
|
|
61
|
-
response = decode_request(
|
|
85
|
+
response = decode_request(
|
|
86
|
+
:once_cache_get_action_result_json,
|
|
87
|
+
selection(action_digest: action_digest),
|
|
88
|
+
)
|
|
62
89
|
response && action_result_from_native(response)
|
|
63
90
|
end
|
|
64
91
|
|
|
65
92
|
def forget_action(action_digest)
|
|
66
|
-
decode_request(
|
|
93
|
+
decode_request(
|
|
94
|
+
:once_cache_forget_action_json,
|
|
95
|
+
selection(action_digest: action_digest),
|
|
96
|
+
)
|
|
67
97
|
end
|
|
68
98
|
|
|
69
99
|
def stats
|
|
70
|
-
response = decode_request(:once_cache_stats_json,
|
|
100
|
+
response = decode_request(:once_cache_stats_json, @selection)
|
|
71
101
|
CacheStats.new(
|
|
72
102
|
blob_count: response.fetch("blob_count"),
|
|
73
103
|
blob_bytes: response.fetch("blob_bytes"),
|
|
@@ -78,6 +108,10 @@ module Once
|
|
|
78
108
|
|
|
79
109
|
private
|
|
80
110
|
|
|
111
|
+
def selection(request)
|
|
112
|
+
@selection.merge(request)
|
|
113
|
+
end
|
|
114
|
+
|
|
81
115
|
def decode_request(function, request)
|
|
82
116
|
decode_response(Native.public_send(function, JSON.generate(request)))
|
|
83
117
|
end
|
|
@@ -129,6 +163,49 @@ module Once
|
|
|
129
163
|
end
|
|
130
164
|
end
|
|
131
165
|
|
|
166
|
+
class ActionKey
|
|
167
|
+
def initialize(namespace)
|
|
168
|
+
raise ArgumentError, "namespace must be a String" unless namespace.is_a?(String)
|
|
169
|
+
|
|
170
|
+
@namespace = namespace
|
|
171
|
+
@inputs = []
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def add_bytes(label, bytes)
|
|
175
|
+
validate_label(label)
|
|
176
|
+
@inputs << { kind: "bytes", label: label, bytes: bytes.to_s.b.bytes }
|
|
177
|
+
self
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def add_digest(label, digest)
|
|
181
|
+
validate_label(label)
|
|
182
|
+
@inputs << { kind: "digest", label: label, digest: digest }
|
|
183
|
+
self
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def digest
|
|
187
|
+
pointer = Native.once_action_key_json(
|
|
188
|
+
JSON.generate(namespace: @namespace, inputs: @inputs),
|
|
189
|
+
)
|
|
190
|
+
raise Error, "native Once function returned null" if pointer.null?
|
|
191
|
+
|
|
192
|
+
response = JSON.parse(pointer.read_string)
|
|
193
|
+
return response.fetch("value") if response.fetch("status") == "ok"
|
|
194
|
+
|
|
195
|
+
raise Error, response.fetch("message")
|
|
196
|
+
rescue JSON::ParserError, KeyError => e
|
|
197
|
+
raise Error, e.message
|
|
198
|
+
ensure
|
|
199
|
+
Native.once_string_free(pointer) if pointer && !pointer.null?
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
private
|
|
203
|
+
|
|
204
|
+
def validate_label(label)
|
|
205
|
+
raise ArgumentError, "input label must be a String" unless label.is_a?(String)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
132
209
|
def self.digest(bytes)
|
|
133
210
|
Cache.new.digest(bytes)
|
|
134
211
|
end
|
data/lib/once/native.rb
CHANGED
|
@@ -60,8 +60,11 @@ module Once
|
|
|
60
60
|
attach_function :once_version, [], :pointer
|
|
61
61
|
attach_function :once_string_free, [:pointer], :void
|
|
62
62
|
attach_function :once_digest_bytes, %i[pointer size_t], :pointer
|
|
63
|
+
attach_function :once_action_key_json, [:string], :pointer
|
|
63
64
|
attach_function :once_cache_put_blob_json, [:string], :pointer
|
|
65
|
+
attach_function :once_cache_put_file_json, [:string], :pointer
|
|
64
66
|
attach_function :once_cache_get_blob_json, [:string], :pointer
|
|
67
|
+
attach_function :once_cache_get_blob_to_file_json, [:string], :pointer
|
|
65
68
|
attach_function :once_cache_has_blob_json, [:string], :pointer
|
|
66
69
|
attach_function :once_cache_put_action_result_json, [:string], :pointer
|
|
67
70
|
attach_function :once_cache_get_action_result_json, [:string], :pointer
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: buildonce
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.33.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tuist GmbH
|
|
@@ -57,5 +57,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
57
57
|
requirements: []
|
|
58
58
|
rubygems_version: 4.0.10
|
|
59
59
|
specification_version: 4
|
|
60
|
-
summary: Ruby
|
|
60
|
+
summary: Ruby software development kit for Once
|
|
61
61
|
test_files: []
|