diff --git a/src/dependencies.ts b/src/dependencies.ts new file mode 100644 index 0000000..63aa273 --- /dev/null +++ b/src/dependencies.ts @@ -0,0 +1,33 @@ +import * as core from '@actions/core' +import {GRAALVM_PLATFORM} from './constants' +import {exec} from '@actions/exec' + +const APT_GET_INSTALL_BASE = 'sudo apt-get -y --no-upgrade install' +const COMPONENT_TO_DEPS = new Map>([ + [ + 'linux', + new Map([ + ['nodejs', `${APT_GET_INSTALL_BASE} g++ make`], + ['ruby', `${APT_GET_INSTALL_BASE} make gcc libssl-dev libz-dev`], + [ + 'R', + `${APT_GET_INSTALL_BASE} libgomp1 build-essential gfortran libxml2 libc++-dev` + ] + ]) + ], + ['darwin', new Map([['ruby', 'brew install openssl']])] +]) + +export async function setUpDependencies(components: string[]): Promise { + const platformDeps = COMPONENT_TO_DEPS.get(GRAALVM_PLATFORM) + if (platformDeps) { + for (const component of components) { + const depCommand = platformDeps.get(component) + if (depCommand) { + core.startGroup(`Installing dependencies for ${component}...`) + await exec(depCommand) + core.endGroup() + } + } + } +} diff --git a/src/main.ts b/src/main.ts index 0ed2ece..1af24c4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,7 @@ import * as core from '@actions/core' import * as graalvm from './graalvm' import {join} from 'path' import {mkdirP} from '@actions/io' +import {setUpDependencies} from './dependencies' import {setUpGraalVMTrunk} from './graalvm-trunk' import {setUpWindowsEnvironment} from './msvc' @@ -18,6 +19,7 @@ async function run(): Promise { if (c.IS_WINDOWS) { setUpWindowsEnvironment() } + setUpDependencies(components) await mkdirP(c.GRAALVM_BASE)