Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .github/workflows/e2e_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ name: vfox E2E tests
on:
push:
branches: [main]
paths: ['lib']
paths:
- '.github/workflows/e2e_test.yaml'
- 'metadata.lua'
- 'hooks/**'
- 'lib/**'
pull_request:
paths: ['lib']
paths:
- '.github/workflows/e2e_test.yaml'
- 'metadata.lua'
- 'hooks/**'
- 'lib/**'
workflow_dispatch:
schedule:
# Runs at 12am UTC
Expand All @@ -14,10 +22,13 @@ on:
jobs:
e2e_tests:
strategy:
fail-fast: false
matrix:
# ref: https://github.com/actions/runner-images
os: [ubuntu-22.04, macos-latest, windows-2022]
runs-on: ${{ matrix.os }}
env:
ELIXIR_PLUGIN_REF: ${{ github.event.pull_request.head.sha || github.sha }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -47,13 +58,13 @@ jobs:
if: runner.os != 'Windows'
run: |
vfox add --source https://github.com/version-fox/vfox-erlang/archive/refs/heads/main.zip erlang
vfox add --source https://github.com/version-fox/vfox-elixir/archive/${GITHUB_REF}.zip elixir
vfox add --source https://github.com/version-fox/vfox-elixir/archive/${ELIXIR_PLUGIN_REF}.zip elixir

- name: add vfox-erlang & vfox-elixir plugin
if: runner.os == 'Windows'
run: |
vfox add --source https://github.com/version-fox/vfox-erlang/archive/refs/heads/main.zip erlang
vfox add --source https://github.com/version-fox/vfox-elixir/archive/$env:GITHUB_REF.zip elixir
vfox add --source https://github.com/version-fox/vfox-elixir/archive/$env:ELIXIR_PLUGIN_REF.zip elixir

- name: install Erlang/OTP & Elixir by vfox-erlang & vfox-elixir plugin (Linux)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -94,7 +105,7 @@ jobs:
elixir hello.ex

- name: install Erlang/OTP & Elixir by vfox-erlang & vfox-elixir plugin (Darwin)
if: runner.os == 'MacOS'
if: runner.os == 'macOS'
run: |
brew install autoconf libxslt fop wxwidgets openssl
export MAKEFLAGS=-j4
Expand Down Expand Up @@ -138,4 +149,4 @@ jobs:
} else {
Write-Output "elixir installed failed!"
exit 1
}
}
51 changes: 30 additions & 21 deletions .github/workflows/mise_e2e_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ name: mise E2E tests
on:
push:
branches: [main]
paths: ['lib']
paths:
- '.github/workflows/mise_e2e_test.yaml'
- 'metadata.lua'
- 'hooks/**'
- 'lib/**'
pull_request:
paths: ['lib']
paths:
- '.github/workflows/mise_e2e_test.yaml'
- 'metadata.lua'
- 'hooks/**'
- 'lib/**'
workflow_dispatch:
schedule:
# Runs at 12am UTC
Expand All @@ -14,6 +22,7 @@ on:
jobs:
mise_e2e_tests:
strategy:
fail-fast: false
matrix:
# ref: https://github.com/actions/runner-images
os: [ubuntu-22.04, macos-latest]
Expand All @@ -34,6 +43,12 @@ jobs:
export PATH="$HOME/.local/bin:$PATH"
mise --version

- name: Link local Elixir plugin for PR validation
if: runner.os != 'Windows'
run: |
export PATH="$HOME/.local/bin:$PATH"
mise plugins link vfox-elixir-ci "$GITHUB_WORKSPACE"

- name: Install Erlang/OTP & Elixir via mise (Linux)
if: runner.os == 'Linux'
run: |
Expand All @@ -42,18 +57,15 @@ jobs:
export MAKEFLAGS=-j4
export PATH="$HOME/.local/bin:$PATH"

