From 5a73aa9f67560c0d447ab95e2c73fb8d0f790c01 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 3 Mar 2023 17:53:40 +0100 Subject: [PATCH] Explain why it was detected as self-hosted --- common.js | 12 ++++++++++++ dist/index.js | 17 +++++++++++++++-- ruby-builder.js | 4 ++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/common.js b/common.js index 9e591c4..8fe2529 100644 --- a/common.js +++ b/common.js @@ -179,6 +179,18 @@ export function isSelfHostedRunner() { getRunnerToolCache() !== getDefaultToolCachePath() } +export function selfHostedRunnerReason() { + if (inputs.selfHosted === 'true') { + return 'the self-hosted input was set' + } else if (!GitHubHostedPlatforms.includes(getOSNameVersionArch())) { + return 'the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported)' + } else if (getRunnerToolCache() !== getDefaultToolCachePath()) { + return 'the $RUNNER_TOOL_CACHE is different than the default tool cache path (they must be the same to reuse prebuilt Ruby binaries)' + } else { + return 'unknown reason' + } +} + let virtualEnvironmentName = undefined export function getVirtualEnvironmentName() { diff --git a/dist/index.js b/dist/index.js index 99c9c72..1312e71 100644 --- a/dist/index.js +++ b/dist/index.js @@ -305,6 +305,7 @@ __nccwpck_require__.d(__webpack_exports__, { "isStableVersion": () => (/* binding */ isStableVersion), "measure": () => (/* binding */ measure), "partition": () => (/* binding */ partition), + "selfHostedRunnerReason": () => (/* binding */ selfHostedRunnerReason), "setupPath": () => (/* binding */ setupPath), "shouldUseToolCache": () => (/* binding */ shouldUseToolCache), "targetRubyVersion": () => (/* binding */ targetRubyVersion), @@ -533,6 +534,18 @@ function isSelfHostedRunner() { getRunnerToolCache() !== getDefaultToolCachePath() } +function selfHostedRunnerReason() { + if (inputs.selfHosted === 'true') { + return 'the self-hosted input was set' + } else if (!GitHubHostedPlatforms.includes(getOSNameVersionArch())) { + return 'the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported)' + } else if (getRunnerToolCache() !== getDefaultToolCachePath()) { + return 'the $RUNNER_TOOL_CACHE is different than the default tool cache path (they must be the same to reuse prebuilt Ruby binaries)' + } else { + return 'unknown reason' + } +} + let virtualEnvironmentName = undefined function getVirtualEnvironmentName() { @@ -68270,8 +68283,8 @@ async function install(platform, engine, version) { if (common.isSelfHostedRunner()) { const rubyBuildDefinition = engine === 'ruby' ? version : `${engine}-${version}` core.error( - `The current runner (${common.getOSNameVersionArch()}, RUNNER_TOOL_CACHE=${common.getRunnerToolCache()}) was detected as self-hosted and not matching a GitHub-hosted runner image.\n` + - `In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build:\n` + + `The current runner (${common.getOSNameVersionArch()}, RUNNER_TOOL_CACHE=${common.getRunnerToolCache()}) was detected as self-hosted because ${common.selfHostedRunnerReason()}.\n` + + `In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build\n` + `You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml\n` + `$ ruby-build ${rubyBuildDefinition} ${toolCacheRubyPrefix}\n` + `Once that completes successfully, mark it as complete with:\n` + diff --git a/ruby-builder.js b/ruby-builder.js index 917ca06..60388fd 100644 --- a/ruby-builder.js +++ b/ruby-builder.js @@ -28,8 +28,8 @@ export async function install(platform, engine, version) { if (common.isSelfHostedRunner()) { const rubyBuildDefinition = engine === 'ruby' ? version : `${engine}-${version}` core.error( - `The current runner (${common.getOSNameVersionArch()}, RUNNER_TOOL_CACHE=${common.getRunnerToolCache()}) was detected as self-hosted and not matching a GitHub-hosted runner image.\n` + - `In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build:\n` + + `The current runner (${common.getOSNameVersionArch()}, RUNNER_TOOL_CACHE=${common.getRunnerToolCache()}) was detected as self-hosted because ${common.selfHostedRunnerReason()}.\n` + + `In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build\n` + `You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml\n` + `$ ruby-build ${rubyBuildDefinition} ${toolCacheRubyPrefix}\n` + `Once that completes successfully, mark it as complete with:\n` +