Compare commits

...
3 Commits
5 changed files with 108 additions and 41 deletions
+6 -1
View File
@@ -77,7 +77,7 @@ export function getVirtualEnvironmentName() {
throw new Error(`Unknown ImageOS ${imageOS}`) throw new Error(`Unknown ImageOS ${imageOS}`)
} }
export function shouldExtractInToolCache(engine, version) { export function shouldUseToolCache(engine, version) {
return engine === 'ruby' && !isHeadVersion(version) return engine === 'ruby' && !isHeadVersion(version)
} }
@@ -99,6 +99,11 @@ export function getToolCacheRubyPrefix(platform, version) {
return path.join(toolCache, 'Ruby', version, 'x64') return path.join(toolCache, 'Ruby', version, 'x64')
} }
export function createToolCacheCompleteFile(toolCacheRubyPrefix) {
const completeFile = `${toolCacheRubyPrefix}.complete`
fs.writeFileSync(completeFile, '')
}
// convert windows path like C:\Users\runneradmin to /c/Users/runneradmin // convert windows path like C:\Users\runneradmin to /c/Users/runneradmin
export function win2nix(path) { export function win2nix(path) {
if (/^[A-Z]:/i.test(path)) { if (/^[A-Z]:/i.test(path)) {
Generated Vendored
+55 -21
View File
@@ -27712,31 +27712,47 @@ async function install(platform, engine, version) {
} }
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length) const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
let rubyPrefix let rubyPrefix, inToolCache
if (common.shouldExtractInToolCache(engine, version)) { if (common.shouldUseToolCache(engine, version)) {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version) inToolCache = tc.find('Ruby', version)
if (inToolCache) {
rubyPrefix = inToolCache
} else {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version)
}
} else { } else {
rubyPrefix = `${drive}:\\${base}` rubyPrefix = `${drive}:\\${base}`
} }
const parentDir = path.dirname(rubyPrefix)
let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version) let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)
common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths]) common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])
if (!inToolCache) {
await downloadAndExtract(engine, version, url, base, rubyPrefix);
}
return rubyPrefix
}
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
const parentDir = path.dirname(rubyPrefix)
const downloadPath = await common.measure('Downloading Ruby', async () => { const downloadPath = await common.measure('Downloading Ruby', async () => {
console.log(url) console.log(url)
return await tc.downloadTool(url) return await tc.downloadTool(url)
}) })
await common.measure('Extracting Ruby', async () => await common.measure('Extracting Ruby', async () =>
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${parentDir}`], { silent: true })) exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${parentDir}`], {silent: true}))
if (base !== path.basename(rubyPrefix)) { if (base !== path.basename(rubyPrefix)) {
await io.mv(path.join(parentDir, base), rubyPrefix) await io.mv(path.join(parentDir, base), rubyPrefix)
} }
return rubyPrefix if (common.shouldUseToolCache(engine, version)) {
common.createToolCacheCompleteFile(rubyPrefix)
}
} }
async function setupMingw(version) { async function setupMingw(version) {
@@ -32100,8 +32116,9 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isStableVersion", function() { return isStableVersion; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isStableVersion", function() { return isStableVersion; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hashFile", function() { return hashFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hashFile", function() { return hashFile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldExtractInToolCache", function() { return shouldExtractInToolCache; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldUseToolCache", function() { return shouldUseToolCache; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getToolCacheRubyPrefix", function() { return getToolCacheRubyPrefix; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getToolCacheRubyPrefix", function() { return getToolCacheRubyPrefix; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createToolCacheCompleteFile", function() { return createToolCacheCompleteFile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "win2nix", function() { return win2nix; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "win2nix", function() { return win2nix; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupPath", function() { return setupPath; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupPath", function() { return setupPath; });
const os = __webpack_require__(87) const os = __webpack_require__(87)
@@ -32183,7 +32200,7 @@ function getVirtualEnvironmentName() {
throw new Error(`Unknown ImageOS ${imageOS}`) throw new Error(`Unknown ImageOS ${imageOS}`)
} }
function shouldExtractInToolCache(engine, version) { function shouldUseToolCache(engine, version) {
return engine === 'ruby' && !isHeadVersion(version) return engine === 'ruby' && !isHeadVersion(version)
} }
@@ -32205,6 +32222,11 @@ function getToolCacheRubyPrefix(platform, version) {
return path.join(toolCache, 'Ruby', version, 'x64') return path.join(toolCache, 'Ruby', version, 'x64')
} }
function createToolCacheCompleteFile(toolCacheRubyPrefix) {
const completeFile = `${toolCacheRubyPrefix}.complete`
fs.writeFileSync(completeFile, '')
}
// convert windows path like C:\Users\runneradmin to /c/Users/runneradmin // convert windows path like C:\Users\runneradmin to /c/Users/runneradmin
function win2nix(path) { function win2nix(path) {
if (/^[A-Z]:/i.test(path)) { if (/^[A-Z]:/i.test(path)) {
@@ -51402,6 +51424,8 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
const gem = path.join(rubyPrefix, 'bin', 'gem') const gem = path.join(rubyPrefix, 'bin', 'gem')
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document']) await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
} }
core.exportVariable('BUNDLER_VERSION', bundlerVersion)
} }
async function bundleInstall(gemfile, lockFile, platform, engine, version) { async function bundleInstall(gemfile, lockFile, platform, engine, version) {
@@ -52908,7 +52932,6 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; });
const os = __webpack_require__(87) const os = __webpack_require__(87)
const path = __webpack_require__(622) const path = __webpack_require__(622)
const core = __webpack_require__(186)
const exec = __webpack_require__(514) const exec = __webpack_require__(514)
const io = __webpack_require__(436) const io = __webpack_require__(436)
const tc = __webpack_require__(188) const tc = __webpack_require__(188)
@@ -52925,24 +52948,33 @@ function getAvailableVersions(platform, engine) {
} }
async function install(platform, engine, version) { async function install(platform, engine, version) {
return await downloadAndExtract(platform, engine, version) let rubyPrefix, inToolCache
} if (common.shouldUseToolCache(engine, version)) {
inToolCache = tc.find('Ruby', version)
async function downloadAndExtract(platform, engine, version) { if (inToolCache) {
let rubyPrefix rubyPrefix = inToolCache
if (common.shouldExtractInToolCache(engine, version)) { } else {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version) rubyPrefix = common.getToolCacheRubyPrefix(platform, version)
}
} else if (windows) { } else if (windows) {
rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`) rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`)
} else { } else {
rubyPrefix = path.join(os.homedir(), '.rubies', `${engine}-${version}`) rubyPrefix = path.join(os.homedir(), '.rubies', `${engine}-${version}`)
} }
const parentDir = path.dirname(rubyPrefix)
// Set the PATH now, so the MSYS2 'tar' is in Path on Windows // Set the PATH now, so the MSYS2 'tar' is in Path on Windows
common.setupPath([path.join(rubyPrefix, 'bin')]) common.setupPath([path.join(rubyPrefix, 'bin')])
if (!inToolCache) {
await downloadAndExtract(platform, engine, version, rubyPrefix);
}
return rubyPrefix
}
async function downloadAndExtract(platform, engine, version, rubyPrefix) {
const parentDir = path.dirname(rubyPrefix)
await io.rmRF(rubyPrefix) await io.rmRF(rubyPrefix)
await io.mkdirP(parentDir) await io.mkdirP(parentDir)
@@ -52955,13 +52987,15 @@ async function downloadAndExtract(platform, engine, version) {
await common.measure('Extracting Ruby', async () => { await common.measure('Extracting Ruby', async () => {
if (windows) { if (windows) {
// Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths // Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
await exec.exec('tar', [ '-xz', '-C', common.win2nix(parentDir), '-f', common.win2nix(downloadPath) ]) await exec.exec('tar', ['-xz', '-C', common.win2nix(parentDir), '-f', common.win2nix(downloadPath)])
} else { } else {
await exec.exec('tar', [ '-xz', '-C', parentDir, '-f', downloadPath ]) await exec.exec('tar', ['-xz', '-C', parentDir, '-f', downloadPath])
} }
}) })
return rubyPrefix if (common.shouldUseToolCache(engine, version)) {
common.createToolCacheCompleteFile(rubyPrefix)
}
} }
function getDownloadURL(platform, engine, version) { function getDownloadURL(platform, engine, version) {
+2
View File
@@ -230,6 +230,8 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
const gem = path.join(rubyPrefix, 'bin', 'gem') const gem = path.join(rubyPrefix, 'bin', 'gem')
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document']) await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
} }
core.exportVariable('BUNDLER_VERSION', bundlerVersion)
} }
async function bundleInstall(gemfile, lockFile, platform, engine, version) { async function bundleInstall(gemfile, lockFile, platform, engine, version) {
+23 -13
View File
@@ -1,6 +1,5 @@
const os = require('os') const os = require('os')
const path = require('path') const path = require('path')
const core = require('@actions/core')
const exec = require('@actions/exec') const exec = require('@actions/exec')
const io = require('@actions/io') const io = require('@actions/io')
const tc = require('@actions/tool-cache') const tc = require('@actions/tool-cache')
@@ -17,24 +16,33 @@ export function getAvailableVersions(platform, engine) {
} }
export async function install(platform, engine, version) { export async function install(platform, engine, version) {
return await downloadAndExtract(platform, engine, version) let rubyPrefix, inToolCache
} if (common.shouldUseToolCache(engine, version)) {
inToolCache = tc.find('Ruby', version)
async function downloadAndExtract(platform, engine, version) { if (inToolCache) {
let rubyPrefix rubyPrefix = inToolCache
if (common.shouldExtractInToolCache(engine, version)) { } else {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version) rubyPrefix = common.getToolCacheRubyPrefix(platform, version)
}
} else if (windows) { } else if (windows) {
rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`) rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`)
} else { } else {
rubyPrefix = path.join(os.homedir(), '.rubies', `${engine}-${version}`) rubyPrefix = path.join(os.homedir(), '.rubies', `${engine}-${version}`)
} }
const parentDir = path.dirname(rubyPrefix)
// Set the PATH now, so the MSYS2 'tar' is in Path on Windows // Set the PATH now, so the MSYS2 'tar' is in Path on Windows
common.setupPath([path.join(rubyPrefix, 'bin')]) common.setupPath([path.join(rubyPrefix, 'bin')])
if (!inToolCache) {
await downloadAndExtract(platform, engine, version, rubyPrefix);
}
return rubyPrefix
}
async function downloadAndExtract(platform, engine, version, rubyPrefix) {
const parentDir = path.dirname(rubyPrefix)
await io.rmRF(rubyPrefix) await io.rmRF(rubyPrefix)
await io.mkdirP(parentDir) await io.mkdirP(parentDir)
@@ -47,13 +55,15 @@ async function downloadAndExtract(platform, engine, version) {
await common.measure('Extracting Ruby', async () => { await common.measure('Extracting Ruby', async () => {
if (windows) { if (windows) {
// Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths // Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
await exec.exec('tar', [ '-xz', '-C', common.win2nix(parentDir), '-f', common.win2nix(downloadPath) ]) await exec.exec('tar', ['-xz', '-C', common.win2nix(parentDir), '-f', common.win2nix(downloadPath)])
} else { } else {
await exec.exec('tar', [ '-xz', '-C', parentDir, '-f', downloadPath ]) await exec.exec('tar', ['-xz', '-C', parentDir, '-f', downloadPath])
} }
}) })
return rubyPrefix if (common.shouldUseToolCache(engine, version)) {
common.createToolCacheCompleteFile(rubyPrefix)
}
} }
function getDownloadURL(platform, engine, version) { function getDownloadURL(platform, engine, version) {
+22 -6
View File
@@ -36,31 +36,47 @@ export async function install(platform, engine, version) {
} }
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length) const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
let rubyPrefix let rubyPrefix, inToolCache
if (common.shouldExtractInToolCache(engine, version)) { if (common.shouldUseToolCache(engine, version)) {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version) inToolCache = tc.find('Ruby', version)
if (inToolCache) {
rubyPrefix = inToolCache
} else {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version)
}
} else { } else {
rubyPrefix = `${drive}:\\${base}` rubyPrefix = `${drive}:\\${base}`
} }
const parentDir = path.dirname(rubyPrefix)
let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version) let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)
common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths]) common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])
if (!inToolCache) {
await downloadAndExtract(engine, version, url, base, rubyPrefix);
}
return rubyPrefix
}
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
const parentDir = path.dirname(rubyPrefix)
const downloadPath = await common.measure('Downloading Ruby', async () => { const downloadPath = await common.measure('Downloading Ruby', async () => {
console.log(url) console.log(url)
return await tc.downloadTool(url) return await tc.downloadTool(url)
}) })
await common.measure('Extracting Ruby', async () => await common.measure('Extracting Ruby', async () =>
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${parentDir}`], { silent: true })) exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${parentDir}`], {silent: true}))
if (base !== path.basename(rubyPrefix)) { if (base !== path.basename(rubyPrefix)) {
await io.mv(path.join(parentDir, base), rubyPrefix) await io.mv(path.join(parentDir, base), rubyPrefix)
} }
return rubyPrefix if (common.shouldUseToolCache(engine, version)) {
common.createToolCacheCompleteFile(rubyPrefix)
}
} }
async function setupMingw(version) { async function setupMingw(version) {