prebake 0.3.6 → 0.3.7
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/lib/prebake/backends/base.rb +5 -0
- data/lib/prebake/backends/http.rb +25 -8
- data/lib/prebake/ext_builder_patch.rb +9 -9
- 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: 8773dbffbc19494a8ca48af28bf2d68bef4f4ebecae1fd37ff7ec171880b2c4d
|
|
4
|
+
data.tar.gz: a3e243baec1fcebd091c3b7b466f65cb6f74b0cfc6ca5a9f69f81e46cbd2eea8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: efbb626624281ca0488cd549ffa3e8467c7601214153733d7e035c949c9b0c7c275b3668ea616c386b7d2726090e8309613ab7727295940c02fd6f23c1119ac9
|
|
7
|
+
data.tar.gz: 0a0ce57c3e7bbd2f03c8d0c1f9d7883d2d8b46389a0dbaccfed45ae545be05b88fb2e7f40d45fc386ede90b778e3684564b5fafdf02f8765d7a3eb68311e6eec
|
|
@@ -13,6 +13,11 @@ module Prebake
|
|
|
13
13
|
nil
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def fetch_with_checksum(cache_key)
|
|
17
|
+
path = fetch(cache_key)
|
|
18
|
+
[path, path && fetch_checksum(cache_key)]
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
def push(gem_path, cache_key, checksum)
|
|
17
22
|
raise NotImplementedError, "#{self.class}#push not implemented"
|
|
18
23
|
end
|
|
@@ -11,6 +11,9 @@ module Prebake
|
|
|
11
11
|
class Http < Base
|
|
12
12
|
include HttpClient
|
|
13
13
|
|
|
14
|
+
CHECKSUM_HEADER = "X-Prebake-Sha256"
|
|
15
|
+
SHA256_HEX = /\A[0-9a-f]{64}\z/
|
|
16
|
+
|
|
14
17
|
def initialize(url:, token: nil)
|
|
15
18
|
@url = url.chomp("/")
|
|
16
19
|
@token = token
|
|
@@ -19,15 +22,16 @@ module Prebake
|
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
def fetch(cache_key)
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
download(cache_key)&.first
|
|
26
|
+
end
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
# The hosted cache sends the checksum with the gem, so a hit costs one
|
|
29
|
+
# request. For servers that don't, the .sha256 file is fetched instead.
|
|
30
|
+
def fetch_with_checksum(cache_key)
|
|
31
|
+
path, checksum = download(cache_key)
|
|
32
|
+
return [nil, nil] unless path
|
|
33
|
+
|
|
34
|
+
[path, checksum || fetch_checksum(cache_key)]
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
def fetch_checksum(cache_key)
|
|
@@ -82,6 +86,19 @@ module Prebake
|
|
|
82
86
|
|
|
83
87
|
private
|
|
84
88
|
|
|
89
|
+
def download(cache_key)
|
|
90
|
+
response = http_request(:get, gem_uri(cache_key))
|
|
91
|
+
return unless response.is_a?(Net::HTTPSuccess)
|
|
92
|
+
|
|
93
|
+
path = File.join(Dir.tmpdir, "prebake-#{SecureRandom.hex(16)}.gem")
|
|
94
|
+
File.binwrite(path, response.body)
|
|
95
|
+
checksum = response[CHECKSUM_HEADER]
|
|
96
|
+
[path, (checksum if checksum&.match?(SHA256_HEX))]
|
|
97
|
+
rescue StandardError => e
|
|
98
|
+
Logger.debug "Fetch failed for #{cache_key}: #{e.message}"
|
|
99
|
+
nil
|
|
100
|
+
end
|
|
101
|
+
|
|
85
102
|
def gem_uri(cache_key)
|
|
86
103
|
URI("#{@url}/gems/#{cache_key}")
|
|
87
104
|
end
|
|
@@ -34,15 +34,8 @@ module Prebake
|
|
|
34
34
|
platform = Platform.generalized
|
|
35
35
|
cache_key = CacheKey.for(@spec.name, @spec.version.to_s, platform)
|
|
36
36
|
|
|
37
|
-
expected_checksum = Prebake.backend.fetch_checksum(cache_key)
|
|
38
|
-
|
|
39
|
-
if expected_checksum.nil? && Prebake.backend.checksums_supported?
|
|
40
|
-
trigger_rebuild(cache_key)
|
|
41
|
-
return super
|
|
42
|
-
end
|
|
43
|
-
|
|
44
37
|
begin
|
|
45
|
-
cached_gem = Prebake.backend.
|
|
38
|
+
cached_gem, expected_checksum = Prebake.backend.fetch_with_checksum(cache_key)
|
|
46
39
|
rescue StandardError => e
|
|
47
40
|
Logger.debug "Cache fetch error for #{@spec.name}: #{e.message}"
|
|
48
41
|
return super
|
|
@@ -53,6 +46,11 @@ module Prebake
|
|
|
53
46
|
return super
|
|
54
47
|
end
|
|
55
48
|
|
|
49
|
+
if expected_checksum.nil? && Prebake.backend.checksums_supported?
|
|
50
|
+
trigger_rebuild(cache_key)
|
|
51
|
+
return super
|
|
52
|
+
end
|
|
53
|
+
|
|
56
54
|
if checksum_matches?(cache_key, expected_checksum, cached_gem)
|
|
57
55
|
unless PortabilityGuard.portable_for_host?(cached_gem, spec_name: @spec.name)
|
|
58
56
|
# Binary is valid for other hosts; don't delete from backend.
|
|
@@ -83,7 +81,9 @@ module Prebake
|
|
|
83
81
|
|
|
84
82
|
def trigger_rebuild(cache_key)
|
|
85
83
|
Logger.warn "No checksum available for #{cache_key}, removing cached gem"
|
|
86
|
-
|
|
84
|
+
# Without the delete the gem is still there, so the GET below would only download it again.
|
|
85
|
+
return unless Prebake.backend.delete(cache_key)
|
|
86
|
+
|
|
87
87
|
# GET triggers the worker to dispatch a rebuild via GH Actions on cache miss
|
|
88
88
|
leftover = Prebake.backend.fetch(cache_key)
|
|
89
89
|
FileUtils.rm_f(leftover) if leftover
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prebake
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thejus Paul
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Prebake speeds up bundle install by skipping native gem compilation.
|
|
14
14
|
It fetches precompiled binaries for gems like puma, nokogiri, pg, grpc, and bootsnap
|