From 2f5d0fd23577f424a78aa091aa3ccae213f4694a Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 24 May 2024 14:03:43 -0700 Subject: [PATCH 01/16] support arm64 builds --- src/setup-beam.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/setup-beam.js b/src/setup-beam.js index 7135893f..21c3b9a1 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -499,7 +499,9 @@ function getRunnerOSVersion() { "']", ) } - + if (['ARM', 'ARM64'].includes(process.env.RUNNER_ARCH)) { + containerFromEnvImageOS = `arm64/${containerFromEnvImageOS}` + } return containerFromEnvImageOS } From ec10220114d125696cee26933fbf132338db369a Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 24 May 2024 14:10:50 -0700 Subject: [PATCH 02/16] update name --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 419d55af..807ead4a 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ --- -name: Setup Erlang/OTP with optional Elixir (and mix) and/or rebar3 +name: Setup Erlang/OTP with optional Elixir (and mix) and/or rebar3 arm64 description: > Set up a specific version of Erlang/OTP, Elixir, and/or rebar3 and add the command-line tools to the PATH From e88a4501dd5c3095fa55e028d81905427ee0f555 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 24 May 2024 14:18:48 -0700 Subject: [PATCH 03/16] remove .github --- .github/ISSUE_TEMPLATE/bug_report.md | 35 --- .github/ISSUE_TEMPLATE/feature_request.md | 26 -- .github/pull_request_template.md | 8 - .github/workflows/action.yml | 77 ------ .github/workflows/hexpm-mirrors.yml | 38 --- .github/workflows/ubuntu.yml | 223 ------------------ .../workflows/update_3rd_party_licenses.sh | 28 --- .../workflows/update_3rd_party_licenses.yml | 18 -- .github/workflows/windows.yml | 154 ------------ 9 files changed, 607 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/action.yml delete mode 100644 .github/workflows/hexpm-mirrors.yml delete mode 100644 .github/workflows/ubuntu.yml delete mode 100755 .github/workflows/update_3rd_party_licenses.sh delete mode 100644 .github/workflows/update_3rd_party_licenses.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 97afdcc8..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Bug report -about: Report a bug to improve this project -title: '' -labels: 'bug' -assignees: '' - ---- - -#### The bug - -A clear and concise description of what the bug is. - -#### Software versions - -A list of software versions where the bug is apparent, as detailed as possible: - -* `setup-beam`: ... -* other (where applicable): ... - -#### How to replicate - -An ordered list of steps to replicate the bug: - -1. run `...` -2. search for `...` in the error output -3. look at file `...` - -#### Expected behaviour - -What's expected to happen when you follow the steps listed above. - -#### Additional context - -Any other context about the bug. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index d20a7a66..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: Feature request -about: Request a feature for this project -title: '' -labels: 'feature' -assignees: '' - ---- - -#### Is your feature request related to a problem? - -A clear and concise description of what the problem is, e.g. "I'm always frustrated -when ..." - -#### Describe the feature you'd like - -A clear and concise description of what you want to happen after the new feature -is implemented. - -#### Describe alternatives you've considered - -A clear and concise description of any alternative solutions or features you've considered. - -#### Additional context - -Any other context about the feature request. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 89306570..00000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,8 +0,0 @@ -# Description - -A brief description of your changes. - -Closes #<issue>. - -- [ ] I have performed a self-review of my changes -- [ ] I have read and understood the [contributing guidelines](/erlef/setup-beam/blob/main/CONTRIBUTING.md) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml deleted file mode 100644 index 949cbf76..00000000 --- a/.github/workflows/action.yml +++ /dev/null @@ -1,77 +0,0 @@ ---- -name: action - -on: - push: - branches: - - main - pull_request: - branches: - - "*" - workflow_dispatch: {} - -env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - -jobs: - version: - name: Version with commit unique id - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v4 - - name: Version it! - run: | - # We expect a string such as const setupBeamVersion = 'undefined' in the code - SHA=$(git rev-parse --short HEAD) - sed -i'.bak' \ - -e "s/const setupBeamVersion = '.*'/const setupBeamVersion = '${SHA}'/g" \ - src/setup-beam.js - npm run build-dist - git config user.name "GitHub Actions" - git config user.email "actions@user.noreply.github.com" - git add src/setup-beam.js - git add dist/index.js - git commit -m "Automation: update setup-beam version output to ${SHA}" - git push origin main - - check_integrity: - name: Expected local npm actions - runs-on: ubuntu-latest - if: github.ref != 'refs/heads/main' - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '20' - - run: npm run build-dist - - name: Check if build left artifacts - run: git diff --exit-code --ignore-space-at-eol - - unit_tests_ubuntu: - name: Unit tests (Ubuntu) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '20' - - run: npm ci - - run: npm test - - name: .tool-versions test - id: setup-beam - uses: ./ - with: - version-file: test/.tool-versions - version-type: strict - - unit_tests_windows: - name: Unit tests (Windows) - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '20' - - run: npm install --production - - run: npm test diff --git a/.github/workflows/hexpm-mirrors.yml b/.github/workflows/hexpm-mirrors.yml deleted file mode 100644 index 45eecd3e..00000000 --- a/.github/workflows/hexpm-mirrors.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: hexpm-mirrors - -on: - push: - branches: - - main - pull_request: - branches: - - "*" - workflow_dispatch: {} - -jobs: - test-failing-first-mirror: - name: Test option hexpm-mirrors with a dummy first mirror - runs-on: ${{matrix.os}} - strategy: - fail-fast: false - matrix: - os: ['ubuntu-22.04', 'windows-2022'] - otp-version: ['24'] - elixir-version: ['v1.14', ''] - install-rebar: [true, false] - install-hex: [true, false] - steps: - - uses: actions/checkout@v4 - - name: Use erlef/setup-beam - id: setup-beam - uses: ./ - with: - otp-version: ${{matrix.otp-version}} - elixir-version: ${{matrix.elixir-version}} - install-rebar: ${{matrix.install-rebar}} - install-hex: ${{matrix.install-hex}} - hexpm-mirrors: | - https://mirror.invalid - https://cdn.jsdelivr.net/hex - https://builds.hex.pm diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml deleted file mode 100644 index 81008a15..00000000 --- a/.github/workflows/ubuntu.yml +++ /dev/null @@ -1,223 +0,0 @@ ---- -name: ubuntu - -on: - push: - branches: - - main - pull_request: - branches: - - "*" - workflow_dispatch: {} - -jobs: - integration_test: - name: > - OTP ${{matrix.combo.otp-version}}, - Elixir ${{matrix.combo.elixir-version}}, - Gleam ${{matrix.combo.gleam-version}}, - rebar3 ${{matrix.combo.rebar3-version}} - runs-on: ${{matrix.combo.os}} - strategy: - fail-fast: false - matrix: - combo: - - otp-version: 'OTP-27.0-rc1' - os: 'ubuntu-latest' - - otp-version: '26.0' - elixir-version: 'v1.14-otp-25' - os: 'ubuntu-latest' - version-type: 'strict' - - otp-version: '26.0' - elixir-version: '1.14.5' - os: 'ubuntu-latest' - version-type: 'strict' - - otp-version: '25.2' - elixir-version: '1.14.2' - os: 'ubuntu-latest' - - otp-version: '25.2' - elixir-version: '1.14.3' - os: 'ubuntu-latest' - version-type: 'strict' - - otp-version: '27' - os: 'ubuntu-24.04' - version-type: 'strict' - - otp-version: '26' - os: 'ubuntu-24.04' - version-type: 'strict' - - otp-version: '25' - os: 'ubuntu-24.04' - - otp-version: '25' - elixir-version: '1' - rebar3-version: '3' - os: 'ubuntu-22.04' - - otp-version: '24' - elixir-version: '1' - rebar3-version: '3' - os: 'ubuntu-22.04' - - otp-version: '25.0' - elixir-version: 'v1.13.4-otp-25' - rebar3-version: '3.18.0' - os: 'ubuntu-latest' - version-type: 'strict' - - otp-version: '25.0' - elixir-version: 'v1.13.4' - rebar3-version: '3.18.0' - os: 'ubuntu-latest' - version-type: 'strict' - - otp-version: '25' - rebar3-version: 'nightly' - os: 'ubuntu-latest' - - otp-version: '24' - rebar3-version: 'nightly' - os: 'ubuntu-latest' - - elixir-version: 'v1.4' - otp-version: '20' - rebar3-version: '3.15.0' - os: 'ubuntu-20.04' - - elixir-version: 'v1.4' - otp-version: '20' - rebar3-version: '3.11' - os: 'ubuntu-20.04' - - elixir-version: 'v1.6' - otp-version: '21' - rebar3-version: '3.12' - os: 'ubuntu-20.04' - - elixir-version: 'v1.7' - otp-version: '22' - rebar3-version: '3.13' - os: 'ubuntu-20.04' - - elixir-version: 'v1.10' - otp-version: '23' - rebar3-version: '3.14' - os: 'ubuntu-20.04' - - elixir-version: 'v1.13.4' - otp-version: '25.0.2' - rebar3-version: '3.19' - os: 'ubuntu-20.04' - - elixir-version: 'v1.12' - otp-version: '24' - rebar3-version: '3.15' - os: 'ubuntu-20.04' - - elixir-version: 'v1.11.0' - otp-version: '22.3.4.2' - os: 'ubuntu-20.04' - version-type: 'strict' - - elixir-version: '1.10.3' - otp-version: '22.3.4.1' - os: 'ubuntu-20.04' - version-type: 'strict' - - elixir-version: 'main' - otp-version: '23.1' - os: 'ubuntu-20.04' - version-type: 'strict' - - elixir-version: 'main' - otp-version: '25' - os: 'ubuntu-20.04' - version-type: 'strict' - - gleam-version: '0.23' - otp-version: '24' - os: 'ubuntu-latest' - disable_problem_matchers: true - - gleam-version: '0.23.0-rc1' - otp-version: '24' - os: 'ubuntu-latest' - disable_problem_matchers: true - - gleam-version: '0.23.0-rc1' - otp-version: false - os: 'ubuntu-latest' - disable_problem_matchers: true - - gleam-version: '0.22.0' # Version with Gleam's old archive naming convention - otp-version: '24' - os: 'ubuntu-latest' - disable_problem_matchers: true - - elixir-version: 'v1.13' - otp-version: '24' - escript_packages: 'hex protobuf' - escript_script: 'protoc-gen-elixir --version' - os: 'ubuntu-latest' - steps: - - uses: actions/checkout@v4 - - name: Use erlef/setup-beam - id: setup-beam - uses: ./ - with: - otp-version: ${{matrix.combo.otp-version}} - elixir-version: ${{matrix.combo.elixir-version}} - gleam-version: ${{matrix.combo.gleam-version}} - rebar3-version: ${{matrix.combo.rebar3-version}} - version-type: ${{matrix.combo.version-type}} - - name: Erlang/OTP version (action) - run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}" - if: ${{matrix.combo.otp-version}} - - name: Elixir version (action) - run: echo "Elixir ${{steps.setup-beam.outputs.elixir-version}}" - if: ${{matrix.combo.elixir-version}} - - name: Gleam version (action) - run: echo "Gleam ${{steps.setup-beam.outputs.gleam-version}}" - if: ${{matrix.combo.gleam-version}} - - name: rebar3 version (action) - run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}" - if: ${{matrix.combo.rebar3-version}} - - name: mix version and help (CLI) - run: | - mix -v - mix help local.rebar - mix help local.hex - if: ${{matrix.combo.elixir-version}} - - name: Run Elixir/Mix project tests - run: | - cd test/projects/elixir_mix - mix deps.get - mix test - if: ${{matrix.combo.elixir-version}} - - name: Run Erlang/rebar3 project tests - run: | - cd test/projects/erlang_rebar3 - rebar3 ct - if: ${{matrix.combo.rebar3-version}} - - name: Format Gleam project (without installing Erlang/OTP) - run: | - cd test/projects/gleam_gleam - gleam format - if: ${{ matrix.combo.gleam-version && !matrix.combo.otp-version }} - - name: Run Gleam project tests (without `rebar3`) - run: | - cd test/projects/gleam_gleam - gleam test - if: ${{ matrix.combo.gleam-version && matrix.combo.otp-version && !matrix.combo.rebar3-version }} - - name: Run escript - run: | - mix escript.install --force ${{matrix.combo.escript_packages}} - ${{matrix.combo.escript_script}} - if: ${{matrix.combo.escript_packages && matrix.combo.escript_script}} - - environment_variables: - name: Environment variables - runs-on: ${{matrix.combo.os}} - strategy: - fail-fast: false - matrix: - combo: - - otp-version: '24' - elixir-version: 'v1.12' - gleam-version: '0.23.0-rc1' - rebar3-version: 'nightly' - os: 'ubuntu-latest' - steps: - - uses: actions/checkout@v4 - - name: Use erlef/setup-beam - id: setup-beam - uses: ./ - with: - otp-version: ${{matrix.combo.otp-version}} - elixir-version: ${{matrix.combo.elixir-version}} - gleam-version: ${{matrix.combo.gleam-version}} - rebar3-version: ${{matrix.combo.rebar3-version}} - - run: env - - name: Check environment variables - run: | - ${INSTALL_DIR_FOR_ELIXIR}/bin/elixir -v - ${INSTALL_DIR_FOR_GLEAM}/bin/gleam --version - ${INSTALL_DIR_FOR_OTP}/bin/erl -version - ${INSTALL_DIR_FOR_REBAR3}/bin/rebar3 version diff --git a/.github/workflows/update_3rd_party_licenses.sh b/.github/workflows/update_3rd_party_licenses.sh deleted file mode 100755 index 7ab6518c..00000000 --- a/.github/workflows/update_3rd_party_licenses.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -git config user.name "GitHub Actions" -git config user.email "actions@user.noreply.github.com" - -BRANCH=feature/3rd-party-licenses-update - -if git branch -a | grep "$BRANCH" > /dev/null; then - # already exists - exit -fi - -git fetch origin -git checkout -b "$BRANCH" -npm run licenses - -if ! git diff --exit-code 1> /dev/null ; then - # there's stuff to push - git add 3RD_PARTY_LICENSES - git commit -m "Update 3rd party licenses" - git push origin "$BRANCH" - - gh pr create --fill \ - --title "Update 3rd party licenses (automation)" \ - --body "This is an automated action to update the action's 3rd party licenses" -fi diff --git a/.github/workflows/update_3rd_party_licenses.yml b/.github/workflows/update_3rd_party_licenses.yml deleted file mode 100644 index 54a31ce1..00000000 --- a/.github/workflows/update_3rd_party_licenses.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Update 3rd party licenses (automation) - -on: - schedule: - - cron: '0 12 * * *' - workflow_dispatch: - -jobs: - update: - name: Update 3rd party licenses - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: - ./.github/workflows/update_3rd_party_licenses.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index f49fcafd..00000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,154 +0,0 @@ ---- -name: windows - -on: - push: - branches: - - main - pull_request: - branches: - - "*" - workflow_dispatch: {} - -jobs: - integration_test: - name: > - OTP ${{matrix.combo.otp-version}}, - Elixir ${{matrix.combo.elixir-version}}, - Gleam ${{matrix.combo.gleam-version}}, - rebar3 ${{matrix.combo.rebar3-version}} - runs-on: ${{matrix.combo.os}} - strategy: - fail-fast: false - matrix: - combo: - - otp-version: 'OTP-27.0-rc1' - os: 'windows-latest' - - otp-version: '26.0' - elixir-version: 'main' - os: 'windows-latest' - version-type: 'strict' - - otp-version: '26.0' - elixir-version: 'v1.14-otp-25' - os: 'windows-latest' - version-type: 'strict' - - otp-version: '26.0' - elixir-version: '1.14.5' - os: 'windows-latest' - version-type: 'strict' - - otp-version: '25' - rebar3-version: 'nightly' - os: 'windows-latest' - - otp-version: '24.0.2' - rebar3-version: '3.16' - os: 'windows-2019' - - otp-version: '24.0.2' - rebar3-version: 'nightly' - os: 'windows-2019' - - otp-version: '23.0' - rebar3-version: '3.15' - os: 'windows-2019' - - elixir-version: 'v1.10' - otp-version: '23' - rebar3-version: '3.14' - os: 'windows-latest' - - elixir-version: 'v1.13' - otp-version: '24' - rebar3-version: '3.15' - os: 'windows-latest' - - gleam-version: '0.19.0-rc3' - otp-version: '24' - os: 'windows-latest' - - gleam-version: '0.23.0-rc1' - otp-version: '24' - os: 'windows-latest' - - elixir-version: 'v1.13' - otp-version: '24' - escript_packages: 'hex protobuf' - escript_script: 'protoc-gen-elixir --version' - os: 'windows-latest' - steps: - - uses: actions/checkout@v4 - - name: Use erlef/setup-beam - id: setup-beam - uses: ./ - with: - otp-version: ${{matrix.combo.otp-version}} - elixir-version: ${{matrix.combo.elixir-version}} - gleam-version: ${{matrix.combo.gleam-version}} - rebar3-version: ${{matrix.combo.rebar3-version}} - version-type: ${{matrix.combo.version-type}} - - name: Erlang/OTP version (action) - run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}" - - name: Elixir version (action) - run: echo "Elixir ${{steps.setup-beam.outputs.elixir-version}}" - if: ${{matrix.combo.elixir-version}} - - name: Gleam version (action) - run: echo "Gleam ${{steps.setup-beam.outputs.gleam-version}}" - if: ${{matrix.combo.gleam-version}} - - name: rebar3 version (action) - run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}" - - name: Run rebar3 and rebar3.cmd - run: | - # Should not fail - rebar3 version - rebar3.cmd version - if: ${{matrix.combo.rebar3-version}} - - name: rebar3 from Rust - run: | - cd test/projects/rust_rebar3_cmd - cargo test -- --nocapture - if: ${{matrix.combo.rebar3-version}} - - name: mix version and help (CLI) - run: | - mix -v - mix help local.rebar - mix help local.hex - if: ${{matrix.combo.elixir-version}} - - name: Run Elixir/Mix project tests - run: | - cd test/projects/elixir_mix - mix deps.get - mix test - if: ${{matrix.combo.elixir-version}} - - name: Run Erlang/rebar3 project tests - run: | - cd test/projects/erlang_rebar3 - rebar3 ct - if: ${{matrix.combo.rebar3-version}} - - name: Run escript - run: | - mix escript.install --force ${{matrix.combo.escript_packages}} - ${{matrix.combo.escript_script}} - if: ${{matrix.combo.escript_packages && matrix.combo.escript_script}} - - environment_variables: - name: Environment variables - runs-on: ${{matrix.combo.os}} - strategy: - fail-fast: false - matrix: - combo: - - otp-version: '24' - elixir-version: 'v1.12' - gleam-version: '0.23.0-rc1' - rebar3-version: 'nightly' - os: 'windows-latest' - steps: - - uses: actions/checkout@v4 - - name: Use erlef/setup-beam - id: setup-beam - uses: ./ - with: - otp-version: ${{matrix.combo.otp-version}} - elixir-version: ${{matrix.combo.elixir-version}} - gleam-version: ${{matrix.combo.gleam-version}} - rebar3-version: ${{matrix.combo.rebar3-version}} - - run: env - - name: Check environment variables - run: | - & "$Env:INSTALL_DIR_FOR_ELIXIR/bin/elixir" "-v" - & "$Env:INSTALL_DIR_FOR_GLEAM/bin/gleam.exe" "--version" - & "$Env:INSTALL_DIR_FOR_OTP/bin/erl.exe" "+V" - & "$Env:INSTALL_DIR_FOR_REBAR3/bin/rebar3.cmd" "version" - & "$Env:INSTALL_DIR_FOR_REBAR3/bin/rebar3.ps1" "version" From 126034e08377e4a1bea9f5f21f6b347f2bee1643 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 24 May 2024 16:35:02 -0700 Subject: [PATCH 04/16] Revert "remove .github" This reverts commit e88a4501dd5c3095fa55e028d81905427ee0f555. --- .github/ISSUE_TEMPLATE/bug_report.md | 35 +++ .github/ISSUE_TEMPLATE/feature_request.md | 26 ++ .github/pull_request_template.md | 8 + .github/workflows/action.yml | 77 ++++++ .github/workflows/hexpm-mirrors.yml | 38 +++ .github/workflows/ubuntu.yml | 223 ++++++++++++++++++ .../workflows/update_3rd_party_licenses.sh | 28 +++ .../workflows/update_3rd_party_licenses.yml | 18 ++ .github/workflows/windows.yml | 154 ++++++++++++ 9 files changed, 607 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/action.yml create mode 100644 .github/workflows/hexpm-mirrors.yml create mode 100644 .github/workflows/ubuntu.yml create mode 100755 .github/workflows/update_3rd_party_licenses.sh create mode 100644 .github/workflows/update_3rd_party_licenses.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..97afdcc8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Report a bug to improve this project +title: '' +labels: 'bug' +assignees: '' + +--- + +#### The bug + +A clear and concise description of what the bug is. + +#### Software versions + +A list of software versions where the bug is apparent, as detailed as possible: + +* `setup-beam`: ... +* other (where applicable): ... + +#### How to replicate + +An ordered list of steps to replicate the bug: + +1. run `...` +2. search for `...` in the error output +3. look at file `...` + +#### Expected behaviour + +What's expected to happen when you follow the steps listed above. + +#### Additional context + +Any other context about the bug. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..d20a7a66 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,26 @@ +--- +name: Feature request +about: Request a feature for this project +title: '' +labels: 'feature' +assignees: '' + +--- + +#### Is your feature request related to a problem? + +A clear and concise description of what the problem is, e.g. "I'm always frustrated +when ..." + +#### Describe the feature you'd like + +A clear and concise description of what you want to happen after the new feature +is implemented. + +#### Describe alternatives you've considered + +A clear and concise description of any alternative solutions or features you've considered. + +#### Additional context + +Any other context about the feature request. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..89306570 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,8 @@ +# Description + +A brief description of your changes. + +Closes #<issue>. + +- [ ] I have performed a self-review of my changes +- [ ] I have read and understood the [contributing guidelines](/erlef/setup-beam/blob/main/CONTRIBUTING.md) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml new file mode 100644 index 00000000..949cbf76 --- /dev/null +++ b/.github/workflows/action.yml @@ -0,0 +1,77 @@ +--- +name: action + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + workflow_dispatch: {} + +env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + +jobs: + version: + name: Version with commit unique id + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4 + - name: Version it! + run: | + # We expect a string such as const setupBeamVersion = 'undefined' in the code + SHA=$(git rev-parse --short HEAD) + sed -i'.bak' \ + -e "s/const setupBeamVersion = '.*'/const setupBeamVersion = '${SHA}'/g" \ + src/setup-beam.js + npm run build-dist + git config user.name "GitHub Actions" + git config user.email "actions@user.noreply.github.com" + git add src/setup-beam.js + git add dist/index.js + git commit -m "Automation: update setup-beam version output to ${SHA}" + git push origin main + + check_integrity: + name: Expected local npm actions + runs-on: ubuntu-latest + if: github.ref != 'refs/heads/main' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - run: npm run build-dist + - name: Check if build left artifacts + run: git diff --exit-code --ignore-space-at-eol + + unit_tests_ubuntu: + name: Unit tests (Ubuntu) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - run: npm ci + - run: npm test + - name: .tool-versions test + id: setup-beam + uses: ./ + with: + version-file: test/.tool-versions + version-type: strict + + unit_tests_windows: + name: Unit tests (Windows) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - run: npm install --production + - run: npm test diff --git a/.github/workflows/hexpm-mirrors.yml b/.github/workflows/hexpm-mirrors.yml new file mode 100644 index 00000000..45eecd3e --- /dev/null +++ b/.github/workflows/hexpm-mirrors.yml @@ -0,0 +1,38 @@ +--- +name: hexpm-mirrors + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + workflow_dispatch: {} + +jobs: + test-failing-first-mirror: + name: Test option hexpm-mirrors with a dummy first mirror + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: ['ubuntu-22.04', 'windows-2022'] + otp-version: ['24'] + elixir-version: ['v1.14', ''] + install-rebar: [true, false] + install-hex: [true, false] + steps: + - uses: actions/checkout@v4 + - name: Use erlef/setup-beam + id: setup-beam + uses: ./ + with: + otp-version: ${{matrix.otp-version}} + elixir-version: ${{matrix.elixir-version}} + install-rebar: ${{matrix.install-rebar}} + install-hex: ${{matrix.install-hex}} + hexpm-mirrors: | + https://mirror.invalid + https://cdn.jsdelivr.net/hex + https://builds.hex.pm diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 00000000..81008a15 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,223 @@ +--- +name: ubuntu + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + workflow_dispatch: {} + +jobs: + integration_test: + name: > + OTP ${{matrix.combo.otp-version}}, + Elixir ${{matrix.combo.elixir-version}}, + Gleam ${{matrix.combo.gleam-version}}, + rebar3 ${{matrix.combo.rebar3-version}} + runs-on: ${{matrix.combo.os}} + strategy: + fail-fast: false + matrix: + combo: + - otp-version: 'OTP-27.0-rc1' + os: 'ubuntu-latest' + - otp-version: '26.0' + elixir-version: 'v1.14-otp-25' + os: 'ubuntu-latest' + version-type: 'strict' + - otp-version: '26.0' + elixir-version: '1.14.5' + os: 'ubuntu-latest' + version-type: 'strict' + - otp-version: '25.2' + elixir-version: '1.14.2' + os: 'ubuntu-latest' + - otp-version: '25.2' + elixir-version: '1.14.3' + os: 'ubuntu-latest' + version-type: 'strict' + - otp-version: '27' + os: 'ubuntu-24.04' + version-type: 'strict' + - otp-version: '26' + os: 'ubuntu-24.04' + version-type: 'strict' + - otp-version: '25' + os: 'ubuntu-24.04' + - otp-version: '25' + elixir-version: '1' + rebar3-version: '3' + os: 'ubuntu-22.04' + - otp-version: '24' + elixir-version: '1' + rebar3-version: '3' + os: 'ubuntu-22.04' + - otp-version: '25.0' + elixir-version: 'v1.13.4-otp-25' + rebar3-version: '3.18.0' + os: 'ubuntu-latest' + version-type: 'strict' + - otp-version: '25.0' + elixir-version: 'v1.13.4' + rebar3-version: '3.18.0' + os: 'ubuntu-latest' + version-type: 'strict' + - otp-version: '25' + rebar3-version: 'nightly' + os: 'ubuntu-latest' + - otp-version: '24' + rebar3-version: 'nightly' + os: 'ubuntu-latest' + - elixir-version: 'v1.4' + otp-version: '20' + rebar3-version: '3.15.0' + os: 'ubuntu-20.04' + - elixir-version: 'v1.4' + otp-version: '20' + rebar3-version: '3.11' + os: 'ubuntu-20.04' + - elixir-version: 'v1.6' + otp-version: '21' + rebar3-version: '3.12' + os: 'ubuntu-20.04' + - elixir-version: 'v1.7' + otp-version: '22' + rebar3-version: '3.13' + os: 'ubuntu-20.04' + - elixir-version: 'v1.10' + otp-version: '23' + rebar3-version: '3.14' + os: 'ubuntu-20.04' + - elixir-version: 'v1.13.4' + otp-version: '25.0.2' + rebar3-version: '3.19' + os: 'ubuntu-20.04' + - elixir-version: 'v1.12' + otp-version: '24' + rebar3-version: '3.15' + os: 'ubuntu-20.04' + - elixir-version: 'v1.11.0' + otp-version: '22.3.4.2' + os: 'ubuntu-20.04' + version-type: 'strict' + - elixir-version: '1.10.3' + otp-version: '22.3.4.1' + os: 'ubuntu-20.04' + version-type: 'strict' + - elixir-version: 'main' + otp-version: '23.1' + os: 'ubuntu-20.04' + version-type: 'strict' + - elixir-version: 'main' + otp-version: '25' + os: 'ubuntu-20.04' + version-type: 'strict' + - gleam-version: '0.23' + otp-version: '24' + os: 'ubuntu-latest' + disable_problem_matchers: true + - gleam-version: '0.23.0-rc1' + otp-version: '24' + os: 'ubuntu-latest' + disable_problem_matchers: true + - gleam-version: '0.23.0-rc1' + otp-version: false + os: 'ubuntu-latest' + disable_problem_matchers: true + - gleam-version: '0.22.0' # Version with Gleam's old archive naming convention + otp-version: '24' + os: 'ubuntu-latest' + disable_problem_matchers: true + - elixir-version: 'v1.13' + otp-version: '24' + escript_packages: 'hex protobuf' + escript_script: 'protoc-gen-elixir --version' + os: 'ubuntu-latest' + steps: + - uses: actions/checkout@v4 + - name: Use erlef/setup-beam + id: setup-beam + uses: ./ + with: + otp-version: ${{matrix.combo.otp-version}} + elixir-version: ${{matrix.combo.elixir-version}} + gleam-version: ${{matrix.combo.gleam-version}} + rebar3-version: ${{matrix.combo.rebar3-version}} + version-type: ${{matrix.combo.version-type}} + - name: Erlang/OTP version (action) + run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}" + if: ${{matrix.combo.otp-version}} + - name: Elixir version (action) + run: echo "Elixir ${{steps.setup-beam.outputs.elixir-version}}" + if: ${{matrix.combo.elixir-version}} + - name: Gleam version (action) + run: echo "Gleam ${{steps.setup-beam.outputs.gleam-version}}" + if: ${{matrix.combo.gleam-version}} + - name: rebar3 version (action) + run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}" + if: ${{matrix.combo.rebar3-version}} + - name: mix version and help (CLI) + run: | + mix -v + mix help local.rebar + mix help local.hex + if: ${{matrix.combo.elixir-version}} + - name: Run Elixir/Mix project tests + run: | + cd test/projects/elixir_mix + mix deps.get + mix test + if: ${{matrix.combo.elixir-version}} + - name: Run Erlang/rebar3 project tests + run: | + cd test/projects/erlang_rebar3 + rebar3 ct + if: ${{matrix.combo.rebar3-version}} + - name: Format Gleam project (without installing Erlang/OTP) + run: | + cd test/projects/gleam_gleam + gleam format + if: ${{ matrix.combo.gleam-version && !matrix.combo.otp-version }} + - name: Run Gleam project tests (without `rebar3`) + run: | + cd test/projects/gleam_gleam + gleam test + if: ${{ matrix.combo.gleam-version && matrix.combo.otp-version && !matrix.combo.rebar3-version }} + - name: Run escript + run: | + mix escript.install --force ${{matrix.combo.escript_packages}} + ${{matrix.combo.escript_script}} + if: ${{matrix.combo.escript_packages && matrix.combo.escript_script}} + + environment_variables: + name: Environment variables + runs-on: ${{matrix.combo.os}} + strategy: + fail-fast: false + matrix: + combo: + - otp-version: '24' + elixir-version: 'v1.12' + gleam-version: '0.23.0-rc1' + rebar3-version: 'nightly' + os: 'ubuntu-latest' + steps: + - uses: actions/checkout@v4 + - name: Use erlef/setup-beam + id: setup-beam + uses: ./ + with: + otp-version: ${{matrix.combo.otp-version}} + elixir-version: ${{matrix.combo.elixir-version}} + gleam-version: ${{matrix.combo.gleam-version}} + rebar3-version: ${{matrix.combo.rebar3-version}} + - run: env + - name: Check environment variables + run: | + ${INSTALL_DIR_FOR_ELIXIR}/bin/elixir -v + ${INSTALL_DIR_FOR_GLEAM}/bin/gleam --version + ${INSTALL_DIR_FOR_OTP}/bin/erl -version + ${INSTALL_DIR_FOR_REBAR3}/bin/rebar3 version diff --git a/.github/workflows/update_3rd_party_licenses.sh b/.github/workflows/update_3rd_party_licenses.sh new file mode 100755 index 00000000..7ab6518c --- /dev/null +++ b/.github/workflows/update_3rd_party_licenses.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -eux + +git config user.name "GitHub Actions" +git config user.email "actions@user.noreply.github.com" + +BRANCH=feature/3rd-party-licenses-update + +if git branch -a | grep "$BRANCH" > /dev/null; then + # already exists + exit +fi + +git fetch origin +git checkout -b "$BRANCH" +npm run licenses + +if ! git diff --exit-code 1> /dev/null ; then + # there's stuff to push + git add 3RD_PARTY_LICENSES + git commit -m "Update 3rd party licenses" + git push origin "$BRANCH" + + gh pr create --fill \ + --title "Update 3rd party licenses (automation)" \ + --body "This is an automated action to update the action's 3rd party licenses" +fi diff --git a/.github/workflows/update_3rd_party_licenses.yml b/.github/workflows/update_3rd_party_licenses.yml new file mode 100644 index 00000000..54a31ce1 --- /dev/null +++ b/.github/workflows/update_3rd_party_licenses.yml @@ -0,0 +1,18 @@ +--- +name: Update 3rd party licenses (automation) + +on: + schedule: + - cron: '0 12 * * *' + workflow_dispatch: + +jobs: + update: + name: Update 3rd party licenses + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: + ./.github/workflows/update_3rd_party_licenses.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..f49fcafd --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,154 @@ +--- +name: windows + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + workflow_dispatch: {} + +jobs: + integration_test: + name: > + OTP ${{matrix.combo.otp-version}}, + Elixir ${{matrix.combo.elixir-version}}, + Gleam ${{matrix.combo.gleam-version}}, + rebar3 ${{matrix.combo.rebar3-version}} + runs-on: ${{matrix.combo.os}} + strategy: + fail-fast: false + matrix: + combo: + - otp-version: 'OTP-27.0-rc1' + os: 'windows-latest' + - otp-version: '26.0' + elixir-version: 'main' + os: 'windows-latest' + version-type: 'strict' + - otp-version: '26.0' + elixir-version: 'v1.14-otp-25' + os: 'windows-latest' + version-type: 'strict' + - otp-version: '26.0' + elixir-version: '1.14.5' + os: 'windows-latest' + version-type: 'strict' + - otp-version: '25' + rebar3-version: 'nightly' + os: 'windows-latest' + - otp-version: '24.0.2' + rebar3-version: '3.16' + os: 'windows-2019' + - otp-version: '24.0.2' + rebar3-version: 'nightly' + os: 'windows-2019' + - otp-version: '23.0' + rebar3-version: '3.15' + os: 'windows-2019' + - elixir-version: 'v1.10' + otp-version: '23' + rebar3-version: '3.14' + os: 'windows-latest' + - elixir-version: 'v1.13' + otp-version: '24' + rebar3-version: '3.15' + os: 'windows-latest' + - gleam-version: '0.19.0-rc3' + otp-version: '24' + os: 'windows-latest' + - gleam-version: '0.23.0-rc1' + otp-version: '24' + os: 'windows-latest' + - elixir-version: 'v1.13' + otp-version: '24' + escript_packages: 'hex protobuf' + escript_script: 'protoc-gen-elixir --version' + os: 'windows-latest' + steps: + - uses: actions/checkout@v4 + - name: Use erlef/setup-beam + id: setup-beam + uses: ./ + with: + otp-version: ${{matrix.combo.otp-version}} + elixir-version: ${{matrix.combo.elixir-version}} + gleam-version: ${{matrix.combo.gleam-version}} + rebar3-version: ${{matrix.combo.rebar3-version}} + version-type: ${{matrix.combo.version-type}} + - name: Erlang/OTP version (action) + run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}" + - name: Elixir version (action) + run: echo "Elixir ${{steps.setup-beam.outputs.elixir-version}}" + if: ${{matrix.combo.elixir-version}} + - name: Gleam version (action) + run: echo "Gleam ${{steps.setup-beam.outputs.gleam-version}}" + if: ${{matrix.combo.gleam-version}} + - name: rebar3 version (action) + run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}" + - name: Run rebar3 and rebar3.cmd + run: | + # Should not fail + rebar3 version + rebar3.cmd version + if: ${{matrix.combo.rebar3-version}} + - name: rebar3 from Rust + run: | + cd test/projects/rust_rebar3_cmd + cargo test -- --nocapture + if: ${{matrix.combo.rebar3-version}} + - name: mix version and help (CLI) + run: | + mix -v + mix help local.rebar + mix help local.hex + if: ${{matrix.combo.elixir-version}} + - name: Run Elixir/Mix project tests + run: | + cd test/projects/elixir_mix + mix deps.get + mix test + if: ${{matrix.combo.elixir-version}} + - name: Run Erlang/rebar3 project tests + run: | + cd test/projects/erlang_rebar3 + rebar3 ct + if: ${{matrix.combo.rebar3-version}} + - name: Run escript + run: | + mix escript.install --force ${{matrix.combo.escript_packages}} + ${{matrix.combo.escript_script}} + if: ${{matrix.combo.escript_packages && matrix.combo.escript_script}} + + environment_variables: + name: Environment variables + runs-on: ${{matrix.combo.os}} + strategy: + fail-fast: false + matrix: + combo: + - otp-version: '24' + elixir-version: 'v1.12' + gleam-version: '0.23.0-rc1' + rebar3-version: 'nightly' + os: 'windows-latest' + steps: + - uses: actions/checkout@v4 + - name: Use erlef/setup-beam + id: setup-beam + uses: ./ + with: + otp-version: ${{matrix.combo.otp-version}} + elixir-version: ${{matrix.combo.elixir-version}} + gleam-version: ${{matrix.combo.gleam-version}} + rebar3-version: ${{matrix.combo.rebar3-version}} + - run: env + - name: Check environment variables + run: | + & "$Env:INSTALL_DIR_FOR_ELIXIR/bin/elixir" "-v" + & "$Env:INSTALL_DIR_FOR_GLEAM/bin/gleam.exe" "--version" + & "$Env:INSTALL_DIR_FOR_OTP/bin/erl.exe" "+V" + & "$Env:INSTALL_DIR_FOR_REBAR3/bin/rebar3.cmd" "version" + & "$Env:INSTALL_DIR_FOR_REBAR3/bin/rebar3.ps1" "version" From 9fa88a6c6501d527017392e9c9c732d13a01832b Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 24 May 2024 16:51:30 -0700 Subject: [PATCH 05/16] create dist --- dist/index.js | 6 ++++-- src/setup-beam.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 11d715ea..4c13ad2b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10318,7 +10318,7 @@ function getRunnerOSVersion() { win19: 'windows-2019', win22: 'windows-2022', } - const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] + let containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] if (!containerFromEnvImageOS) { throw new Error( "Tried to map a target OS from env. variable 'ImageOS' (got " + @@ -10330,7 +10330,9 @@ function getRunnerOSVersion() { "']", ) } - + if (['ARM', 'ARM64'].includes(process.env.RUNNER_ARCH)) { + containerFromEnvImageOS = `arm64/${containerFromEnvImageOS}` + } return containerFromEnvImageOS } diff --git a/src/setup-beam.js b/src/setup-beam.js index 21c3b9a1..1b424694 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -487,7 +487,7 @@ function getRunnerOSVersion() { win19: 'windows-2019', win22: 'windows-2022', } - const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] + let containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] if (!containerFromEnvImageOS) { throw new Error( "Tried to map a target OS from env. variable 'ImageOS' (got " + From 948ed88aebe626e345072c9b9bac96c3f01e3ee6 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Thu, 30 May 2024 17:35:38 -0700 Subject: [PATCH 06/16] tests --- src/setup-beam.js | 35 ++++++-- test/setup-beam.test.js | 190 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 220 insertions(+), 5 deletions(-) diff --git a/src/setup-beam.js b/src/setup-beam.js index 1b424694..6723f56d 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -254,7 +254,12 @@ async function getOTPVersions(osVersion) { let otpVersionsListings let originListing if (process.platform === 'linux') { - originListing = `/builds/otp/${osVersion}/builds.txt` + let osArchitecture = getRunnerOSArchitecture() + if (osArchitecture.length > 0) { + osArchitecture = `${osArchitecture}/` + } + + originListing = `/builds/otp/${osArchitecture}${osVersion}/builds.txt` otpVersionsListings = await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `fetch ${originListing}`, @@ -478,6 +483,28 @@ function isKnownBranch(ver) { return ['main', 'master', 'maint'].includes(ver) } +function githubARMRunnerArchs() { + return ['ARM', 'ARM64'] +} + +function githubAMDRunnerArchs() { + return ['X86', 'X64'] +} + +function getRunnerOSArchitecture() { + // These options come from: + // https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + if (githubARMRunnerArchs().includes(process.env.RUNNER_ARCH)) { + return 'arm64' + } + + if (githubAMDRunnerArchs().includes(process.env.RUNNER_ARCH)) { + return 'amd64' + } + + return '' +} + function getRunnerOSVersion() { const ImageOSToContainer = { ubuntu18: 'ubuntu-18.04', @@ -487,7 +514,7 @@ function getRunnerOSVersion() { win19: 'windows-2019', win22: 'windows-2022', } - let containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] + const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] if (!containerFromEnvImageOS) { throw new Error( "Tried to map a target OS from env. variable 'ImageOS' (got " + @@ -499,9 +526,7 @@ function getRunnerOSVersion() { "']", ) } - if (['ARM', 'ARM64'].includes(process.env.RUNNER_ARCH)) { - containerFromEnvImageOS = `arm64/${containerFromEnvImageOS}` - } + return containerFromEnvImageOS } diff --git a/test/setup-beam.test.js b/test/setup-beam.test.js index 131042fb..da3709ed 100644 --- a/test/setup-beam.test.js +++ b/test/setup-beam.test.js @@ -21,6 +21,8 @@ async function all() { await testFailInstallRebar3() await testOTPVersions() + await testLinuxARM64OTPVersions() + await testLinuxAMD64OTPVersions() await testElixirVersions() await testGleamVersions() await testRebar3Versions() @@ -235,6 +237,194 @@ async function testOTPVersions() { simulateInput('hexpm-mirrors', hexMirrors, { multiline: true }) } +async function testLinuxARM64OTPVersions() { + let got + let expected + let spec + let osVersion + let before + const hexMirrors = simulateInput( + 'hexpm-mirrors', + 'https://repo.hex.pm, https://cdn.jsdelivr.net/hex', + { multiline: true }, + ) + + const arm64Options = setupBeam.githubARMRunnerArchs() + process.env.RUNNER_ARCH = + arm64Options[Math.floor(Math.random() * arm64Options.length)] + + if (process.platform === 'linux') { + before = simulateInput('version-type', 'strict') + spec = '26' + osVersion = 'ubuntu-24.04' + expected = 'maint-26' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + simulateInput('version-type', before) + spec = '27.0' + osVersion = 'ubuntu-24.04' + expected = 'OTP-27.0' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + simulateInput('version-type', before) + spec = '25.3.2.1' + osVersion = 'ubuntu-20.04' + expected = 'OTP-25.3.2.1' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + simulateInput('version-type', before) + + spec = '20' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '20.3.8.26' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + spec = '20.x' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '20.0' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.0.5' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '20.0.x' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.0.5' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = 'maint' + osVersion = 'ubuntu-22.04' + expected = 'maint' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + spec = 'master' + osVersion = 'ubuntu-22.04' + expected = 'master' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + } + + simulateInput('hexpm-mirrors', hexMirrors, { multiline: true }) +} + +async function testLinuxAMD64OTPVersions() { + let got + let expected + let spec + let osVersion + let before + const hexMirrors = simulateInput( + 'hexpm-mirrors', + 'https://repo.hex.pm, https://cdn.jsdelivr.net/hex', + { multiline: true }, + ) + + const amd64Options = setupBeam.githubAMDRunnerArchs() + process.env.RUNNER_ARCH = + amd64Options[Math.floor(Math.random() * amd64Options.length)] + + if (process.platform === 'linux') { + before = simulateInput('version-type', 'strict') + spec = '26' + osVersion = 'ubuntu-24.04' + expected = 'maint-26' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + simulateInput('version-type', before) + spec = '27.0' + osVersion = 'ubuntu-24.04' + expected = 'OTP-27.0' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + simulateInput('version-type', before) + spec = '25.3.2.1' + osVersion = 'ubuntu-20.04' + expected = 'OTP-25.3.2.1' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + simulateInput('version-type', before) + spec = '19.3.x' + osVersion = 'ubuntu-16.04' + expected = 'OTP-19.3.6.13' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '^19.3.6' + osVersion = 'ubuntu-16.04' + expected = 'OTP-19.3.6.13' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '^19.3' + osVersion = 'ubuntu-18.04' + expected = 'OTP-19.3.6.13' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '20' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '20.3.8.26' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + spec = '20.x' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.3.8.26' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '20.0' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.0.5' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = '20.0.x' + osVersion = 'ubuntu-20.04' + expected = 'OTP-20.0.5' + got = await setupBeam.getOTPVersion(spec, osVersion) + assert.deepStrictEqual(got, expected) + + spec = 'maint' + osVersion = 'ubuntu-22.04' + expected = 'maint' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + + spec = 'master' + osVersion = 'ubuntu-22.04' + expected = 'master' + got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + assert.deepStrictEqual(got, expected) + } + + simulateInput('hexpm-mirrors', hexMirrors, { multiline: true }) +} + async function testElixirVersions() { let got let expected From bd6b479ccbd434e00e7d389bd376fb87412ae9b3 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Thu, 30 May 2024 17:37:51 -0700 Subject: [PATCH 07/16] build dist --- dist/index.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 2eb5397d..0d440de0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10085,7 +10085,12 @@ async function getOTPVersions(osVersion) { let otpVersionsListings let originListing if (process.platform === 'linux') { - originListing = `/builds/otp/${osVersion}/builds.txt` + let osArchitecture = getRunnerOSArchitecture() + if (osArchitecture.length > 0) { + osArchitecture = `${osArchitecture}/` + } + + originListing = `/builds/otp/${osArchitecture}${osVersion}/builds.txt` otpVersionsListings = await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `fetch ${originListing}`, @@ -10309,6 +10314,28 @@ function isKnownBranch(ver) { return ['main', 'master', 'maint'].includes(ver) } +function githubARMRunnerArchs() { + return ['ARM', 'ARM64'] +} + +function githubAMDRunnerArchs() { + return ['X86', 'X64'] +} + +function getRunnerOSArchitecture() { + // These options come from: + // https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + if (githubARMRunnerArchs().includes(process.env.RUNNER_ARCH)) { + return 'arm64' + } + + if (githubAMDRunnerArchs().includes(process.env.RUNNER_ARCH)) { + return 'amd64' + } + + return '' +} + function getRunnerOSVersion() { const ImageOSToContainer = { ubuntu18: 'ubuntu-18.04', @@ -10318,7 +10345,7 @@ function getRunnerOSVersion() { win19: 'windows-2019', win22: 'windows-2022', } - let containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] + const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] if (!containerFromEnvImageOS) { throw new Error( "Tried to map a target OS from env. variable 'ImageOS' (got " + @@ -10330,9 +10357,7 @@ function getRunnerOSVersion() { "']", ) } - if (['ARM', 'ARM64'].includes(process.env.RUNNER_ARCH)) { - containerFromEnvImageOS = `arm64/${containerFromEnvImageOS}` - } + return containerFromEnvImageOS } From b06ef4be9147b0d0a7db600f05004b2ccf1d3b28 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Thu, 30 May 2024 17:41:41 -0700 Subject: [PATCH 08/16] revert action name --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 807ead4a..419d55af 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ --- -name: Setup Erlang/OTP with optional Elixir (and mix) and/or rebar3 arm64 +name: Setup Erlang/OTP with optional Elixir (and mix) and/or rebar3 description: > Set up a specific version of Erlang/OTP, Elixir, and/or rebar3 and add the command-line tools to the PATH From f693b2bd03c8536989b92e4547f869cb790ea6e0 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 31 May 2024 01:45:59 -0700 Subject: [PATCH 09/16] exports --- src/setup-beam.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/setup-beam.js b/src/setup-beam.js index 781bd8f5..1b1ec208 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -1033,6 +1033,8 @@ module.exports = { getGleamVersion, getRebar3Version, getVersionFromSpec, + githubAMDRunnerArchs, + githubARMRunnerArchs, install, parseVersionFile, } From 94357834af78b78ed6a81f102b246ae398437ed3 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 31 May 2024 03:05:26 -0700 Subject: [PATCH 10/16] update dist --- dist/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/index.js b/dist/index.js index 0d440de0..1eb298c6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10864,6 +10864,8 @@ module.exports = { getGleamVersion, getRebar3Version, getVersionFromSpec, + githubAMDRunnerArchs, + githubARMRunnerArchs, install, parseVersionFile, } From 63cc82ced86e5bfbf1a31f9efd93042186754fd5 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 31 May 2024 22:16:42 -0700 Subject: [PATCH 11/16] throw error on invalid github runner architecture --- dist/index.js | 6 +++++- src/setup-beam.js | 6 +++++- test/setup-beam.test.js | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 100e6375..7a2e574a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10333,7 +10333,11 @@ function getRunnerOSArchitecture() { return 'amd64' } - return '' + throw new Error( + 'Invalid Github runner architecture, expected one of ' + + `${githubAMDRunnerArchs().concat(githubARMRunnerArchs()).join(', ')} ` + + `but got process.env.RUNNER_ARCH = ${process.env.RUNNER_ARCH}`, + ) } function getRunnerOSVersion() { diff --git a/src/setup-beam.js b/src/setup-beam.js index 72b9724b..3715dc40 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -502,7 +502,11 @@ function getRunnerOSArchitecture() { return 'amd64' } - return '' + throw new Error( + 'Invalid Github runner architecture, expected one of ' + + `${githubAMDRunnerArchs().concat(githubARMRunnerArchs()).join(', ')} ` + + `but got process.env.RUNNER_ARCH = ${process.env.RUNNER_ARCH}`, + ) } function getRunnerOSVersion() { diff --git a/test/setup-beam.test.js b/test/setup-beam.test.js index da3709ed..a49113e4 100644 --- a/test/setup-beam.test.js +++ b/test/setup-beam.test.js @@ -19,6 +19,7 @@ async function all() { await testFailInstallElixir() await testFailInstallGleam() await testFailInstallRebar3() + await testFailGetOTPVersion() await testOTPVersions() await testLinuxARM64OTPVersions() @@ -425,6 +426,32 @@ async function testLinuxAMD64OTPVersions() { simulateInput('hexpm-mirrors', hexMirrors, { multiline: true }) } +async function testFailGetOTPVersion() { + const hexMirrors = simulateInput( + 'hexpm-mirrors', + 'https://repo.hex.pm, https://cdn.jsdelivr.net/hex', + { multiline: true }, + ) + + process.env.RUNNER_ARCH = 'invalid' + + if (process.platform === 'linux') { + const spec = '26' + const osVersion = 'ubuntu-24.04' + + assert.rejects( + async () => { + await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) + }, + (err) => { + assert.ok(err instanceof Error) + return true + }, + `Fetching OTP Version with invalid Github runner architecture is supposed to fail`, + ) + } +} + async function testElixirVersions() { let got let expected From 2e6a2ac0761b420d29e04937225a2f463f2e5351 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Fri, 31 May 2024 22:20:50 -0700 Subject: [PATCH 12/16] use architecture for build listings --- dist/index.js | 6 +----- src/setup-beam.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7a2e574a..0232b701 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10086,11 +10086,7 @@ async function getOTPVersions(osVersion) { let originListing if (process.platform === 'linux') { let osArchitecture = getRunnerOSArchitecture() - if (osArchitecture.length > 0) { - osArchitecture = `${osArchitecture}/` - } - - originListing = `/builds/otp/${osArchitecture}${osVersion}/builds.txt` + originListing = `/builds/otp/${osArchitecture}/${osVersion}/builds.txt` otpVersionsListings = await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `fetch ${originListing}`, diff --git a/src/setup-beam.js b/src/setup-beam.js index 3715dc40..fbe8f71b 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -255,11 +255,7 @@ async function getOTPVersions(osVersion) { let originListing if (process.platform === 'linux') { let osArchitecture = getRunnerOSArchitecture() - if (osArchitecture.length > 0) { - osArchitecture = `${osArchitecture}/` - } - - originListing = `/builds/otp/${osArchitecture}${osVersion}/builds.txt` + originListing = `/builds/otp/${osArchitecture}/${osVersion}/builds.txt` otpVersionsListings = await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `fetch ${originListing}`, From 7b5c056379dc19dbb7bf4e474892b2f00e7408f9 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Sat, 15 Jun 2024 21:24:00 -0700 Subject: [PATCH 13/16] restore RUNNER_ARCH env --- test/setup-beam.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/setup-beam.test.js b/test/setup-beam.test.js index 77448a5b..73aebf87 100644 --- a/test/setup-beam.test.js +++ b/test/setup-beam.test.js @@ -475,6 +475,7 @@ async function testFailGetOTPVersion() { { multiline: true }, ) + const previousRunnerArch = process.env.RUNNER_ARCH process.env.RUNNER_ARCH = 'invalid' if (process.platform === 'linux') { @@ -492,6 +493,7 @@ async function testFailGetOTPVersion() { `Fetching OTP Version with invalid Github runner architecture is supposed to fail`, ) } + process.env.RUNNER_ARCH = previousRunnerArch } async function testElixirVersions() { From 09e2f7279deddce410715ad843798f5be64d36f5 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Sat, 15 Jun 2024 21:29:27 -0700 Subject: [PATCH 14/16] update test that now depends on RUNNER_ARCH --- test/setup-beam.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/setup-beam.test.js b/test/setup-beam.test.js index 73aebf87..56553a0c 100644 --- a/test/setup-beam.test.js +++ b/test/setup-beam.test.js @@ -174,6 +174,9 @@ async function testOTPVersions() { ) if (process.platform === 'linux') { + const previousRunnerArch = process.env.RUNNER_ARCH + process.env.RUNNER_ARCH = 'X64' + before = simulateInput('version-type', 'strict') spec = '26' osVersion = 'ubuntu-24.04' @@ -255,6 +258,8 @@ async function testOTPVersions() { expected = 'master' got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors) assert.deepStrictEqual(got, expected) + + process.env.RUNNER_ARCH = previousRunnerArch } if (process.platform === 'win32') { From 04128ab0241f35f3bc3d49fa46a0292a860287a1 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Sat, 15 Jun 2024 21:36:43 -0700 Subject: [PATCH 15/16] split arch info --- src/setup-beam.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/setup-beam.js b/src/setup-beam.js index f53d742e..81d0c345 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -55,7 +55,9 @@ async function main() { async function installOTP(otpSpec, osVersion) { const otpVersion = await getOTPVersion(otpSpec, osVersion) - core.startGroup(`Installing Erlang/OTP ${otpVersion} - built on ${osVersion}`) + core.startGroup( + `Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`, + ) await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `install Erlang/OTP ${otpVersion}`, @@ -254,8 +256,7 @@ async function getOTPVersions(osVersion) { let otpVersionsListings let originListing if (process.platform === 'linux') { - let osArchitecture = getRunnerOSArchitecture() - originListing = `/builds/otp/${osArchitecture}/${osVersion}/builds.txt` + originListing = `/builds/otp/${getRunnerOSArchitecture()}/${osVersion}/builds.txt` otpVersionsListings = await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `fetch ${originListing}`, @@ -770,7 +771,7 @@ async function install(toolName, opts) { tool: 'Erlang/OTP', linux: { downloadToolURL: () => - `${hexMirror}/builds/otp/${versionSpec}.tar.gz`, + `${hexMirror}/builds/otp/${getRunnerOSArchitecture()}/${versionSpec}.tar.gz`, extract: async (file) => { const dest = undefined const flags = ['zx', '--strip-components=1'] From 5f84fbe4ec2118194d652a6df516c71374d4c015 Mon Sep 17 00:00:00 2001 From: Favio Manriquez Date: Sat, 15 Jun 2024 21:40:46 -0700 Subject: [PATCH 16/16] update dist too! --- dist/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index e743c76c..783ce975 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9160,7 +9160,9 @@ async function main() { async function installOTP(otpSpec, osVersion) { const otpVersion = await getOTPVersion(otpSpec, osVersion) - core.startGroup(`Installing Erlang/OTP ${otpVersion} - built on ${osVersion}`) + core.startGroup( + `Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`, + ) await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `install Erlang/OTP ${otpVersion}`, @@ -9354,8 +9356,7 @@ async function getOTPVersions(osVersion) { let otpVersionsListings let originListing if (process.platform === 'linux') { - let osArchitecture = getRunnerOSArchitecture() - originListing = `/builds/otp/${osArchitecture}/${osVersion}/builds.txt` + originListing = `/builds/otp/${getRunnerOSArchitecture()}/${osVersion}/builds.txt` otpVersionsListings = await doWithMirrors({ hexMirrors: hexMirrorsInput(), actionTitle: `fetch ${originListing}`, @@ -9870,7 +9871,7 @@ async function install(toolName, opts) { tool: 'Erlang/OTP', linux: { downloadToolURL: () => - `${hexMirror}/builds/otp/${versionSpec}.tar.gz`, + `${hexMirror}/builds/otp/${getRunnerOSArchitecture()}/${versionSpec}.tar.gz`, extract: async (file) => { const dest = undefined const flags = ['zx', '--strip-components=1']