Skip to content

Commit

Permalink
Merge pull request #1 from codeadict/master
Browse files Browse the repository at this point in the history
Make distillery compatible with OTP 26
  • Loading branch information
codeadict authored Apr 1, 2024
2 parents 3ab4d61 + 37c336f commit b3ba48a
Show file tree
Hide file tree
Showing 33 changed files with 158 additions and 120 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches:
- master
- main
pull_request:
branches:
- main

env:
LANG: C.UTF-8
TERM: xterm-256color
MIX_ENV: test
VERBOSE_TESTS: true

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
elixir: [1.16.1]
otp_release: [26.1.2]

steps:
- uses: actions/checkout@v4
- name: Set up OTP and Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp_release }}
- name: Install dependencies
run: |
epmd -daemon
mix deps.get
- name: Run tests
continue-on-error: true
run: mix test --exclude=integration
- name: Run integration tests
run: mix test --only=win32:false
2 changes: 1 addition & 1 deletion lib/distillery/releases/archiver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ defmodule Distillery.Releases.Archiver do
end
catch
kind, err ->
{:error, {:archiver, Exception.normalize(kind, err, System.stacktrace())}}
{:error, {:archiver, Exception.normalize(kind, err, __STACKTRACE__)}}
end

defp make_archive(%Release{version: version} = release, tmpdir) do
Expand Down
16 changes: 13 additions & 3 deletions lib/distillery/releases/assembler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule Distillery.Releases.Assembler do
struct. It creates the release directory, copies applications, and generates release-specific
files required by `:systools` and `:release_handler`.
"""
alias Config.Reader
alias Distillery.Releases.Config
alias Distillery.Releases.Release
alias Distillery.Releases.Environment
Expand Down Expand Up @@ -220,7 +221,7 @@ defmodule Distillery.Releases.Assembler do
end
rescue
e in [File.Error] ->
{:error, {:assembler, {e, System.stacktrace()}}}
{:error, {:assembler, {e, __STACKTRACE__}}}
catch
:error, {:assembler, _mod, _reason} = err ->
{:error, err}
Expand Down Expand Up @@ -655,7 +656,7 @@ defmodule Distillery.Releases.Assembler do
{:ok, tokens, _} <- :erl_scan.string(String.to_charlist(templated)),
{:ok, sys_config} <- :erl_parse.parse_term(tokens),
:ok <- validate_sys_config(sys_config),
merged <- Mix.Config.merge(base_config, sys_config) do
merged <- Reader.merge(base_config, sys_config) do
merged
else
err ->
Expand Down Expand Up @@ -860,7 +861,15 @@ defmodule Distillery.Releases.Assembler do
# no work around for this
old_cwd = File.cwd!()
File.cd!(output_dir)
:ok = :release_handler.create_RELEASES('./', 'releases', '#{relfile}', [])

:ok =
:release_handler.create_RELEASES(
File.cwd!(),
Path.join([File.cwd!(), 'releases']),
'#{relfile}',
[]
)

File.cd!(old_cwd)
:ok
end
Expand Down Expand Up @@ -992,6 +1001,7 @@ defmodule Distillery.Releases.Assembler do
" this setting will prevent you from doing so without a rolling restart.\n" <>
" You may ignore this warning if you have no plans to use hot upgrades."
)

Shell.debug("Stripping release (#{path})")

case :beam_lib.strip_release(String.to_charlist(path)) do
Expand Down
8 changes: 4 additions & 4 deletions lib/distillery/releases/config/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ defmodule Distillery.Releases.Config do
config
rescue
e in [LoadError] ->
reraise(e, System.stacktrace())
reraise(e, __STACKTRACE__)

e ->
reraise(LoadError, [file: "nofile", error: e], System.stacktrace())
reraise(LoadError, [file: "nofile", error: e], __STACKTRACE__)
end

@doc """
Expand All @@ -381,10 +381,10 @@ defmodule Distillery.Releases.Config do
read_string!(File.read!(file))
rescue
e in [LoadError] ->
reraise(LoadError, [file: file, error: e.error], System.stacktrace())
reraise(LoadError, [file: file, error: e.error], __STACKTRACE__)

e ->
reraise(LoadError, [file: file, error: e], System.stacktrace())
reraise(LoadError, [file: file, error: e], __STACKTRACE__)
end

