Use tc.find() with the effective tool cache path
* So it finds already-download prebuilt Ruby in the GH-hosted tool cache path on self-hosted, where $RUNNER_TOOL_CACHE is often different than on GH-hosted. * See #475. * This relies on tc.find() looking up the env var every time: https://github.com/actions/toolkit/blob/1f4b3fac06/packages/tool-cache/src/tool-cache.ts#L522
This commit is contained in:
@@ -5,6 +5,7 @@ const util = require('util')
|
|||||||
const stream = require('stream')
|
const stream = require('stream')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
|
const tc = require('@actions/tool-cache')
|
||||||
const { performance } = require('perf_hooks')
|
const { performance } = require('perf_hooks')
|
||||||
const linuxOSInfo = require('linux-os-info')
|
const linuxOSInfo = require('linux-os-info')
|
||||||
import macosRelease from 'macos-release'
|
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 {
|
return {
|
||||||
ruby: 'Ruby',
|
ruby: 'Ruby',
|
||||||
jruby: 'JRuby',
|
jruby: 'JRuby',
|
||||||
|
|||||||
+15
-3
@@ -289,7 +289,6 @@ __nccwpck_require__.r(__webpack_exports__);
|
|||||||
__nccwpck_require__.d(__webpack_exports__, {
|
__nccwpck_require__.d(__webpack_exports__, {
|
||||||
"createToolCacheCompleteFile": () => (/* binding */ createToolCacheCompleteFile),
|
"createToolCacheCompleteFile": () => (/* binding */ createToolCacheCompleteFile),
|
||||||
"drive": () => (/* binding */ drive),
|
"drive": () => (/* binding */ drive),
|
||||||
"engineToToolCacheName": () => (/* binding */ engineToToolCacheName),
|
|
||||||
"floatVersion": () => (/* binding */ floatVersion),
|
"floatVersion": () => (/* binding */ floatVersion),
|
||||||
"getOSNameVersionArch": () => (/* binding */ getOSNameVersionArch),
|
"getOSNameVersionArch": () => (/* binding */ getOSNameVersionArch),
|
||||||
"getRunnerToolCache": () => (/* binding */ getRunnerToolCache),
|
"getRunnerToolCache": () => (/* binding */ getRunnerToolCache),
|
||||||
@@ -313,6 +312,7 @@ __nccwpck_require__.d(__webpack_exports__, {
|
|||||||
"targetRubyVersion": () => (/* binding */ targetRubyVersion),
|
"targetRubyVersion": () => (/* binding */ targetRubyVersion),
|
||||||
"time": () => (/* binding */ time),
|
"time": () => (/* binding */ time),
|
||||||
"toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile),
|
"toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile),
|
||||||
|
"toolCacheFind": () => (/* binding */ toolCacheFind),
|
||||||
"win2nix": () => (/* binding */ win2nix),
|
"win2nix": () => (/* binding */ win2nix),
|
||||||
"windows": () => (/* binding */ windows)
|
"windows": () => (/* binding */ windows)
|
||||||
});
|
});
|
||||||
@@ -362,6 +362,7 @@ const util = __nccwpck_require__(3837)
|
|||||||
const stream = __nccwpck_require__(2781)
|
const stream = __nccwpck_require__(2781)
|
||||||
const common_crypto = __nccwpck_require__(6113)
|
const common_crypto = __nccwpck_require__(6113)
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
|
const tc = __nccwpck_require__(7784)
|
||||||
const { performance } = __nccwpck_require__(4074)
|
const { performance } = __nccwpck_require__(4074)
|
||||||
const linuxOSInfo = __nccwpck_require__(8487)
|
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) {
|
function engineToToolCacheName(engine) {
|
||||||
return {
|
return {
|
||||||
ruby: 'Ruby',
|
ruby: 'Ruby',
|
||||||
@@ -68284,7 +68296,7 @@ function getAvailableVersions(platform, engine) {
|
|||||||
async function install(platform, engine, version) {
|
async function install(platform, engine, version) {
|
||||||
let rubyPrefix, inToolCache
|
let rubyPrefix, inToolCache
|
||||||
if (common.shouldUseToolCache(engine, version)) {
|
if (common.shouldUseToolCache(engine, version)) {
|
||||||
inToolCache = tc.find(common.engineToToolCacheName(engine), version)
|
inToolCache = common.toolCacheFind(engine, version)
|
||||||
if (inToolCache) {
|
if (inToolCache) {
|
||||||
rubyPrefix = inToolCache
|
rubyPrefix = inToolCache
|
||||||
} else {
|
} else {
|
||||||
@@ -68498,7 +68510,7 @@ async function install(platform, engine, version) {
|
|||||||
|
|
||||||
let rubyPrefix, inToolCache
|
let rubyPrefix, inToolCache
|
||||||
if (common.shouldUseToolCache(engine, version)) {
|
if (common.shouldUseToolCache(engine, version)) {
|
||||||
inToolCache = tc.find(common.engineToToolCacheName(engine), version)
|
inToolCache = common.toolCacheFind(engine, version)
|
||||||
if (inToolCache) {
|
if (inToolCache) {
|
||||||
rubyPrefix = inToolCache
|
rubyPrefix = inToolCache
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ export function getAvailableVersions(platform, engine) {
|
|||||||
export async function install(platform, engine, version) {
|
export async function install(platform, engine, version) {
|
||||||
let rubyPrefix, inToolCache
|
let rubyPrefix, inToolCache
|
||||||
if (common.shouldUseToolCache(engine, version)) {
|
if (common.shouldUseToolCache(engine, version)) {
|
||||||
inToolCache = tc.find(common.engineToToolCacheName(engine), version)
|
inToolCache = common.toolCacheFind(engine, version)
|
||||||
if (inToolCache) {
|
if (inToolCache) {
|
||||||
rubyPrefix = inToolCache
|
rubyPrefix = inToolCache
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ export async function install(platform, engine, version) {
|
|||||||
|
|
||||||
let rubyPrefix, inToolCache
|
let rubyPrefix, inToolCache
|
||||||
if (common.shouldUseToolCache(engine, version)) {
|
if (common.shouldUseToolCache(engine, version)) {
|
||||||
inToolCache = tc.find(common.engineToToolCacheName(engine), version)
|
inToolCache = common.toolCacheFind(engine, version)
|
||||||
if (inToolCache) {
|
if (inToolCache) {
|
||||||
rubyPrefix = inToolCache
|
rubyPrefix = inToolCache
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user