neiam /action-setup-beam
action-setup-beam
public · Issues · Pulls · Labels · Forks · Compare · Actions queued
⭐
Log in to mark this repository.
Override OTP version when specified in Elixir spec (#330)
3e793a7 · Kevin Schweikert · 2025-05-25 15:49
Files changed
modified
dist/index.js
+7
−1
@@ -9284,7 +9284,13 @@ async function getOTPVersion(otpSpec0, osVersion) {
| 9284 | 9284 | |
| 9285 | 9285 | async function getElixirVersion(exSpec0, otpVersion0) { |
| 9286 | 9286 | const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] |
| 9287 | − const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] | |
| 9287 | + let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] | |
| 9288 | + | |
| 9289 | + const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null | |
| 9290 | + | |
| 9291 | + if (userSuppliedOtp && isVersion(userSuppliedOtp)) { | |
| 9292 | + otpVersionMajor = userSuppliedOtp | |
| 9293 | + } | |
| 9288 | 9294 | |
| 9289 | 9295 | const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() |
| 9290 | 9296 | const spec = exSpec0.replace(/-otp-.*$/, '') |
modified
src/setup-beam.js
+7
−1
@@ -184,7 +184,13 @@ async function getOTPVersion(otpSpec0, osVersion) {
| 184 | 184 | |
| 185 | 185 | async function getElixirVersion(exSpec0, otpVersion0) { |
| 186 | 186 | const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] |
| 187 | − const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] | |
| 187 | + let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] | |
| 188 | + | |
| 189 | + const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null | |
| 190 | + | |
| 191 | + if (userSuppliedOtp && isVersion(userSuppliedOtp)) { | |
| 192 | + otpVersionMajor = userSuppliedOtp | |
| 193 | + } | |
| 188 | 194 | |
| 189 | 195 | const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() |
| 190 | 196 | const spec = exSpec0.replace(/-otp-.*$/, '') |
modified
test/setup-beam.test.js
+6
−0
@@ -511,6 +511,12 @@ describe('.getOTPVersion(_) - Elixir', () => {
| 511 | 511 | got = await setupBeam.getElixirVersion(spec, otpVersion) |
| 512 | 512 | assert.deepStrictEqual(got, expected) |
| 513 | 513 | |
| 514 | + spec = '1.16.2-otp-26' | |
| 515 | + otpVersion = 'OTP-27' | |
| 516 | + expected = 'v1.16.2-otp-26' | |
| 517 | + got = await setupBeam.getElixirVersion(spec, otpVersion) | |
| 518 | + assert.deepStrictEqual(got, expected) | |
| 519 | + | |
| 514 | 520 | spec = '1.12.1' |
| 515 | 521 | otpVersion = 'OTP-24.0.2' |
| 516 | 522 | expected = 'v1.12.1-otp-24' |
Parents: 98ad08a