@doc """
Expand Down
4 changes: 2 additions & 2 deletions lib/distillery/releases/config/provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ defmodule Distillery.Releases.Config.Provider do
end
rescue
err ->
trace = System.stacktrace()
trace = __STACKTRACE__
msg = Exception.message(err) <> "\n" <> Exception.format_stacktrace(trace)
print_err(msg)
reraise err, trace
catch
kind, err ->
print_err(Exception.format(kind, err, System.stacktrace()))
print_err(Exception.format(kind, err, __STACKTRACE__))

case kind do
:throw ->
Expand Down
10 changes: 5 additions & 5 deletions lib/distillery/releases/plugins/plugin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ defmodule Distillery.Releases.Plugin do
call(plugins, callback, release)
catch
:throw, {:error, {:plugin, {kind, err}}} ->
{:error, {:plugin, {kind, err, System.stacktrace()}}}
{:error, {:plugin, {kind, err, __STACKTRACE__}}}
end

defp call([], _, release), do: {:ok, release}
Expand All @@ -193,10 +193,10 @@ defmodule Distillery.Releases.Plugin do
apply_plugin(plugin, callback, release, opts)
rescue
e ->
{:error, {:plugin, {e, System.stacktrace()}}}
{:error, {:plugin, {e, __STACKTRACE__}}}
catch
kind, err ->
{:error, {:plugin, {kind, err, System.stacktrace()}}}
{:error, {:plugin, {kind, err, __STACKTRACE__}}}
else
nil ->
call(plugins, callback, release)
Expand Down Expand Up @@ -224,10 +224,10 @@ defmodule Distillery.Releases.Plugin do
apply_plugin(plugin, callback, args, opts)
rescue
e ->
{:error, {:plugin, {e, System.stacktrace()}}}
{:error, {:plugin, {e, __STACKTRACE__}}}
catch
kind, err ->
{:error, {:plugin, {kind, err, System.stacktrace()}}}
{:error, {:plugin, {kind, err, __STACKTRACE__}}}
else
_ ->
run(plugins, callback, args)
Expand Down
8 changes: 4 additions & 4 deletions lib/distillery/releases/runtime/control.ex
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,14 @@ defmodule Distillery.Releases.Runtime.Control do
Console.error("""
Could not load #{Path.expand(file)}: #{Exception.message(err)}
#{Exception.format_stacktrace(System.stacktrace())}
#{Exception.format_stacktrace(__STACKTRACE__)}
""")

err ->
Console.error("""
Evaluation failed with: #{Exception.message(err)}
#{Exception.format_stacktrace(System.stacktrace())}
#{Exception.format_stacktrace(__STACKTRACE__)}
""")
end

Expand Down Expand Up @@ -778,7 +778,7 @@ defmodule Distillery.Releases.Runtime.Control do
Console.error("""
Evaluation failed with: #{Exception.message(err)}
#{Exception.format_stacktrace(System.stacktrace())}
#{Exception.format_stacktrace(__STACKTRACE__)}
""")
end

Expand All @@ -792,7 +792,7 @@ defmodule Distillery.Releases.Runtime.Control do
Console.error("""
Evaluation failed with: #{Exception.message(err)}
#{Exception.format_stacktrace(System.stacktrace())}
#{Exception.format_stacktrace(__STACKTRACE__)}
""")
end

Expand Down
4 changes: 2 additions & 2 deletions lib/distillery/tasks/release.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ defmodule Mix.Tasks.Distillery.Release do
e ->
Shell.error(
"Release failed: #{Exception.message(e)}\n" <>
Exception.format_stacktrace(System.stacktrace())
Exception.format_stacktrace(__STACKTRACE__)
)

System.halt(1)
Expand Down Expand Up @@ -153,7 +153,7 @@ defmodule Mix.Tasks.Distillery.Release do
e ->
Shell.error(
"Release failed: #{Exception.message(e)}\n" <>
Exception.format_stacktrace(System.stacktrace())
Exception.format_stacktrace(__STACKTRACE__)
)

System.halt(1)
Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ defmodule Distillery.Mixfile do
end

def application do
[extra_applications: [:runtime_tools]]
[extra_applications: [:runtime_tools, :crypto, :sasl, :eex]]
end

defp deps do
[
{:artificery, "~> 0.2"},
{:ex_doc, "~> 0.13", only: [:docs]},
{:excoveralls, "~> 0.6", only: [:test]},
{:eqc_ex, "~> 1.4", only: [:test]},
{:excoveralls, "~> 0.18", only: [:test]},
# {:eqc_ex, git: "https://github.com/Quviq/eqc_ex.git", ref: "1e83672", only: [:test]},
{:ex_unit_clustered_case, "~> 0.3", only: [:test], runtime: false},
{:dialyzex, "~> 1.2", only: [:dev], runtime: false}
]
Expand Down
30 changes: 11 additions & 19 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
%{
"artificery": {:hex, :artificery, "0.4.2", "3ded6e29e13113af52811c72f414d1e88f711410cac1b619ab3a2666bbd7efd4", [:mix], [], "hexpm"},
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"dialyzex": {:hex, :dialyzex, "1.2.1", "6a4f28f755882aba7b9aa53f874f636f1aa764d8b0424d74e22827a842a06f94", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"},
"eqc_ex": {:hex, :eqc_ex, "1.4.2", "c89322cf8fbd4f9ddcb18141fb162a871afd357c55c8c0198441ce95ffe2e105", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"ex_unit_clustered_case": {:hex, :ex_unit_clustered_case, "0.3.2", "e4acd0e46c5d6f057d71a1798a1674d333309eb247bbd753af4c5dbe52971b1e", [:mix], [], "hexpm"},
"excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"},
"artificery": {:hex, :artificery, "0.4.2", "3ded6e29e13113af52811c72f414d1e88f711410cac1b619ab3a2666bbd7efd4", [:mix], [], "hexpm", "514586f4312ef3709a3ccbd8e55f69455add235c1729656687bb781d10d0afdb"},
"dialyzex": {:hex, :dialyzex, "1.2.1", "6a4f28f755882aba7b9aa53f874f636f1aa764d8b0424d74e22827a842a06f94", [:mix], [], "hexpm", "6efe5e8612c2e6940d57fc243a99b465c933743cc0ceea1b925b66b4f44d229d"},
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm", "e3be2bc3ae67781db529b80aa7e7c49904a988596e2dbff897425b48b3581161"},
"eqc_ex": {:git, "https://github.com/Quviq/eqc_ex.git", "1e8367293a06de050bbceffc53ac2aca7696dae7", [ref: "1e83672"]},
"ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "8e24fc8ff9a50b9f557ff020d6c91a03cded7e59ac3e0eec8a27e771430c7d27"},
"ex_unit_clustered_case": {:hex, :ex_unit_clustered_case, "0.3.2", "e4acd0e46c5d6f057d71a1798a1674d333309eb247bbd753af4c5dbe52971b1e", [:mix], [], "hexpm", "6c680701b8699797610cc695c6dd9d8c3efbad3653f2f59fa6f98a9d00706b48"},
"excoveralls": {:hex, :excoveralls, "0.18.0", "b92497e69465dc51bc37a6422226ee690ab437e4c06877e836f1c18daeb35da9", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1109bb911f3cb583401760be49c02cbbd16aed66ea9509fc5479335d284da60b"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5fbc8e549aa9afeea2847c0769e3970537ed302f93a23ac612602e805d9d1e7f"},
"makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "adf0218695e22caeda2820eaba703fa46c91820d53813a2223413da3ef4ba515"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm", "5c040b8469c1ff1b10093d3186e2e10dbe483cd73d79ec017993fb3985b8a9b3"},
}
2 changes: 1 addition & 1 deletion priv/libexec/commands/console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ erlexec \
-args_file "$VMARGS_PATH" \
-mode "$CODE_LOADING_MODE" \
${ERL_OPTS} \
-user Elixir.IEx.CLI \
-user \
-extra --no-halt +iex \
-- "$@"
20 changes: 8 additions & 12 deletions priv/libexec/erts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ __rel_apps() {
-e's/^[^a-z]*//' \
-e's/,/-/' \
-e's/"//' \
-e's/","[^"]*$//'
-e's/","[^"]*$//' \
-e's/",<<"[^"]*$//'
}

code_paths=()
Expand Down Expand Up @@ -173,7 +174,6 @@ Usage: $(basename "$0") [options] [.exs file] [data]
--logger-otp-reports BOOL Enables or disables OTP reporting
--logger-sasl-reports BOOL Enables or disables SASL reporting
--no-halt Does not halt the Erlang VM after execution
--werl Uses Erlang's Windows shell GUI (Windows only)
Options given after the .exs file or -- are passed down to the executed code.
Options can be passed to the Erlang runtime using \$ELIXIR_ERL_OPTIONS or --erl.
Expand Down Expand Up @@ -204,7 +204,7 @@ See run_erl to learn more. To reattach, run: to_erl PIPEDIR.
USAGE
exit 1
fi
MODE="elixir"
MODE="cli"
ERL=""
I=1
E=0
Expand All @@ -213,13 +213,12 @@ USAGE
while [ $I -le $LENGTH ]; do
S=1
case "$1" in
+iex)
+elixirc)
set -- "$@" "$1"
MODE="iex"
;;
+elixirc)
+iex)
set -- "$@" "$1"
MODE="elixirc"
MODE="iex"
;;
-v|--no-halt)
set -- "$@" "$1"
Expand Down Expand Up @@ -296,8 +295,6 @@ USAGE
echo "--pipe-to : LOGDIR cannot be a switch" >&2 && exit 1
fi
;;
--werl)
;;
*)
while [ $I -le $LENGTH ]; do
I=$((I + 1))
Expand All @@ -318,14 +315,13 @@ USAGE
I=$((I - 1))
done

if [ "$MODE" != "iex" ]; then ERL="-noshell -s elixir start_cli $ERL"; fi
#shellcheck disable=2086
erl $ELIXIR_ERL_OPTIONS $ERL "$@"
erl -noshell -elixir_root "$RELEASE_ROOT_DIR/lib" $ELIXIR_ERL_OPTIONS -s elixir start_$MODE $ERL "$@"
}

# Run IEx
iex() {
elixir --no-halt --erl "-noshell -user Elixir.IEx.CLI" +iex "$@"
elixir --no-halt --erl "-user elixir" +iex "$@"
}

# Echoes the current ERTS version
Expand Down
Loading

0 comments on commit b3ba48a

Please sign in to comment.