Skip to content

Commit 1c72875

Browse files
Copilotyeshan333
andcommitted
Add MacOS prebuilt support using @erlef/otp_builds
Co-authored-by: yeshan333 <39296814+yeshan333@users.noreply.github.com>
1 parent 840cbfd commit 1c72875

4 files changed

Lines changed: 92 additions & 8 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: E2E tests on Darwin MacOS (Prebuilt release)
2+
3+
on:
4+
push:
5+
# branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
schedule:
9+
# Runs at 12am UTC
10+
- cron: '0 0 * * *'
11+
12+
jobs:
13+
e2e_tests:
14+
strategy:
15+
matrix:
16+
# ref: https://github.com/actions/runner-images
17+
os: [macos-13]
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-go@v5
23+
with:
24+
go-version: '^1.24.2' # The Go version to download (if necessary) and use.
25+
26+
- name: build vfox (MacOS)
27+
run: |
28+
git clone https://github.com/version-fox/vfox.git
29+
cd vfox
30+
go build -o vfox
31+
chmod +x vfox
32+
cp vfox /usr/local/bin
33+
34+
- name: add vfox-erlang plugin (Unix-like)
35+
run: |
36+
vfox -version
37+
vfox add --source https://github.com/version-fox/vfox-erlang/archive/${GITHUB_REF}.zip erlang
38+
39+
- name: install Erlang/OTP by vfox-erlang plugin (Darwin prebuilt)
40+
run: |
41+
export USE_PREBUILT_OTP="macos-13"
42+
vfox install erlang@26.2.3
43+
vfox use -g erlang@26.2.3
44+
eval "$(vfox activate bash)"
45+
echo "===============PATH==============="
46+
echo $PATH
47+
echo "===============PATH==============="
48+
cd assets
49+
erlc hello.erl
50+
erl -noshell -s hello hello_world -s init stop

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,30 @@ You can reference the E2E test in in windows-2022: [.github/workflows/e2e_test_w
8585

8686
## install a prebuilt Erlang/OTP version
8787

88-
After vfox-erlang v1.1.0, you can also install a prebuilt Erlang/OTP version in Ubuntu linux system.
88+
After vfox-erlang v1.1.0, you can also install a prebuilt Erlang/OTP version in Ubuntu linux system and MacOS.
8989

9090
**Before install, you must disable vfox search cache.** Reference: [https://vfox.lhan.me/guides/configuration.html#cache-settings](https://vfox.lhan.me/guides/configuration.html#cache-settings)
9191

92+
### Linux (Ubuntu)
93+
9294
This is an installation example in Bash Shell:
9395

9496
```shell
9597
# install an available version, you can also a avaliable version in: https://bobs-list.kobrakai.de/
9698
USE_PREBUILT_OTP="ubuntu-20.04" vfox search erlang
99+
USE_PREBUILT_OTP="ubuntu-20.04" vfox install erlang@26.2.3
100+
```
101+
102+
**USE_PREBUILT_OTP** var value for Linux is one of: ["ubuntu-14.04", "ubuntu-16.04", "ubuntu-18.04", "ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04"].
103+
104+
### MacOS
105+
106+
For MacOS, you can use prebuilt Erlang/OTP versions from [@erlef/otp_builds](https://github.com/erlef/otp_builds):
107+
108+
```shell
109+
# install a prebuilt version for MacOS
110+
USE_PREBUILT_OTP="macos-13" vfox search erlang
111+
USE_PREBUILT_OTP="macos-13" vfox install erlang@26.2.3
97112
```
98113

99-
**USE_PREBUILT_OTP** var value is one of: ["ubuntu-14.04", "ubuntu-16.04", "ubuntu-18.04", "ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04"].
114+
**USE_PREBUILT_OTP** var value for MacOS is one of: ["macos-11", "macos-12", "macos-13", "macos-14"].

hooks/post_install.lua

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,23 @@ function PLUGIN:PostInstall(ctx)
2828
elseif PRE_BUILT_OS_RELEASE then
2929
print("Erlang/OTP install from prebuilt release: " .. PRE_BUILT_OS_RELEASE)
3030
local install_path = ctx.sdkInfo.erlang.path
31-
local install_cmd = "cd " .. install_path .. " && ./Install -cross -sasl"
32-
33-
local status = os.execute(install_cmd)
34-
if status ~= 0 then
35-
error(
36-
"Erlang/OTP install failed, please check the stdout for details. Make sure you have the required utilties: https://www.erlang.org/doc/installation_guide/install#required-utilities")
31+
32+
if RUNTIME.osType == "darwin" then
33+
-- For MacOS prebuilts from @erlef/otp_builds, the tarball contains a ready-to-use installation
34+
-- We need to move the contents to a 'release' subdirectory to match expected structure
35+
local move_cmd = "cd " .. install_path .. " && mkdir -p release && mv * release/ 2>/dev/null || true"
36+
local status = os.execute(move_cmd)
37+
if status ~= 0 then
38+
error("Erlang/OTP install failed during file organization, please check the stdout for details.")
39+
end
40+
else
41+
-- Linux installation using the Install script
42+
local install_cmd = "cd " .. install_path .. " && ./Install -cross -sasl"
43+
local status = os.execute(install_cmd)
44+
if status ~= 0 then
45+
error(
46+
"Erlang/OTP install failed, please check the stdout for details. Make sure you have the required utilties: https://www.erlang.org/doc/installation_guide/install#required-utilities")
47+
end
3748
end
3849
else
3950
-- use ENV OTP_COMPILE_ARGS to control compile behavior

hooks/pre_install.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ function PLUGIN:PreInstall(ctx)
3030
"Make sure the USE_PREBUILT environment variable is set to one of the following values: ubuntu-20.04, ubuntu-22.04, ubuntu-24.04")
3131
end
3232
download_url = "https://builds.hex.pm/builds/otp/" .. RUNTIME.archType .. "/" .. PRE_BUILT_OS_RELEASE .. "/" .. erlang_version .. ".tar.gz"
33+
elseif RUNTIME.osType == "darwin" and PRE_BUILT_OS_RELEASE then
34+
local SUPPORT_MACOS_RELEASE = { "macos-11", "macos-12", "macos-13", "macos-14" }
35+
if not erlangUtils.array_contains(SUPPORT_MACOS_RELEASE, PRE_BUILT_OS_RELEASE) then
36+
error(
37+
"Make sure the USE_PREBUILT_OTP environment variable is set to one of the following values for MacOS: macos-11, macos-12, macos-13, macos-14")
38+
end
39+
-- Use @erlef/otp_builds for MacOS prebuilt binaries
40+
download_url = "https://github.com/erlef/otp_builds/releases/download/OTP-" .. erlang_version .. "/otp_" .. PRE_BUILT_OS_RELEASE .. "_" .. RUNTIME.archType .. ".tar.gz"
3341
else
3442
download_url = "https://github.com/erlang/otp/archive/refs/tags/OTP-" .. erlang_version .. ".tar.gz"
3543
end

0 commit comments

Comments
 (0)