-
Notifications
You must be signed in to change notification settings - Fork 30
/
gu.ts
84 lines (80 loc) · 2.62 KB
/
gu.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import * as c from './constants'
import * as core from '@actions/core'
import * as semver from 'semver'
import {GRAALVM_PLATFORM} from './constants'
import {exec} from './utils'
import {join} from 'path'
const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress']
const COMPONENT_TO_POST_INSTALL_HOOK = new Map<string, Map<string, string>>([
[
'linux',
new Map<string, string>([
['ruby', 'languages/ruby/lib/truffle/post_install_hook.sh']
// ['R', 'languages/R/bin/configure_fastr'] (GR-36105: cannot be run non-interactively)
])
],
[
'darwin',
new Map<string, string>([
['ruby', 'languages/ruby/lib/truffle/post_install_hook.sh']
// ['R', 'languages/R/bin/configure_fastr'] (GR-36105: cannot be run non-interactively)
])
]
// No post install hooks for Windows (yet)
])
export async function setUpGUComponents(
javaVersion: string,
graalVMVersion: string,
graalVMHome: string,
components: string[],
gdsToken: string
): Promise<void> {
if (components.length == 0) {
return // nothing to do
}
const coercedJavaVersion = semver.coerce(javaVersion)
if (
graalVMVersion === c.VERSION_DEV ||
javaVersion === c.VERSION_DEV ||
(coercedJavaVersion != null && semver.gte(coercedJavaVersion, '21.0.0'))
) {
if (components.length == 1 && components[0] === 'native-image') {
core.warning(
`Please remove "components: 'native-image'" from your workflow file. It is automatically included since GraalVM for JDK 17: https://github.com/oracle/graal/pull/5995`
)
} else {
core.warning(
`Unable to install component(s): '${components.join(
','
)}'. The latest GraalVM dev builds and the upcoming GraalVM for JDK 21 no longer include the GraalVM Updater: https://github.com/oracle/graal/issues/6855`
)
}
} else if (graalVMVersion.startsWith(c.MANDREL_NAMESPACE)) {
core.warning(
`Mandrel does not support GraalVM component(s): '${components.join(',')}'`
)
} else {
await installGUComponents(gdsToken, graalVMHome, components)
}
}
async function installGUComponents(
gdsToken: string,
graalVMHome: string,
components: string[]
): Promise<void> {
await exec('gu', BASE_FLAGS.concat(components), {
env: {
...process.env,
GRAAL_EE_DOWNLOAD_TOKEN: gdsToken
}
})
const platformHooks = COMPONENT_TO_POST_INSTALL_HOOK.get(GRAALVM_PLATFORM)
if (platformHooks) {
for (const component of components) {
const postInstallHook = platformHooks.get(component)
if (postInstallHook) {
await exec(`"${join(graalVMHome, postInstallHook)}"`)
}
}
}
}