Add ability to specify OTP architecture (#316)

This commit is contained in:
Gilbert Bishop-White
2025-01-31 18:29:21 +00:00
committed by GitHub
parent e5b66193a0
commit 3360bfffe1
5 changed files with 101 additions and 14 deletions
+26 -8
View File
@@ -71,14 +71,14 @@ be the latest.
This list presents the known working version combos between the target operating system This list presents the known working version combos between the target operating system
and Erlang/OTP. and Erlang/OTP.
| Operating system | Erlang/OTP | Status | Operating system | Erlang/OTP | OTP Architecture | Status
|- |- |- |- |- | |-
| `ubuntu-18.04` | 17.0 - 25.3 | ✅ | `ubuntu-18.04` | 17.0 - 25.3 | x86_64, arm64 | ✅
| `ubuntu-20.04` | 21.0 - 27 | ✅ | `ubuntu-20.04` | 21.0 - 27 | x86_64, arm64 | ✅
| `ubuntu-22.04` | 24.2 - 27 | ✅ | `ubuntu-22.04` | 24.2 - 27 | x86_64, arm64 | ✅
| `ubuntu-24.04` | 24.3 - 27 | ✅ | `ubuntu-24.04` | 24.3 - 27 | x86_64, arm64 | ✅
| `windows-2019` | 21* - 25 | ✅ | `windows-2019` | 21\* - 25 | x86_64, x86 |
| `windows-2022` | 21* - 27 | ✅ | `windows-2022` | 21\* - 27 | x86_64, x86 |
**Note** \*: prior to 23, Windows builds are only available for minor versions, e.g. 21.0, 21.3, **Note** \*: prior to 23, Windows builds are only available for minor versions, e.g. 21.0, 21.3,
22.0, etc. 22.0, etc.
@@ -194,6 +194,24 @@ jobs:
https://cdn.jsdelivr.net/hex https://cdn.jsdelivr.net/hex
``` ```
### OTP Architecture
On Windows you can specify the OTP architecture to install.
```yaml
# create this in .github/workflows/ci.yml
on: push
jobs:
test:
runs-on: windows-latest
steps:
- uses: erlef/setup-beam@v1
with:
otp-version: '26'
otp-architecture: '32'
```
### Environment variables ### Environment variables
Base installation folders (useful for e.g. fetching headers for NIFs) are available in the following Base installation folders (useful for e.g. fetching headers for NIFs) are available in the following
+3
View File
@@ -19,6 +19,9 @@ inputs:
otp-version: otp-version:
description: Version range or exact version of Erlang/OTP to use, description: Version range or exact version of Erlang/OTP to use,
or false when installing only Gleam without OTP or false when installing only Gleam without OTP
otp-architecture:
description: 32 or 64, to specify the architecture of the OTP to install. Only applies to Windows.
default: 64
elixir-version: elixir-version:
description: Version range or exact version of Elixir to use description: Version range or exact version of Elixir to use
gleam-version: gleam-version:
+24 -3
View File
@@ -9119,6 +9119,7 @@ main().catch((err) => {
async function main() { async function main() {
checkPlatform() checkPlatform()
checkOtpArchitecture()
const versionFilePath = getInput('version-file', false) const versionFilePath = getInput('version-file', false)
let versions let versions
@@ -9388,13 +9389,16 @@ async function getOTPVersions(osVersion) {
otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference
}) })
} else if (process.platform === 'win32') { } else if (process.platform === 'win32') {
const file_regex = new RegExp(
`^otp_win${getInput('otp-architecture')}_(.*).exe$`,
)
otpVersionsListings.forEach((otpVersionsListing) => { otpVersionsListings.forEach((otpVersionsListing) => {
otpVersionsListing otpVersionsListing
.map((x) => x.assets) .map((x) => x.assets)
.flat() .flat()
.filter((x) => x.name.match(/^otp_win64_.*.exe$/)) .filter((x) => x.name.match(file_regex))
.forEach((x) => { .forEach((x) => {
const otpMatch = x.name.match(/^otp_win64_(.*).exe$/) const otpMatch = x.name.match(file_regex)
const otpVersion = otpMatch[1] const otpVersion = otpMatch[1]
debugLog('OTP line and parsing', [otpMatch, otpVersion]) debugLog('OTP line and parsing', [otpMatch, otpVersion])
otpVersions[otpVersion] = otpVersion otpVersions[otpVersion] = otpVersion
@@ -9899,7 +9903,9 @@ async function install(toolName, opts) {
win32: { win32: {
downloadToolURL: () => downloadToolURL: () =>
'https://github.com/erlang/otp/releases/download/' + 'https://github.com/erlang/otp/releases/download/' +
`OTP-${toolVersion}/otp_win64_${toolVersion}.exe`, `OTP-${toolVersion}/otp_win${getInput(
'otp-architecture',
)}_${toolVersion}.exe`,
extract: async () => ['file', 'otp.exe'], extract: async () => ['file', 'otp.exe'],
postExtract: async (cachePath) => { postExtract: async (cachePath) => {
const cmd = path.join(cachePath, 'otp.exe') const cmd = path.join(cachePath, 'otp.exe')
@@ -10155,6 +10161,21 @@ function checkPlatform() {
} }
} }
function checkOtpArchitecture() {
if (process.platform !== 'win32' && getInput('otp-architecture') == '32') {
throw new Error(
'@erlef/setup-beam only supports otp-architecture=32 on Windows',
)
}
if (
getInput('otp-architecture') !== '32' &&
getInput('otp-architecture') !== '64'
) {
throw new Error('otp-architecture must be 32 or 64')
}
}
function debugLoggingEnabled() { function debugLoggingEnabled() {
return !!process.env.RUNNER_DEBUG return !!process.env.RUNNER_DEBUG
} }
+24 -3
View File
@@ -14,6 +14,7 @@ main().catch((err) => {
async function main() { async function main() {
checkPlatform() checkPlatform()
checkOtpArchitecture()
const versionFilePath = getInput('version-file', false) const versionFilePath = getInput('version-file', false)
let versions let versions
@@ -288,13 +289,16 @@ async function getOTPVersions(osVersion) {
otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference
}) })
} else if (process.platform === 'win32') { } else if (process.platform === 'win32') {
const file_regex = new RegExp(
`^otp_win${getInput('otp-architecture')}_(.*).exe$`,
)
otpVersionsListings.forEach((otpVersionsListing) => { otpVersionsListings.forEach((otpVersionsListing) => {
otpVersionsListing otpVersionsListing
.map((x) => x.assets) .map((x) => x.assets)
.flat() .flat()
.filter((x) => x.name.match(/^otp_win64_.*.exe$/)) .filter((x) => x.name.match(file_regex))
.forEach((x) => { .forEach((x) => {
const otpMatch = x.name.match(/^otp_win64_(.*).exe$/) const otpMatch = x.name.match(file_regex)
const otpVersion = otpMatch[1] const otpVersion = otpMatch[1]
debugLog('OTP line and parsing', [otpMatch, otpVersion]) debugLog('OTP line and parsing', [otpMatch, otpVersion])
otpVersions[otpVersion] = otpVersion otpVersions[otpVersion] = otpVersion
@@ -799,7 +803,9 @@ async function install(toolName, opts) {
win32: { win32: {
downloadToolURL: () => downloadToolURL: () =>
'https://github.com/erlang/otp/releases/download/' + 'https://github.com/erlang/otp/releases/download/' +
`OTP-${toolVersion}/otp_win64_${toolVersion}.exe`, `OTP-${toolVersion}/otp_win${getInput(
'otp-architecture',
)}_${toolVersion}.exe`,
extract: async () => ['file', 'otp.exe'], extract: async () => ['file', 'otp.exe'],
postExtract: async (cachePath) => { postExtract: async (cachePath) => {
const cmd = path.join(cachePath, 'otp.exe') const cmd = path.join(cachePath, 'otp.exe')
@@ -1055,6 +1061,21 @@ function checkPlatform() {
} }
} }
function checkOtpArchitecture() {
if (process.platform !== 'win32' && getInput('otp-architecture') == '32') {
throw new Error(
'@erlef/setup-beam only supports otp-architecture=32 on Windows',
)
}
if (
getInput('otp-architecture') !== '32' &&
getInput('otp-architecture') !== '64'
) {
throw new Error('otp-architecture must be 32 or 64')
}
}
function debugLoggingEnabled() { function debugLoggingEnabled() {
return !!process.env.RUNNER_DEBUG return !!process.env.RUNNER_DEBUG
} }
+24
View File
@@ -1,4 +1,5 @@
simulateInput('otp-version', '25.1.2') simulateInput('otp-version', '25.1.2')
simulateInput('otp-architecture', '64')
simulateInput('elixir-version', '1.14.2') simulateInput('elixir-version', '1.14.2')
simulateInput('rebar3-version', '3.20') simulateInput('rebar3-version', '3.20')
simulateInput('install-rebar', 'true') simulateInput('install-rebar', 'true')
@@ -283,6 +284,29 @@ async function testOTPVersions() {
expected = '23.0.4' expected = '23.0.4'
got = await setupBeam.getOTPVersion(spec, osVersion) got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected) assert.deepStrictEqual(got, expected)
// Check we get the same results for 32-bit OTP
before = simulateInput('otp-architecture', '32')
spec = '24.0.1'
osVersion = 'windows-latest'
expected = '24.0.1'
got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected)
spec = '23.2.x'
osVersion = 'windows-2016'
expected = '23.2.7'
got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected)
spec = '23.0'
osVersion = 'windows-2019'
expected = '23.0.4'
got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected)
simulateInput('otp-architecture', before)
} }
simulateInput('hexpm-mirrors', hexMirrors, { multiline: true }) simulateInput('hexpm-mirrors', hexMirrors, { multiline: true })