# Install via mise
mise install vfox:version-fox/vfox-erlang@26.2.3
mise use -g vfox:version-fox/vfox-erlang@26.2.3
eval "$(mise activate bash --shims)"
eval "$(mise env)"
which erl
echo "===============PATH==============="
echo $PATH
echo "===============PATH==============="

mise install vfox:version-fox/vfox-elixir@1.16.2
mise use -g vfox:version-fox/vfox-elixir@1.16.2
eval "$(mise activate bash --shims)"
which erlc

mise install vfox-elixir-ci@1.16.2
mise use -g vfox-elixir-ci@1.16.2
eval "$(mise env)"
elixirc -v
cd assets
elixir hello.ex
Expand All @@ -66,18 +78,15 @@ jobs:
export MAKEFLAGS=-j4
export PATH="$HOME/.local/bin:$PATH"

# Install via mise
mise install vfox:version-fox/vfox-erlang@26.2.3
mise use -g vfox:version-fox/vfox-erlang@26.2.3
eval "$(mise activate bash)"
eval "$(mise env)"
which erl
echo "===============PATH==============="
echo $PATH
echo "===============PATH==============="

mise install vfox:version-fox/vfox-elixir@1.16.2
mise use -g vfox:version-fox/vfox-elixir@1.16.2
eval "$(mise activate bash)"
which erlc

mise install vfox-elixir-ci@1.16.2
mise use -g vfox-elixir-ci@1.16.2
eval "$(mise env)"
elixirc -v
cd assets
elixir hello.ex
elixir hello.ex
9 changes: 7 additions & 2 deletions hooks/post_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ function PLUGIN:PostInstall(ctx)
elseif os.getenv("VFOX_ELIXIR_MIRROR") == "hex" then
return
else
install_cmd = "cd " .. path .. " && make"
local erlang_bin = elixirUtils.find_erlang_bin()
if erlang_bin then
install_cmd = "cd " .. path .. " && PATH=" .. erlang_bin .. ":$PATH make"
else
install_cmd = "cd " .. path .. " && make"
end
local status = os.execute(install_cmd)
if status ~= 0 then
error("Elixir install failed, please check the stdout for details.")
end
end
end
end
28 changes: 24 additions & 4 deletions lib/elixir_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,32 @@ function elixir_utils.check_version_existence(url)
end
end

function elixir_utils.find_erlang_bin()
local handle = io.popen("which erlc 2>/dev/null")
local result = handle:read("*l")
handle:close()
if result and result ~= "" then
return result:match("(.+)/")
end

local home = os.getenv("HOME") or ""
local mise_dir = os.getenv("MISE_DATA_DIR") or (home .. "/.local/share/mise")
handle = io.popen("find '" .. mise_dir .. "/installs' -name erlc -type f 2>/dev/null | head -1")
result = handle:read("*l")
handle:close()
if result and result ~= "" then
return result:match("(.+)/")
end

return nil
end

function elixir_utils.check_erlang_existence()
print("Check Erlang/OTP existence...")
local status = os.execute("which erlc")
if status ~= 0 then
error("Please install Erlang/OTP before you install Elixir.")
if elixir_utils.find_erlang_bin() then
return
end
error("Please install Erlang/OTP before you install Elixir.")
end

function elixir_utils.get_elixir_release_verions_in_linux()
Expand Down Expand Up @@ -137,4 +157,4 @@ function elixir_utils.get_hex_prebuild_url(version)
return string.format("https://builds.hex.pm/builds/elixir/%s.zip", url_version)
end

return elixir_utils
return elixir_utils
3 changes: 3 additions & 0 deletions metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ PLUGIN.license = "Apache 2.0"
--- Plugin description
PLUGIN.description = "Elixir vfox plugin, support for managing multiple Elixir language versions in Windows & Uinx-like system."

--- Erlang/OTP must be on PATH when compiling Elixir from source.
PLUGIN.depends = { "erlang" }


--- !!! OPTIONAL !!!
--[[
Expand Down
Loading