Skip to content

Commit b99fbcb

Browse files
Add build_manifest.json concept for reproducible build
1 parent 0418907 commit b99fbcb

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ wapm_packages
1010
compile_commands.json
1111

1212
html
13+
14+
build_manifest.json

Rakefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ BUILD_SOURCES = {
2222
}
2323
}
2424

25+
# Respect revisions specified in build_manifest.json, which is usually generated on GitHub Actions.
26+
if File.exist?("build_manifest.json")
27+
begin
28+
manifest = JSON.parse(File.read("build_manifest.json"))
29+
manifest["ruby_revisions"].each do |name, rev|
30+
BUILD_SOURCES[name]["rev"] = rev
31+
end
32+
rescue StandardError
33+
$stderr.puts "Failed to load build_manifest.json"
34+
end
35+
end
36+
2537
FULL_EXTS =
2638
"bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl"
2739

tasks/ci.rake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
def latest_build_sources
2+
BUILD_SOURCES.map do |name, src|
3+
case src[:type]
4+
when "github"
5+
url = "https://api.github.com/repos/#{src[:repo]}/commits/#{src[:rev]}"
6+
revision = OpenURI.open_uri(url) { |f| JSON.load(f.read) }
7+
[name, revision["sha"]]
8+
else
9+
raise "#{src[:type]} is not supported to pin source revision"
10+
end
11+
end.to_h
12+
end
113
namespace :ci do
214
task :rake_task_matrix do
315
require "pathname"
@@ -29,4 +41,9 @@ namespace :ci do
2941
end
3042
print JSON.generate(entries)
3143
end
44+
45+
task :build_manifest do
46+
content = JSON.generate({ ruby_revisions: latest_build_sources })
47+
File.write("build_manifest.json", content)
48+
end
3249
end

0 commit comments

Comments
 (0)