Skip to content

Commit

Permalink
Explain why it was detected as self-hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Mar 3, 2023
1 parent d01c52a commit 5a73aa9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
12 changes: 12 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
17 changes: 15 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ruby-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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` +
Expand Down

0 comments on commit 5a73aa9

Please sign in to comment.