From 271876da60474401e13f5c05ad5cffb5153e7046 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 14 Jun 2020 10:19:07 -0500 Subject: [PATCH] Allow running external function before 'bundle install' External actions may use setup-ruby, and some actions make changes/additions to the build environment. These may be needed for dependencies. Hence, allow those external actions to run code before 'bundle install'. This is done by passing a function as a parameter to setupRuby(). --- dist/index.js | 11 +++++++++-- index.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1466872..0839809 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2202,14 +2202,14 @@ const inputDefaults = { // entry point when this action is run on its own async function run() { try { - await setupRuby({}) + await setupRuby() } catch (error) { core.setFailed(error.message) } } // entry point when this action is run from other actions -async function setupRuby(options) { +async function setupRuby(options = {}) { const inputs = { ...options } for (const key in inputDefaults) { if (!inputs.hasOwnProperty(key)) { @@ -2238,6 +2238,13 @@ async function setupRuby(options) { setupPath(newPathEntries) + // When setup-ruby is used by other actions, this allows code in them to run + // before 'bundle install'. Installed dependencies may require additional + // libraries & headers, build tools, etc. + if (inputs['afterSetupPathHook'] instanceof Function) { + await inputs['afterSetupPathHook']({ platform, rubyPrefix, engine, version }) + } + if (inputs['bundler'] !== 'none') { await common.measure('Installing Bundler', async () => installBundler(inputs['bundler'], platform, rubyPrefix, engine, version)) diff --git a/index.js b/index.js index 11c1c34..4fbaa81 100644 --- a/index.js +++ b/index.js @@ -16,14 +16,14 @@ const inputDefaults = { // entry point when this action is run on its own export async function run() { try { - await setupRuby({}) + await setupRuby() } catch (error) { core.setFailed(error.message) } } // entry point when this action is run from other actions -export async function setupRuby(options) { +export async function setupRuby(options = {}) { const inputs = { ...options } for (const key in inputDefaults) { if (!inputs.hasOwnProperty(key)) { @@ -52,6 +52,13 @@ export async function setupRuby(options) { setupPath(newPathEntries) + // When setup-ruby is used by other actions, this allows code in them to run + // before 'bundle install'. Installed dependencies may require additional + // libraries & headers, build tools, etc. + if (inputs['afterSetupPathHook'] instanceof Function) { + await inputs['afterSetupPathHook']({ platform, rubyPrefix, engine, version }) + } + if (inputs['bundler'] !== 'none') { await common.measure('Installing Bundler', async () => installBundler(inputs['bundler'], platform, rubyPrefix, engine, version))