diff --git a/common.js b/common.js index dc71bc03d..a28f8390b 100644 --- a/common.js +++ b/common.js @@ -5,6 +5,7 @@ const util = require('util') const stream = require('stream') const crypto = require('crypto') const core = require('@actions/core') +const tc = require('@actions/tool-cache') const { performance } = require('perf_hooks') const linuxOSInfo = require('linux-os-info') import macosRelease from 'macos-release' @@ -264,7 +265,18 @@ function getDefaultToolCachePath() { } } -export function engineToToolCacheName(engine) { +// tc.find() but using RUNNER_TOOL_CACHE=getToolCachePath() +export function toolCacheFind(engine, version) { + const originalToolCache = getToolCachePath() + process.env['RUNNER_TOOL_CACHE'] = getToolCachePath() + try { + return tc.find(engineToToolCacheName(engine), version) + } finally { + process.env['RUNNER_TOOL_CACHE'] = originalToolCache + } +} + +function engineToToolCacheName(engine) { return { ruby: 'Ruby', jruby: 'JRuby', diff --git a/dist/index.js b/dist/index.js index c2a54b51a..48ccb6648 100644 --- a/dist/index.js +++ b/dist/index.js @@ -289,7 +289,6 @@ __nccwpck_require__.r(__webpack_exports__); __nccwpck_require__.d(__webpack_exports__, { "createToolCacheCompleteFile": () => (/* binding */ createToolCacheCompleteFile), "drive": () => (/* binding */ drive), - "engineToToolCacheName": () => (/* binding */ engineToToolCacheName), "floatVersion": () => (/* binding */ floatVersion), "getOSNameVersionArch": () => (/* binding */ getOSNameVersionArch), "getRunnerToolCache": () => (/* binding */ getRunnerToolCache), @@ -313,6 +312,7 @@ __nccwpck_require__.d(__webpack_exports__, { "targetRubyVersion": () => (/* binding */ targetRubyVersion), "time": () => (/* binding */ time), "toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile), + "toolCacheFind": () => (/* binding */ toolCacheFind), "win2nix": () => (/* binding */ win2nix), "windows": () => (/* binding */ windows) }); @@ -362,6 +362,7 @@ const util = __nccwpck_require__(3837) const stream = __nccwpck_require__(2781) const common_crypto = __nccwpck_require__(6113) const core = __nccwpck_require__(2186) +const tc = __nccwpck_require__(7784) const { performance } = __nccwpck_require__(4074) const linuxOSInfo = __nccwpck_require__(8487) ; @@ -621,6 +622,17 @@ function getDefaultToolCachePath() { } } +// tc.find() but using RUNNER_TOOL_CACHE=getToolCachePath() +function toolCacheFind(engine, version) { + const originalToolCache = getToolCachePath() + process.env['RUNNER_TOOL_CACHE'] = getToolCachePath() + try { + return tc.find(engineToToolCacheName(engine), version) + } finally { + process.env['RUNNER_TOOL_CACHE'] = originalToolCache + } +} + function engineToToolCacheName(engine) { return { ruby: 'Ruby', @@ -68284,7 +68296,7 @@ function getAvailableVersions(platform, engine) { async function install(platform, engine, version) { let rubyPrefix, inToolCache if (common.shouldUseToolCache(engine, version)) { - inToolCache = tc.find(common.engineToToolCacheName(engine), version) + inToolCache = common.toolCacheFind(engine, version) if (inToolCache) { rubyPrefix = inToolCache } else { @@ -68498,7 +68510,7 @@ async function install(platform, engine, version) { let rubyPrefix, inToolCache if (common.shouldUseToolCache(engine, version)) { - inToolCache = tc.find(common.engineToToolCacheName(engine), version) + inToolCache = common.toolCacheFind(engine, version) if (inToolCache) { rubyPrefix = inToolCache } else { diff --git a/ruby-builder.js b/ruby-builder.js index 8dd71c588..9f5b143c5 100644 --- a/ruby-builder.js +++ b/ruby-builder.js @@ -20,7 +20,7 @@ export function getAvailableVersions(platform, engine) { export async function install(platform, engine, version) { let rubyPrefix, inToolCache if (common.shouldUseToolCache(engine, version)) { - inToolCache = tc.find(common.engineToToolCacheName(engine), version) + inToolCache = common.toolCacheFind(engine, version) if (inToolCache) { rubyPrefix = inToolCache } else { diff --git a/windows.js b/windows.js index d827071c7..e831cb4e2 100644 --- a/windows.js +++ b/windows.js @@ -49,7 +49,7 @@ export async function install(platform, engine, version) { let rubyPrefix, inToolCache if (common.shouldUseToolCache(engine, version)) { - inToolCache = tc.find(common.engineToToolCacheName(engine), version) + inToolCache = common.toolCacheFind(engine, version) if (inToolCache) { rubyPrefix = inToolCache } else {