diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36354f7b4..a32251621 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14, windows-2019, windows-2022 ] + os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14, macos-15, windows-2019, windows-2022 ] ruby: [ '1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', ruby-head, jruby, jruby-head, @@ -35,7 +35,7 @@ jobs: - { os: ubuntu-22.04, ruby: '2.2' } - { os: ubuntu-24.04, ruby: '1.9' } - { os: ubuntu-24.04, ruby: '2.2' } - # These old Rubies fail to compile on macos-14 (macOS 14, arm64), which is used for ruby/ruby-builder + # These old Rubies fail to compile on macOS arm64 - { os: macos-14, ruby: '1.9' } - { os: macos-14, ruby: '2.0' } - { os: macos-14, ruby: '2.1' } @@ -43,6 +43,13 @@ jobs: - { os: macos-14, ruby: '2.3' } - { os: macos-14, ruby: '2.4' } - { os: macos-14, ruby: '2.5' } + - { os: macos-15, ruby: '1.9' } + - { os: macos-15, ruby: '2.0' } + - { os: macos-15, ruby: '2.1' } + - { os: macos-15, ruby: '2.2' } + - { os: macos-15, ruby: '2.3' } + - { os: macos-15, ruby: '2.4' } + - { os: macos-15, ruby: '2.5' } # Windows - { os: windows-2019, ruby: '1.9' } - { os: windows-2019, ruby: debug } diff --git a/common.js b/common.js index 61d0021d1..cd4dd2766 100644 --- a/common.js +++ b/common.js @@ -162,73 +162,103 @@ export async function hashFile(file) { return hash.digest('hex') } +// macos is not listed explicitly, see below const GitHubHostedPlatforms = [ 'ubuntu-20.04-x64', 'ubuntu-22.04-x64', 'ubuntu-24.04-x64', - 'macos-12-x64', - 'macos-13-x64', - 'macos-13-arm64', - 'macos-14-x64', - 'macos-14-arm64', 'windows-2019-x64', 'windows-2022-x64', ] +// Precisely: whether we have builds for that platform and there are GitHub-hosted runners to test it +function isSupportedPlatform() { + const platform = getOSName() + switch (platform) { + case 'ubuntu': + return GitHubHostedPlatforms.includes(getOSNameVersionArch()) + case 'macos': + // See https://github.com/ruby/ruby-builder/blob/master/README.md#naming + // 13 on arm64 because of old macos-arm-oss runners + return (os.arch() === 'x64' && parseInt(getOSVersion()) >= 12) || + (os.arch() === 'arm64' && parseInt(getOSVersion()) >= 13) + case 'windows': + return GitHubHostedPlatforms.includes(getOSNameVersionArch()) + } +} + // Actually a self-hosted runner for which the OS and OS version does not correspond to a GitHub-hosted runner image, export function isSelfHostedRunner() { if (inputs.selfHosted === undefined) { throw new Error('inputs.selfHosted should have been already set') } - return inputs.selfHosted === 'true' || - !GitHubHostedPlatforms.includes(getOSNameVersionArch()) + return inputs.selfHosted === 'true' || !isSupportedPlatform() } export function selfHostedRunnerReason() { if (inputs.selfHosted === 'true') { return 'the self-hosted input was set' - } else if (!GitHubHostedPlatforms.includes(getOSNameVersionArch())) { + } else if (!isSupportedPlatform()) { return 'the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported)' } else { return 'unknown reason' } } -let osNameVersion = undefined +let osName = undefined +let osVersion = undefined -export function getOSNameVersion() { - if (osNameVersion !== undefined) { - return osNameVersion +export function getOSName() { + if (osName !== undefined) { + return osName } const platform = os.platform() - let osName - let osVersion if (platform === 'linux') { const info = linuxOSInfo({mode: 'sync'}) osName = info.id - osVersion = info.version_id } else if (platform === 'darwin') { osName = 'macos' - osVersion = macosRelease().version } else if (platform === 'win32') { osName = 'windows' + } else { + throw new Error(`Unknown platform ${platform}`) + } + + return osName +} + +export function getOSVersion() { + if (osVersion !== undefined) { + return osVersion + } + + const platform = os.platform() + if (platform === 'linux') { + const info = linuxOSInfo({mode: 'sync'}) + osVersion = info.version_id + } else if (platform === 'darwin') { + osVersion = macosRelease().version + } else if (platform === 'win32') { osVersion = findWindowsVersion() } else { throw new Error(`Unknown platform ${platform}`) } - osNameVersion = `${osName}-${osVersion}` - return osNameVersion + return osVersion +} + +export function getOSNameVersion() { + return `${getOSName()}-${getOSVersion()}` } export function getOSNameVersionArch() { - return `${getOSNameVersion()}-${os.arch()}` + return `${getOSName()}-${getOSVersion()}-${os.arch()}` } function findWindowsVersion() { - const version = os.version(); + const version = os.version() const match = version.match(/^Windows Server (\d+) Datacenter/) if (match) { return match[1] @@ -261,15 +291,14 @@ export function getRunnerToolCache() { // Rubies prebuilt by this action embed this path rather than using $RUNNER_TOOL_CACHE function getDefaultToolCachePath() { - const platform = getOSNameVersion() - if (platform.startsWith('ubuntu-')) { - return '/opt/hostedtoolcache' - } else if (platform.startsWith('macos-')) { - return '/Users/runner/hostedtoolcache' - } else if (platform.startsWith('windows-')) { - return 'C:\\hostedtoolcache\\windows' - } else { - throw new Error('Unknown platform') + const platform = getOSName() + switch (platform) { + case 'ubuntu': + return '/opt/hostedtoolcache' + case 'macos': + return '/Users/runner/hostedtoolcache' + case 'windows': + return 'C:\\hostedtoolcache\\windows' } } diff --git a/dist/index.js b/dist/index.js index 61c20642e..c7c936f22 100644 --- a/dist/index.js +++ b/dist/index.js @@ -292,8 +292,10 @@ __nccwpck_require__.d(__webpack_exports__, { "createToolCacheCompleteFile": () => (/* binding */ createToolCacheCompleteFile), "drive": () => (/* binding */ drive), "floatVersion": () => (/* binding */ floatVersion), + "getOSName": () => (/* binding */ getOSName), "getOSNameVersion": () => (/* binding */ getOSNameVersion), "getOSNameVersionArch": () => (/* binding */ getOSNameVersionArch), + "getOSVersion": () => (/* binding */ getOSVersion), "getRunnerToolCache": () => (/* binding */ getRunnerToolCache), "getToolCachePath": () => (/* binding */ getToolCachePath), "getToolCacheRubyPrefix": () => (/* binding */ getToolCacheRubyPrefix), @@ -523,73 +525,103 @@ async function hashFile(file) { return hash.digest('hex') } +// macos is not listed explicitly, see below const GitHubHostedPlatforms = [ 'ubuntu-20.04-x64', 'ubuntu-22.04-x64', 'ubuntu-24.04-x64', - 'macos-12-x64', - 'macos-13-x64', - 'macos-13-arm64', - 'macos-14-x64', - 'macos-14-arm64', 'windows-2019-x64', 'windows-2022-x64', ] +// Precisely: whether we have builds for that platform and there are GitHub-hosted runners to test it +function isSupportedPlatform() { + const platform = getOSName() + switch (platform) { + case 'ubuntu': + return GitHubHostedPlatforms.includes(getOSNameVersionArch()) + case 'macos': + // See https://github.com/ruby/ruby-builder/blob/master/README.md#naming + // 13 on arm64 because of old macos-arm-oss runners + return (os.arch() === 'x64' && parseInt(getOSVersion()) >= 12) || + (os.arch() === 'arm64' && parseInt(getOSVersion()) >= 13) + case 'windows': + return GitHubHostedPlatforms.includes(getOSNameVersionArch()) + } +} + // Actually a self-hosted runner for which the OS and OS version does not correspond to a GitHub-hosted runner image, function isSelfHostedRunner() { if (inputs.selfHosted === undefined) { throw new Error('inputs.selfHosted should have been already set') } - return inputs.selfHosted === 'true' || - !GitHubHostedPlatforms.includes(getOSNameVersionArch()) + return inputs.selfHosted === 'true' || !isSupportedPlatform() } function selfHostedRunnerReason() { if (inputs.selfHosted === 'true') { return 'the self-hosted input was set' - } else if (!GitHubHostedPlatforms.includes(getOSNameVersionArch())) { + } else if (!isSupportedPlatform()) { return 'the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported)' } else { return 'unknown reason' } } -let osNameVersion = undefined +let osName = undefined +let osVersion = undefined -function getOSNameVersion() { - if (osNameVersion !== undefined) { - return osNameVersion +function getOSName() { + if (osName !== undefined) { + return osName } const platform = os.platform() - let osName - let osVersion if (platform === 'linux') { const info = linuxOSInfo({mode: 'sync'}) osName = info.id - osVersion = info.version_id } else if (platform === 'darwin') { osName = 'macos' - osVersion = macosRelease().version } else if (platform === 'win32') { osName = 'windows' + } else { + throw new Error(`Unknown platform ${platform}`) + } + + return osName +} + +function getOSVersion() { + if (osVersion !== undefined) { + return osVersion + } + + const platform = os.platform() + if (platform === 'linux') { + const info = linuxOSInfo({mode: 'sync'}) + osVersion = info.version_id + } else if (platform === 'darwin') { + osVersion = macosRelease().version + } else if (platform === 'win32') { osVersion = findWindowsVersion() } else { throw new Error(`Unknown platform ${platform}`) } - osNameVersion = `${osName}-${osVersion}` - return osNameVersion + return osVersion +} + +function getOSNameVersion() { + return `${getOSName()}-${getOSVersion()}` } function getOSNameVersionArch() { - return `${getOSNameVersion()}-${os.arch()}` + return `${getOSName()}-${getOSVersion()}-${os.arch()}` } function findWindowsVersion() { - const version = os.version(); + const version = os.version() const match = version.match(/^Windows Server (\d+) Datacenter/) if (match) { return match[1] @@ -622,15 +654,14 @@ function getRunnerToolCache() { // Rubies prebuilt by this action embed this path rather than using $RUNNER_TOOL_CACHE function getDefaultToolCachePath() { - const platform = getOSNameVersion() - if (platform.startsWith('ubuntu-')) { - return '/opt/hostedtoolcache' - } else if (platform.startsWith('macos-')) { - return '/Users/runner/hostedtoolcache' - } else if (platform.startsWith('windows-')) { - return 'C:\\hostedtoolcache\\windows' - } else { - throw new Error('Unknown platform') + const platform = getOSName() + switch (platform) { + case 'ubuntu': + return '/opt/hostedtoolcache' + case 'macos': + return '/Users/runner/hostedtoolcache' + case 'windows': + return 'C:\\hostedtoolcache\\windows' } }