Skip to content

Commit 266d931

Browse files
committed
Add truffleruby JVM EA build
1 parent 5d0425d commit 266d931

File tree

2 files changed

+133
-1
lines changed

2 files changed

+133
-1
lines changed

.github/workflows/build.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,19 @@ jobs:
7979
fail-fast: false
8080
matrix:
8181
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, ubuntu-22.04-arm, ubuntu-24.04-arm, macos-13, macos-14 ]
82-
name: [ '-head', '+graalvm-head' ]
82+
name: [ '-head', '+graalvm-head', '+graalvm-ea' ]
83+
continue-on-error: ${{ matrix.name == '+graalvm-ea' }}
8384
runs-on: ${{ matrix.os }}
8485
steps:
8586
- name: Clone truffleruby
8687
uses: actions/checkout@v4
8788
with:
8889
repository: oracle/truffleruby
8990
ref: ${{ needs.prepare.outputs.commit }}
91+
- uses: actions/checkout@v4
92+
with:
93+
path: truffleruby-dev-builder
94+
if: matrix.name == '+graalvm-ea'
9095

9196
- name: Set platform
9297
id: platform
@@ -130,12 +135,17 @@ jobs:
130135
- name: Build TruffleRuby (jvm)
131136
run: jt build --env jvm-ce-libgraal
132137
if: matrix.name == '+graalvm-head'
138+
- name: Build TruffleRuby (jvm-ea)
139+
run: ruby truffleruby-dev-builder/ea-build-with-truffleruby-master.rb
140+
if: matrix.name == '+graalvm-ea'
133141

134142
- run: mkdir -p ~/.rubies
135143
- run: mv $(jt mx --env native standalone-home --type=native ruby) ~/.rubies/truffleruby${{ matrix.name }}
136144
if: matrix.name == '-head'
137145
- run: mv $(jt mx --env jvm-ce-libgraal standalone-home --type=jvm ruby) ~/.rubies/truffleruby${{ matrix.name }}
138146
if: matrix.name == '+graalvm-head'
147+
- run: mv truffleruby-jvm-ea-master-build ~/.rubies/truffleruby${{ matrix.name }}
148+
if: matrix.name == '+graalvm-ea'
139149
- name: Create archive
140150
run: tar czf truffleruby${{ matrix.name }}-${{ steps.platform.outputs.platform }}.tar.gz -C ~/.rubies truffleruby${{ matrix.name }}
141151

ea-build-with-truffleruby-master.rb

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
require "fileutils"
2+
require "json"
3+
4+
include FileUtils::Verbose
5+
6+
def sh(*args, **kwargs)
7+
puts "::group::$ #{args.join(" ")}"
8+
system(*args, exception: true, **kwargs)
9+
puts "::endgroup::"
10+
end
11+
12+
os = case RbConfig::CONFIG['host_os']
13+
in /linux/ then "linux"
14+
in /darwin/ then "darwin"
15+
end
16+
17+
arch = case RbConfig::CONFIG['host_cpu']
18+
in /amd64|x86_64|x64/ then "amd64"
19+
in /arm64|aarch64/ then "aarch64"
20+
end
21+
22+
url = "https://github.com/graalvm/graal-languages-ea-builds/raw/HEAD/truffleruby/versions/latest-jvm-#{os}-#{arch}.url"
23+
puts url
24+
url = `curl -Ls #{url}`
25+
puts url
26+
27+
ea_build_archive = "truffleruby-jvm-ea-build.tar.gz"
28+
29+
unless File.exist? ea_build_archive
30+
sh "wget", "--progress=dot:mega", "-O", ea_build_archive, url
31+
end
32+
33+
ea_build = `tar tf truffleruby-jvm-ea-build.tar.gz | head -1`[/^(.+?)\//, 1]
34+
puts "EA build dir: #{ea_build}"
35+
36+
unless Dir.exist? ea_build
37+
sh "tar", "xf", ea_build_archive
38+
end
39+
40+
ea_files = Dir.glob("**/{*,.*}", base: ea_build)
41+
42+
ea_commit_info = File.read("#{ea_build}/release")[/COMMIT_INFO=(.+)/, 1]
43+
ea_truffle_commit = JSON.load(ea_commit_info).fetch("truffle").fetch("commit.rev")
44+
puts "EA build Truffle commit: #{ea_truffle_commit}"
45+
46+
# Build with the same truffle version as in ea_build
47+
sh "git", "checkout", ea_truffle_commit, chdir: "../graal"
48+
# unset JAVA_HOME to download the correct JDK from graal common.json
49+
ENV.delete "JAVA_HOME"
50+
sh({ "JT_IMPORTS_DONT_ASK" => "true" }, "bin/jt", "build")
51+
52+
master_build = "mxbuild/truffleruby-jvm"
53+
54+
master_files = Dir.glob("**/{*,.*}", base: master_build)
55+
56+
result = "truffleruby-jvm-ea-master-build"
57+
58+
EXPECTED_DIFFERENT = %w[
59+
jvm
60+
]
61+
62+
OVERRIDE_WITH_EA_BUILD = %w[
63+
jvm
64+
release
65+
]
66+
67+
EXPECTED_EXTRA_IN_EA_BUILD = %w[
68+
license-information-user-manual.zip
69+
DISCLAIMER.txt
70+
71+
modules/nativebridge.jar
72+
modules/sulong-enterprise-native.jar
73+
modules/sulong-enterprise.jar
74+
modules/truffle-enterprise.jar
75+
]
76+
77+
EXPECTED_EXTRA_IN_MASTER_BUILD = %w[
78+
3rd_party_licenses_truffleruby.txt
79+
]
80+
81+
# There might be more or less files in these directories, that's OK, these are "Ruby home" files
82+
CHANGES_ALLOWED_IN_MASTER_BUILD = %w[
83+
bin
84+
doc
85+
lib
86+
logo
87+
src
88+
]
89+
90+
def check_diff(a_files, b_files, expected_extra)
91+
diff = a_files - b_files
92+
diff = diff.reject { |path| expected_extra.any? { |e| path.start_with?(e) } }
93+
unless diff.empty?
94+
puts diff
95+
raise "ERROR: Unexpected files!"
96+
end
97+
end
98+
99+
puts "extra master files (master_files - ea_files)"
100+
check_diff(master_files, ea_files, EXPECTED_EXTRA_IN_MASTER_BUILD + CHANGES_ALLOWED_IN_MASTER_BUILD + EXPECTED_DIFFERENT)
101+
102+
puts "extra EA files (ea_files - master_files)"
103+
check_diff(ea_files, master_files, EXPECTED_EXTRA_IN_EA_BUILD + EXPECTED_DIFFERENT)
104+
105+
rm_rf result
106+
cp_r master_build, result
107+
108+
EXPECTED_EXTRA_IN_MASTER_BUILD.each { |path|
109+
rm_r "#{result}/#{path}" if File.exist? "#{result}/#{path}"
110+
}
111+
112+
(EXPECTED_EXTRA_IN_EA_BUILD + OVERRIDE_WITH_EA_BUILD).each { |path|
113+
rm_r "#{result}/#{path}" if File.exist? "#{result}/#{path}"
114+
cp_r "#{ea_build}/#{path}", "#{result}/#{path}"
115+
}
116+
117+
result_files = Dir.glob("**/{*,.*}", base: result)
118+
puts "extra result files (result_files - ea_files)"
119+
check_diff(result_files, ea_files, [])
120+
121+
# Run specs after to make sure it works correctly:
122+
sh "bin/jt", "-u", "#{Dir.pwd}/#{result}", "test", "fast"

0 commit comments

Comments
 (0)