mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-14 06:54:20 +02:00
Add a self-hosted input to force considering the current runner as self-hosted
* Since checking for self-hosted is based on guessing as there is no proper predicate for it in GitHub Actions (AFAIK).
This commit is contained in:
@@ -30,6 +30,11 @@ inputs:
|
|||||||
description: |
|
description: |
|
||||||
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
|
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
|
||||||
to invalidate the cache.
|
to invalidate the cache.
|
||||||
|
self-hosted:
|
||||||
|
description: |
|
||||||
|
Consider the runner as a self-hosted runner, which means not using prebuilt Ruby binaries which only work
|
||||||
|
on GitHub-hosted runners or self-hosted runners with a very similar image to the ones used by GitHub runners.
|
||||||
|
The default is to detect this automatically based on the OS, OS version and $RUNNER_TOOL_CACHE.
|
||||||
outputs:
|
outputs:
|
||||||
ruby-prefix:
|
ruby-prefix:
|
||||||
description: 'The prefix of the installed ruby'
|
description: 'The prefix of the installed ruby'
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ export const windows = (os.platform() === 'win32')
|
|||||||
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
|
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
|
||||||
export const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
|
export const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
|
||||||
|
|
||||||
|
export const inputs = {
|
||||||
|
selfHosted: undefined
|
||||||
|
}
|
||||||
|
|
||||||
export function partition(string, separator) {
|
export function partition(string, separator) {
|
||||||
const i = string.indexOf(separator)
|
const i = string.indexOf(separator)
|
||||||
if (i === -1) {
|
if (i === -1) {
|
||||||
@@ -166,8 +170,13 @@ const GitHubHostedPlatforms = [
|
|||||||
// * the OS and OS version does not correspond to a GitHub-hosted runner image,
|
// * the OS and OS version does not correspond to a GitHub-hosted runner image,
|
||||||
// * or the hosted tool cache is different from the default tool cache path
|
// * or the hosted tool cache is different from the default tool cache path
|
||||||
export function isSelfHostedRunner() {
|
export function isSelfHostedRunner() {
|
||||||
return !GitHubHostedPlatforms.includes(getOSNameVersionArch()) ||
|
if (inputs.selfHosted === undefined) {
|
||||||
getRunnerToolCache() !== getDefaultToolCachePath()
|
throw new Error('inputs.selfHosted should have been already set')
|
||||||
|
}
|
||||||
|
|
||||||
|
return inputs.selfHosted === 'true' ||
|
||||||
|
!GitHubHostedPlatforms.includes(getOSNameVersionArch()) ||
|
||||||
|
getRunnerToolCache() !== getDefaultToolCachePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
let virtualEnvironmentName = undefined
|
let virtualEnvironmentName = undefined
|
||||||
|
|||||||
+14
-2
@@ -296,6 +296,7 @@ __nccwpck_require__.d(__webpack_exports__, {
|
|||||||
"getVirtualEnvironmentName": () => (/* binding */ getVirtualEnvironmentName),
|
"getVirtualEnvironmentName": () => (/* binding */ getVirtualEnvironmentName),
|
||||||
"hasBundlerDefaultGem": () => (/* binding */ hasBundlerDefaultGem),
|
"hasBundlerDefaultGem": () => (/* binding */ hasBundlerDefaultGem),
|
||||||
"hashFile": () => (/* binding */ hashFile),
|
"hashFile": () => (/* binding */ hashFile),
|
||||||
|
"inputs": () => (/* binding */ inputs),
|
||||||
"isBundler1Default": () => (/* binding */ isBundler1Default),
|
"isBundler1Default": () => (/* binding */ isBundler1Default),
|
||||||
"isBundler2Default": () => (/* binding */ isBundler2Default),
|
"isBundler2Default": () => (/* binding */ isBundler2Default),
|
||||||
"isBundler2dot2Default": () => (/* binding */ isBundler2dot2Default),
|
"isBundler2dot2Default": () => (/* binding */ isBundler2dot2Default),
|
||||||
@@ -366,6 +367,10 @@ const windows = (os.platform() === 'win32')
|
|||||||
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
|
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
|
||||||
const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
|
const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
|
||||||
|
|
||||||
|
const inputs = {
|
||||||
|
selfHosted: undefined
|
||||||
|
}
|
||||||
|
|
||||||
function partition(string, separator) {
|
function partition(string, separator) {
|
||||||
const i = string.indexOf(separator)
|
const i = string.indexOf(separator)
|
||||||
if (i === -1) {
|
if (i === -1) {
|
||||||
@@ -519,8 +524,13 @@ const GitHubHostedPlatforms = [
|
|||||||
// * the OS and OS version does not correspond to a GitHub-hosted runner image,
|
// * the OS and OS version does not correspond to a GitHub-hosted runner image,
|
||||||
// * or the hosted tool cache is different from the default tool cache path
|
// * or the hosted tool cache is different from the default tool cache path
|
||||||
function isSelfHostedRunner() {
|
function isSelfHostedRunner() {
|
||||||
return !GitHubHostedPlatforms.includes(getOSNameVersionArch()) ||
|
if (inputs.selfHosted === undefined) {
|
||||||
getRunnerToolCache() !== getDefaultToolCachePath()
|
throw new Error('inputs.selfHosted should have been already set')
|
||||||
|
}
|
||||||
|
|
||||||
|
return inputs.selfHosted === 'true' ||
|
||||||
|
!GitHubHostedPlatforms.includes(getOSNameVersionArch()) ||
|
||||||
|
getRunnerToolCache() !== getDefaultToolCachePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
let virtualEnvironmentName = undefined
|
let virtualEnvironmentName = undefined
|
||||||
@@ -69022,6 +69032,7 @@ const inputDefaults = {
|
|||||||
'bundler-cache': 'false',
|
'bundler-cache': 'false',
|
||||||
'working-directory': '.',
|
'working-directory': '.',
|
||||||
'cache-version': bundler.DEFAULT_CACHE_VERSION,
|
'cache-version': bundler.DEFAULT_CACHE_VERSION,
|
||||||
|
'self-hosted': 'false',
|
||||||
}
|
}
|
||||||
|
|
||||||
// entry point when this action is run on its own
|
// entry point when this action is run on its own
|
||||||
@@ -69045,6 +69056,7 @@ async function setupRuby(options = {}) {
|
|||||||
inputs[key] = core.getInput(key) || inputDefaults[key]
|
inputs[key] = core.getInput(key) || inputDefaults[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
common.inputs.selfHosted = inputs['self-hosted']
|
||||||
|
|
||||||
process.chdir(inputs['working-directory'])
|
process.chdir(inputs['working-directory'])
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const inputDefaults = {
|
|||||||
'bundler-cache': 'false',
|
'bundler-cache': 'false',
|
||||||
'working-directory': '.',
|
'working-directory': '.',
|
||||||
'cache-version': bundler.DEFAULT_CACHE_VERSION,
|
'cache-version': bundler.DEFAULT_CACHE_VERSION,
|
||||||
|
'self-hosted': 'false',
|
||||||
}
|
}
|
||||||
|
|
||||||
// entry point when this action is run on its own
|
// entry point when this action is run on its own
|
||||||
@@ -39,6 +40,7 @@ export async function setupRuby(options = {}) {
|
|||||||
inputs[key] = core.getInput(key) || inputDefaults[key]
|
inputs[key] = core.getInput(key) || inputDefaults[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
common.inputs.selfHosted = inputs['self-hosted']
|
||||||
|
|
||||||
process.chdir(inputs['working-directory'])
|
process.chdir(inputs['working-directory'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user