Skip to content

Commit

Permalink
Run the installer in the runner, not in the cache server
Browse files Browse the repository at this point in the history
This might prevent a class of errors in Windows

On the other hand this restore the paths to what we were
using prior to introducing the caching behaviour mechanism

The important change in the commit is the use of fs.cpSync
  • Loading branch information
paulo-ferraz-oliveira committed Jan 31, 2024
1 parent b348e43 commit ff6f757
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
21 changes: 15 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10772,16 +10772,25 @@ async function installTool(opts) {
core.debug(` ... it is, at ${cachePath}`)
}

// This makes sure we run, e.g. in Windows, the installer in the runner
// We're not caching the install, just the downloaded tool
const runnerToolPath = path.join(
process.env.RUNNER_TEMP,
'.setup-beam',
toolName,
)
fs.cpSync(cachePath, runnerToolPath, { recursive: true })

core.debug('Performing post extract operations...')
await platformOpts.postExtract(cachePath)
await platformOpts.postExtract(runnerToolPath)

core.debug(`Adding ${cachePath}'s bin to system path`)
const catchPathBin = path.join(cachePath, 'bin')
core.addPath(catchPathBin)
core.debug(`Adding ${runnerToolPath}' bin to system path`)
const runnerToolPathBin = path.join(runnerToolPath, 'bin')
core.addPath(runnerToolPathBin)

const installDirForVarName = `INSTALL_DIR_FOR_${toolName}`.toUpperCase()
core.debug(`Exporting ${installDirForVarName} as ${cachePath}`)
core.exportVariable(installDirForVarName, cachePath)
core.debug(`Exporting ${installDirForVarName} as ${runnerToolPath}`)
core.exportVariable(installDirForVarName, runnerToolPath)

core.info(`Installed ${installOpts.tool} version`)
const [cmd, args] = platformOpts.reportVersion()
Expand Down
21 changes: 15 additions & 6 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,16 +952,25 @@ async function installTool(opts) {
core.debug(` ... it is, at ${cachePath}`)
}

// This makes sure we run, e.g. in Windows, the installer in the runner
// We're not caching the install, just the downloaded tool
const runnerToolPath = path.join(
process.env.RUNNER_TEMP,
'.setup-beam',
toolName,
)
fs.cpSync(cachePath, runnerToolPath, { recursive: true })

core.debug('Performing post extract operations...')
await platformOpts.postExtract(cachePath)
await platformOpts.postExtract(runnerToolPath)

core.debug(`Adding ${cachePath}'s bin to system path`)
const catchPathBin = path.join(cachePath, 'bin')
core.addPath(catchPathBin)
core.debug(`Adding ${runnerToolPath}' bin to system path`)
const runnerToolPathBin = path.join(runnerToolPath, 'bin')
core.addPath(runnerToolPathBin)

const installDirForVarName = `INSTALL_DIR_FOR_${toolName}`.toUpperCase()
core.debug(`Exporting ${installDirForVarName} as ${cachePath}`)
core.exportVariable(installDirForVarName, cachePath)
core.debug(`Exporting ${installDirForVarName} as ${runnerToolPath}`)
core.exportVariable(installDirForVarName, runnerToolPath)

core.info(`Installed ${installOpts.tool} version`)
const [cmd, args] = platformOpts.reportVersion()
Expand Down

0 comments on commit ff6f757

Please sign in to comment.