From 23b2b5e5f16f1ca741a3d523fccc5a0a548ab8e2 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 5 Dec 2020 16:30:07 +0100 Subject: [PATCH] Create the .complete file so tc.find() can find it for future runs for self-hosted runners --- common.js | 5 +++++ dist/index.js | 18 ++++++++++++++++-- ruby-builder.js | 4 ++++ windows.js | 8 ++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/common.js b/common.js index fc2c510..d16152c 100644 --- a/common.js +++ b/common.js @@ -99,6 +99,11 @@ export function getToolCacheRubyPrefix(platform, version) { 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 export function win2nix(path) { if (/^[A-Z]:/i.test(path)) { diff --git a/dist/index.js b/dist/index.js index df16c38..72179bf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -27729,13 +27729,13 @@ async function install(platform, engine, version) { common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths]) if (!inToolCache) { - await downloadAndExtract(url, base, rubyPrefix); + await downloadAndExtract(engine, version, url, base, rubyPrefix); } return rubyPrefix } -async function downloadAndExtract(url, base, rubyPrefix) { +async function downloadAndExtract(engine, version, url, base, rubyPrefix) { const parentDir = path.dirname(rubyPrefix) const downloadPath = await common.measure('Downloading Ruby', async () => { @@ -27749,6 +27749,10 @@ async function downloadAndExtract(url, base, rubyPrefix) { if (base !== path.basename(rubyPrefix)) { await io.mv(path.join(parentDir, base), rubyPrefix) } + + if (common.shouldUseToolCache(engine, version)) { + common.createToolCacheCompleteFile(rubyPrefix) + } } async function setupMingw(version) { @@ -32114,6 +32118,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; }); /* 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__, "createToolCacheCompleteFile", function() { return createToolCacheCompleteFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "win2nix", function() { return win2nix; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupPath", function() { return setupPath; }); const os = __webpack_require__(87) @@ -32217,6 +32222,11 @@ function getToolCacheRubyPrefix(platform, version) { 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 function win2nix(path) { if (/^[A-Z]:/i.test(path)) { @@ -52982,6 +52992,10 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) { await exec.exec('tar', ['-xz', '-C', parentDir, '-f', downloadPath]) } }) + + if (common.shouldUseToolCache(engine, version)) { + common.createToolCacheCompleteFile(rubyPrefix) + } } function getDownloadURL(platform, engine, version) { diff --git a/ruby-builder.js b/ruby-builder.js index c136fcd..912a6b6 100644 --- a/ruby-builder.js +++ b/ruby-builder.js @@ -60,6 +60,10 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) { await exec.exec('tar', ['-xz', '-C', parentDir, '-f', downloadPath]) } }) + + if (common.shouldUseToolCache(engine, version)) { + common.createToolCacheCompleteFile(rubyPrefix) + } } function getDownloadURL(platform, engine, version) { diff --git a/windows.js b/windows.js index d5fc8da..517abe4 100644 --- a/windows.js +++ b/windows.js @@ -53,13 +53,13 @@ export async function install(platform, engine, version) { common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths]) if (!inToolCache) { - await downloadAndExtract(url, base, rubyPrefix); + await downloadAndExtract(engine, version, url, base, rubyPrefix); } return rubyPrefix } -async function downloadAndExtract(url, base, rubyPrefix) { +async function downloadAndExtract(engine, version, url, base, rubyPrefix) { const parentDir = path.dirname(rubyPrefix) const downloadPath = await common.measure('Downloading Ruby', async () => { @@ -73,6 +73,10 @@ async function downloadAndExtract(url, base, rubyPrefix) { if (base !== path.basename(rubyPrefix)) { await io.mv(path.join(parentDir, base), rubyPrefix) } + + if (common.shouldUseToolCache(engine, version)) { + common.createToolCacheCompleteFile(rubyPrefix) + } } async function setupMingw(version) {