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().
This commit is contained in:
MSP-Greg
2020-07-01 21:22:43 +02:00
committed by Benoit Daloze
parent 5c4fc21c57
commit 271876da60
2 changed files with 18 additions and 4 deletions
Generated Vendored
+9 -2
View File
@@ -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))
+9 -2
View File
@@ -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))