From f8b54b559e6123caaab7f1aa113f60a5fad786e6 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Sat, 14 Mar 2026 20:10:19 +0000 Subject: [PATCH] Run ARM-specific tests consistently (#434) * Run ARM-specific test consistently * Fix for builds.hex.pm https://builds.hex.pm/builds/otp/arm64/ubuntu-.04/builds.txt file is only available when >= 20. * Fix for builds.hex.pm https://builds.hex.pm/builds/otp/arm64/ubuntu-20.04/builds.txt does not contain Erlang 19 any more... --- .github/workflows/action.yml | 21 +++++++++++++++--- test/setup-beam.test.js | 42 ++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index b697207..6d4a3ba 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -63,7 +63,12 @@ jobs: unit_tests_ubuntu: name: Unit tests (Ubuntu) - runs-on: ubuntu-latest + strategy: + matrix: + os: + - ubuntu-24.04-arm # ARM64 + - ubuntu-latest # x86_64 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6.0.2 - uses: actions/setup-node@v6.3.0 @@ -84,7 +89,12 @@ jobs: unit_tests_windows: name: Unit tests (Windows) - runs-on: windows-latest + strategy: + matrix: + os: + - windows-11-arm # ARM64 + - windows-latest # x86_64 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6.0.2 - uses: actions/setup-node@v6.3.0 @@ -105,7 +115,12 @@ jobs: unit_tests_macos: name: Unit tests (macOS) - runs-on: macos-latest + strategy: + matrix: + os: + - macos-latest # ARM64 + - macos-15-intel # x86_64 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6.0.2 - uses: actions/setup-node@v6.3.0 diff --git a/test/setup-beam.test.js b/test/setup-beam.test.js index fc5fad1..6091642 100644 --- a/test/setup-beam.test.js +++ b/test/setup-beam.test.js @@ -177,11 +177,8 @@ describe('.getOTPVersion(_) - Erlang', () => { 'https://repo.hex.pm, https://cdn.jsdelivr.net/hex', { multiline: true }, ) - const previousRunnerArch = process.env.RUNNER_ARCH if (process.platform === 'linux') { - process.env.RUNNER_ARCH = 'X64' - it('is Ok for known linux version', async () => { before = simulateInput('version-type', 'strict') spec = '27.0' @@ -199,21 +196,21 @@ describe('.getOTPVersion(_) - Erlang', () => { assert.deepStrictEqual(got, expected) simulateInput('version-type', before) - spec = '19.3.x' - osVersion = 'ubuntu-16.04' - expected = 'OTP-19.3.6.13' + spec = '20.3.x' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' got = await setupBeam.getOTPVersion(spec, osVersion) assert.deepStrictEqual(got, expected) - spec = '^19.3.6' - osVersion = 'ubuntu-16.04' - expected = 'OTP-19.3.6.13' + spec = '^20.3.8' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' got = await setupBeam.getOTPVersion(spec, osVersion) assert.deepStrictEqual(got, expected) - spec = '^19.3' - osVersion = 'ubuntu-18.04' - expected = 'OTP-19.3.6.13' + spec = '^20.3' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' got = await setupBeam.getOTPVersion(spec, osVersion) assert.deepStrictEqual(got, expected) @@ -309,6 +306,7 @@ describe('.getOTPVersion(_) - Erlang', () => { if (process.platform === 'linux') { it('is main-... only if strict/maint-... is used as input', async () => { const arm64Options = setupBeam.githubARMRunnerArchs() + const previousRunnerArch = process.env.RUNNER_ARCH process.env.RUNNER_ARCH = arm64Options[Math.floor(Math.random() * arm64Options.length)] @@ -344,6 +342,7 @@ describe('.getOTPVersion(_) - Erlang', () => { it('is Ok for known linux ARM64 version', async () => { const arm64Options = setupBeam.githubARMRunnerArchs() + const previousRunnerArch = process.env.RUNNER_ARCH process.env.RUNNER_ARCH = arm64Options[Math.floor(Math.random() * arm64Options.length)] @@ -404,10 +403,13 @@ describe('.getOTPVersion(_) - Erlang', () => { expected = 'master' got = await setupBeam.getOTPVersion(spec, osVersion) assert.deepStrictEqual(got, expected) + + process.env.RUNNER_ARCH = previousRunnerArch }) it('is Ok for known linux AMD64 version', async () => { const amd64Options = setupBeam.githubAMDRunnerArchs() + const previousRunnerArch = process.env.RUNNER_ARCH process.env.RUNNER_ARCH = amd64Options[Math.floor(Math.random() * amd64Options.length)] @@ -486,12 +488,15 @@ describe('.getOTPVersion(_) - Erlang', () => { expected = 'master' got = await setupBeam.getOTPVersion(spec, osVersion) assert.deepStrictEqual(got, expected) + + process.env.RUNNER_ARCH = previousRunnerArch }) } if (process.platform === 'darwin') { it('is main-... only if strict/maint-... is used as input', async () => { const arm64Options = setupBeam.githubARMRunnerArchs() + const previousRunnerArch = process.env.RUNNER_ARCH process.env.RUNNER_ARCH = arm64Options[Math.floor(Math.random() * arm64Options.length)] @@ -521,6 +526,7 @@ describe('.getOTPVersion(_) - Erlang', () => { it('is Ok for known macos ARM64 version', async () => { const arm64Options = setupBeam.githubARMRunnerArchs() + const previousRunnerArch = process.env.RUNNER_ARCH process.env.RUNNER_ARCH = arm64Options[Math.floor(Math.random() * arm64Options.length)] @@ -531,10 +537,13 @@ describe('.getOTPVersion(_) - Erlang', () => { got = await setupBeam.getOTPVersion(spec, osVersion) assert.deepStrictEqual(got, expected) simulateInput('version-type', before) + + process.env.RUNNER_ARCH = previousRunnerArch }) it('is Ok for known macos AMD64 version', async () => { const amd64Options = setupBeam.githubARMRunnerArchs() + const previousRunnerArch = process.env.RUNNER_ARCH process.env.RUNNER_ARCH = amd64Options[Math.floor(Math.random() * amd64Options.length)] @@ -545,11 +554,12 @@ describe('.getOTPVersion(_) - Erlang', () => { got = await setupBeam.getOTPVersion(spec, osVersion) assert.deepStrictEqual(got, expected) simulateInput('version-type', before) + + process.env.RUNNER_ARCH = previousRunnerArch }) } simulateInput('hexpm-mirrors', hexMirrors, { multiline: true }) - process.env.RUNNER_ARCH = previousRunnerArch }) describe('OTP arch-specific install', () => { @@ -572,6 +582,7 @@ describe('OTP arch-specific install', () => { `Fetching OTP Version with invalid Github runner architecture is supposed to fail`, ) } + process.env.RUNNER_ARCH = previousRunnerArch }) }) @@ -582,11 +593,8 @@ describe('.getOTPVersion(_) - Elixir', () => { let spec let otpVersion let before - const previousRunnerArch = process.env.RUNNER_ARCH if (process.platform === 'linux') { - process.env.RUNNER_ARCH = 'X64' - it('returns the expected value', async () => { spec = '1.18.x' otpVersion = 'OTP-27' @@ -644,8 +652,6 @@ describe('.getOTPVersion(_) - Elixir', () => { simulateInput('version-type', before) }) } - - process.env.RUNNER_ARCH = previousRunnerArch }) describe('.getOTPVersion(_) - Gleam', () => {