Skip to content

Commit

Permalink
[GR-44550] Adopt common.jsonnet
Browse files Browse the repository at this point in the history
PullRequest: mx/1572
  • Loading branch information
eregon committed Mar 1, 2023
2 parents 3b5ad88 + f0c25a4 commit 18b5c73
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 274 deletions.
165 changes: 65 additions & 100 deletions ci.jsonnet
Original file line number Diff line number Diff line change
@@ -1,96 +1,68 @@
local common = import "common.json";
local jdks = common.jdks;
local common = import "ci/common.jsonnet";
local versions = {
python3: "3.8.10",
pylint: "2.4.4",
gcc: "4.9.2",
ruby: "2.7.2",
git: "1.8.3",
devtoolset: "7",
make: "3.83",
binutils: "2.34",
capstone: "4.0.2",
};
local catch_files = common.catch_files + [
local extra_catch_files = [
"Cannot decode '(?P<filename>[^']+)'"
];

local composable(o) =
std.foldl(function(obj, key)
obj +
if std.type(o[key]) == "object" then
{ [key] +: composable(o[key]) }
else
{ [key] : o[key] },
std.objectFields(o),
{}
);

# this uses <os>_<arch> or <os> depending on what field is available in 'common.json'
# if 'common.json' is migrated to jsonnet, we could simplify this by providing reasonable defaults there
local deps(os, arch) = composable(if std.objectHasAll(common.sulong.deps, os) then common.sulong.deps[os] else common.sulong.deps[os + "_" + arch])
+ composable(if std.objectHasAll(common.sulong.deps, "common") then common.sulong.deps.common else {});
local remove_mx_from_packages(obj) = obj + {
# Exclude mx from packages
packages: {
[key]: obj.packages[key]
for key in std.objectFields(obj.packages) if key != "mx"
},
};

# Common configuration for all gates. Specific gates are defined
# by the functions at the bottom of this object.
#
# This structure allows for easily changing the
# platform details of a gate builder.
local with(os, arch, java_release, timelimit="15:00") = deps(os, arch) + {
local with(platform, java_release, timelimit="15:00") = {
local os = platform.os,
local arch = platform.arch,
local path(unixpath) = if os == "windows" then std.strReplace(unixpath, "/", "\\") else unixpath,
local exe(unixpath) = if os == "windows" then path(unixpath) + ".exe" else unixpath,
local copydir(src, dst) = if os == "windows" then ["xcopy", path(src), path(dst), "/e", "/i", "/q"] else ["cp", "-r", src, dst],
local mx_copy_dir = path("${PWD}/../path with a space"),
local mx = path("./mx"),
local openssl102_for_ruby = if os == "linux" && arch == "amd64" then {
docker: {
image: "phx.ocir.io/oraclelabs2/c_graal/buildslave:buildslave_ol7",
mount_modules: true,
},
} else {},

# Creates a builder name in "top down" order: first "what it is" (e.g. gate) then Java version followed by OS and arch
with_name(prefix):: self + {
name: "%s-jdk%s-%s-%s" % [prefix, java_release, os, arch],
local jdk = common.jdks["labsjdk-ee-%s" % java_release],

local base = platform + jdk + common.deps.eclipse + common.deps.pylint + common.deps.sulong + common.deps.svm + {
# Creates a builder name in "top down" order: first "what it is" (e.g. gate) then Java version followed by OS and arch
name: "%s-jdk%s-%s-%s" % [self.prefix, java_release, os, arch],
targets: ["gate"],
catch_files+: extra_catch_files,
environment: {
ECLIPSE_EXE: if os == "darwin" then "$ECLIPSE/Contents/MacOS/eclipse" else exe("$ECLIPSE/eclipse"),
# Required to keep pylint happy on Darwin
# https://coderwall.com/p/-k_93g/mac-os-x-valueerror-unknown-locale-utf-8-in-python
LC_ALL: "en_US.UTF-8",
},
timelimit: timelimit,
setup: [
# Copy mx to a directory with a space in its name to ensure
# mx can work in that context.
copydir("$PWD", mx_copy_dir),
["cd", mx_copy_dir],
] + if os == "darwin" then [
# Need to remove the com.apple.quarantine attribute from Eclipse otherwise
# it will fail to start on later macOS versions.
["xattr", "-d", "-r", "com.apple.quarantine", "${ECLIPSE}"],
] else [],

java_home_in_env(suite_dir, suite_name):: [
# Set JAVA_HOME *only* in <suite_dir>/mx.<suite>/env
["python3", "-c", "import os; open(r'" + path(suite_dir + "/mx.%s/env" % suite_name) + "', 'w').write('JAVA_HOME=' + os.environ['JAVA_HOME'])"],
["unset", "JAVA_HOME"],
],
},

catch_files: catch_files,

python_version: "3",
targets: ["gate"],
capabilities: [os, arch],
packages+: {
"pip:pylint": "==" + versions.pylint,
"python3": "==" + versions.python3,
} + if os == "linux" then {
"devtoolset": "==" + versions.devtoolset,
} else {},
downloads+: common.downloads.eclipse.downloads + {
JAVA_HOME: jdks["labsjdk-ee-%s" % java_release]
},
environment: {
ECLIPSE_EXE: if os == "darwin" then "$ECLIPSE/Contents/MacOS/eclipse" else exe("$ECLIPSE/eclipse"),
# Required to keep pylint happy on Darwin
# https://coderwall.com/p/-k_93g/mac-os-x-valueerror-unknown-locale-utf-8-in-python
LC_ALL: "en_US.UTF-8",
with_name(prefix):: base + {
prefix:: prefix,
},
timelimit: timelimit,
setup: [
# Copy mx to a directory with a space in its name to ensure
# mx can work in that context.
copydir("$PWD", mx_copy_dir),
["cd", mx_copy_dir],
] + if os == "darwin" then [
# Need to remove the com.apple.quarantine attribute from Eclipse otherwise
# it will fail to start on later macOS versions.
["xattr", "-d", "-r", "com.apple.quarantine", "${ECLIPSE}"],
] else [],

java_home_in_env(suite_dir, suite_name):: [
# Set JAVA_HOME *only* in <suite_dir>/mx.<suite>/env
["python3", "-c", "import os; open(r'" + path(suite_dir + "/mx.%s/env" % suite_name) + "', 'w').write('JAVA_HOME=' + os.environ['JAVA_HOME'])"],
["unset", "JAVA_HOME"],
],

# Specific gate builders are defined by the following functions

Expand Down Expand Up @@ -171,11 +143,7 @@ local with(os, arch, java_release, timelimit="15:00") = deps(os, arch) + {
],
},

build_truffleruby:: self.with_name("gate-build-truffleruby") + deps(os, arch) + openssl102_for_ruby + {
packages+: {
ruby: ">=" + versions.ruby,
python3: "==" + versions.python3,
},
build_truffleruby:: self.with_name("gate-build-truffleruby") + common.deps.sulong + common.deps.truffleruby + {
environment+: {
PATH: "$BUILD_DIR/main:$PATH", # add ./mx on PATH
},
Expand All @@ -187,13 +155,9 @@ local with(os, arch, java_release, timelimit="15:00") = deps(os, arch) + {
],
},

build_graalvm_ce:: self.with_name("gate-build-graalvm-ce") + deps(os, arch) + {
build_graalvm_ce:: self.with_name("gate-build-graalvm-ce") + common.deps.sulong + {
packages+: {
git: ">=" + versions.git,
devtoolset: "==" + versions.devtoolset,
make: ">=" + versions.make,
binutils: "==" + versions.binutils,
python3: "==" + versions.python3,
},
run: [
[mx, "sclone", "--kind", "git", "--source", "https://github.com/oracle/graal.git", "--dest", "../graal"],
Expand Down Expand Up @@ -234,25 +198,26 @@ local with(os, arch, java_release, timelimit="15:00") = deps(os, arch) + {
specVersion: "3",

# Overlay
overlay: "b83990a5afcd4d1e527125c572ecd7e060748f05",
overlay: "4729580ae1f0eb78190527e388c3b5f71eafdac0",

# For use by overlay
versions:: versions,
catch_files:: catch_files,

builds: [
with("linux", "amd64", 19).gate,
with("linux", "amd64", 19).fetchjdk_test,
with("linux", "amd64", 19).bisect_test,
with("windows", "amd64", 19).gate,
with("darwin", "amd64", 19, timelimit="25:00").gate,
with("linux", "amd64", 19).bench_test,
with("linux", "amd64", 19).jmh_test,
with("linux", "amd64", 19, timelimit="20:00").proftool_test,
with("linux", "amd64", 19, timelimit="20:00").build_truffleruby,
with("linux", "amd64", 19, timelimit="20:00").build_graalvm_ce,
with("linux", "amd64", 19).mx_unit_test,
with("linux", "amd64", 19).version_update_check,
with("linux", "amd64", 19).post_merge_tag_version,
]
extra_catch_files:: extra_catch_files,

local builds = [
with(common.linux_amd64, 19).gate,
with(common.linux_amd64, 19).fetchjdk_test,
with(common.linux_amd64, 19).bisect_test,
with(common.windows_amd64, 19).gate,
with(common.darwin_amd64, 19, timelimit="25:00").gate,
with(common.linux_amd64, 19).bench_test,
with(common.linux_amd64, 19).jmh_test,
with(common.linux_amd64, 19, timelimit="20:00").proftool_test,
with(common.linux_amd64, 19, timelimit="20:00").build_truffleruby,
with(common.linux_amd64, 19, timelimit="20:00").build_graalvm_ce,
with(common.linux_amd64, 19).mx_unit_test,
with(common.linux_amd64, 19).version_update_check,
with(common.linux_amd64, 19).post_merge_tag_version,
],
builds: [remove_mx_from_packages(b) for b in builds],
}

0 comments on commit 18b5c73

Please sign in to comment.