From 36e9b3f3df4bc6f7b99661188e6eb72bc87374c6 Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Tue, 22 Oct 2024 15:58:41 +0200 Subject: [PATCH] require Elixir 1.15+ in new apps (#5957) Closes #5276. --- .github/workflows/ci.yml | 16 ++++++------ guides/deployment/heroku.md | 4 +-- guides/deployment/releases.md | 8 +++--- guides/introduction/installation.md | 6 ++--- installer/lib/mix/tasks/phx.new.ex | 25 +++---------------- installer/mix.exs | 2 +- .../templates/phx_single/config/config.exs | 2 +- installer/templates/phx_single/mix.exs | 2 +- .../phx_umbrella/apps/app_name/mix.exs | 2 +- .../phx_umbrella/apps/app_name_web/mix.exs | 2 +- .../templates/phx_umbrella/config/dev.exs | 2 +- .../phx_umbrella/config/extra_config.exs | 2 +- integration_test/docker.sh | 6 ++--- integration_test/mix.exs | 2 +- test/test_helper.exs | 2 +- 15 files changed, 33 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc08e02056..c11117b32a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,8 @@ jobs: - elixir: 1.14.5 otp: 25.3.2.9 - - elixir: 1.17.2 - otp: 27.0 + - elixir: 1.17.3 + otp: 27.1 lint: true installer: true @@ -111,13 +111,13 @@ jobs: matrix: include: # look for correct alpine image here: https://hub.docker.com/r/hexpm/elixir/tags - - elixir: 1.14.5 - otp: 25.3.2.12 - suffix: "alpine-3.19.1" + - elixir: 1.15.8 + otp: 24.3.4.17 + suffix: "alpine-3.20.3" - - elixir: 1.16.2 - otp: 26.2.5 - suffix: "alpine-3.19.1" + - elixir: 1.17.3 + otp: 27.1.2 + suffix: "alpine-3.20.3" container: image: hexpm/elixir:${{ matrix.elixir }}-erlang-${{ matrix.otp }}-${{ matrix.suffix }} diff --git a/guides/deployment/heroku.md b/guides/deployment/heroku.md index b2560b0880..9ba3838f22 100644 --- a/guides/deployment/heroku.md +++ b/guides/deployment/heroku.md @@ -97,11 +97,11 @@ The buildpack uses a predefined Elixir and Erlang version, but to avoid surprise ```console # Elixir version -elixir_version=1.14.0 +elixir_version=1.15.0 # Erlang version # https://github.com/HashNuke/heroku-buildpack-elixir-otp-builds/blob/master/otp-versions -erlang_version=24.3 +erlang_version=25.3 # Invoke assets.deploy defined in your mix.exs to deploy assets with esbuild # Note we nuke the esbuild executable from the image diff --git a/guides/deployment/releases.md b/guides/deployment/releases.md index c89ef2add7..7e4d1668fa 100644 --- a/guides/deployment/releases.md +++ b/guides/deployment/releases.md @@ -169,11 +169,11 @@ If you call `mix phx.gen.release --docker` you'll see a new file with these cont # - https://hub.docker.com/r/hexpm/elixir/tags - for the build image # - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20230612-slim - for the release image # - https://pkgs.org/ - resource for finding needed packages -# - Ex: hexpm/elixir:1.14.5-erlang-25.3.2.4-debian-bullseye-20230612-slim +# - Ex: hexpm/elixir:1.15.8-erlang-25.3.2.15-debian-bookworm-20241016-slim # -ARG ELIXIR_VERSION=1.14.5 -ARG OTP_VERSION=25.3.2.4 -ARG DEBIAN_VERSION=bullseye-20230612-slim +ARG ELIXIR_VERSION=1.15.8 +ARG OTP_VERSION=25.3.2.15 +ARG DEBIAN_VERSION=bookworm-20241016-slim ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}" ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}" diff --git a/guides/introduction/installation.md b/guides/introduction/installation.md index e7e96a9f91..11b2c3969e 100644 --- a/guides/introduction/installation.md +++ b/guides/introduction/installation.md @@ -8,7 +8,7 @@ In order to build a Phoenix application, we will need a few dependencies install Please take a look at this list and make sure to install anything necessary for your system. Having dependencies installed in advance can prevent frustrating problems later on. -## Elixir 1.14 or later +## Elixir 1.15 or later Phoenix is written in Elixir, and our application code will also be written in Elixir. We won't get far in a Phoenix app without it! The Elixir site maintains a great [Installation Page](https://elixir-lang.org/install.html) to help. @@ -28,13 +28,13 @@ When we install Elixir using instructions from the Elixir [Installation Page](ht ## Phoenix -To check that we are on Elixir 1.14 and Erlang 24 or later, run: +To check that we are on Elixir 1.15 and Erlang 24 or later, run: ```console elixir -v Erlang/OTP 24 [erts-12.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] -Elixir 1.14.0 +Elixir 1.15.0 ``` Once we have Elixir and Erlang, we are ready to install the Phoenix application generator: diff --git a/installer/lib/mix/tasks/phx.new.ex b/installer/lib/mix/tasks/phx.new.ex index 01882b9d21..dc4807b652 100644 --- a/installer/lib/mix/tasks/phx.new.ex +++ b/installer/lib/mix/tasks/phx.new.ex @@ -223,9 +223,7 @@ defmodule Mix.Tasks.Phx.New do Task.async(fn -> cmd(project, cmd, log: false, cd: project.web_path) end) end) - if rebar_available?() do - cmd(project, "mix deps.compile") - end + cmd(project, "mix deps.compile") Task.await_many(tasks, :infinity) end @@ -254,28 +252,13 @@ defmodule Mix.Tasks.Phx.New do defp maybe_cd(path, func), do: path && File.cd!(path, func) defp install_mix(project, install?) do - if install? && hex_available?() do + if install? do cmd(project, "mix deps.get") else ["$ mix deps.get"] end end - # TODO: Elixir v1.15 automatically installs Hex/Rebar if missing, so we can simplify this. - defp hex_available? do - Code.ensure_loaded?(Hex) - end - - if Version.match?(System.version(), "~> 1.18") do - defp rebar_available? do - true - end - else - defp rebar_available? do - Mix.Rebar.rebar_cmd(:rebar3) - end - end - defp print_missing_steps(steps) do Mix.shell().info(""" @@ -395,9 +378,9 @@ defmodule Mix.Tasks.Phx.New do end defp elixir_version_check! do - unless Version.match?(System.version(), "~> 1.14") do + unless Version.match?(System.version(), "~> 1.15") do Mix.raise( - "Phoenix v#{@version} requires at least Elixir v1.14\n " <> + "Phoenix v#{@version} requires at least Elixir v1.15\n " <> "You have #{System.version()}. Please update accordingly" ) end diff --git a/installer/mix.exs b/installer/mix.exs index 98ca0634c6..518f3a2432 100644 --- a/installer/mix.exs +++ b/installer/mix.exs @@ -17,7 +17,7 @@ defmodule Phx.New.MixProject do # 4. test/test_helper.exs at the root # 5. installer/lib/mix/tasks/phx.new.ex # - @elixir_requirement "~> 1.14" + @elixir_requirement "~> 1.15" def project do [ diff --git a/installer/templates/phx_single/config/config.exs b/installer/templates/phx_single/config/config.exs index 661291d54a..97c1bbf53b 100644 --- a/installer/templates/phx_single/config/config.exs +++ b/installer/templates/phx_single/config/config.exs @@ -56,7 +56,7 @@ config :tailwind, ]<% end %> # Configures Elixir's Logger -config :logger, :console, +config :logger, :default_formatter, format: "$time $metadata[$level] $message\n", metadata: [:request_id] diff --git a/installer/templates/phx_single/mix.exs b/installer/templates/phx_single/mix.exs index 8282523114..ed631a2521 100644 --- a/installer/templates/phx_single/mix.exs +++ b/installer/templates/phx_single/mix.exs @@ -9,7 +9,7 @@ defmodule <%= @app_module %>.MixProject do config_path: "../../config/config.exs", deps_path: "../../deps", lockfile: "../../mix.lock",<% end %> - elixir: "~> 1.14", + elixir: "~> 1.15", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(), diff --git a/installer/templates/phx_umbrella/apps/app_name/mix.exs b/installer/templates/phx_umbrella/apps/app_name/mix.exs index b1510c8c23..5ba7b9323e 100644 --- a/installer/templates/phx_umbrella/apps/app_name/mix.exs +++ b/installer/templates/phx_umbrella/apps/app_name/mix.exs @@ -9,7 +9,7 @@ defmodule <%= @app_module %>.MixProject do config_path: "../../config/config.exs", deps_path: "../../deps", lockfile: "../../mix.lock", - elixir: "~> 1.14", + elixir: "~> 1.15", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(), diff --git a/installer/templates/phx_umbrella/apps/app_name_web/mix.exs b/installer/templates/phx_umbrella/apps/app_name_web/mix.exs index 620aa84ec4..f0bd3d0cd2 100644 --- a/installer/templates/phx_umbrella/apps/app_name_web/mix.exs +++ b/installer/templates/phx_umbrella/apps/app_name_web/mix.exs @@ -9,7 +9,7 @@ defmodule <%= @web_namespace %>.MixProject do config_path: "../../config/config.exs", deps_path: "../../deps", lockfile: "../../mix.lock", - elixir: "~> 1.14", + elixir: "~> 1.15", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(), diff --git a/installer/templates/phx_umbrella/config/dev.exs b/installer/templates/phx_umbrella/config/dev.exs index c48d060474..a049be27d4 100644 --- a/installer/templates/phx_umbrella/config/dev.exs +++ b/installer/templates/phx_umbrella/config/dev.exs @@ -1,7 +1,7 @@ import Config # Do not include metadata nor timestamps in development logs -config :logger, :console, format: "[$level] $message\n" +config :logger, :default_formatter, format: "[$level] $message\n" # Initialize plugs at runtime for faster development compilation config :phoenix, :plug_init_mode, :runtime<%= if @html do %> diff --git a/installer/templates/phx_umbrella/config/extra_config.exs b/installer/templates/phx_umbrella/config/extra_config.exs index 68d1c6605a..a34ed28f28 100644 --- a/installer/templates/phx_umbrella/config/extra_config.exs +++ b/installer/templates/phx_umbrella/config/extra_config.exs @@ -1,7 +1,7 @@ import Config # Configures Elixir's Logger -config :logger, :console, +config :logger, :default_formatter, format: "$time $metadata[$level] $message\n", metadata: [:request_id] diff --git a/integration_test/docker.sh b/integration_test/docker.sh index ab4441ca7c..c2a2965141 100755 --- a/integration_test/docker.sh +++ b/integration_test/docker.sh @@ -2,9 +2,9 @@ # adapt with versions from .github/versions/ci.yml if necessary; # you can also override these with environment variables -ELIXIR="${ELIXIR:-1.16.2}" -ERLANG="${ERLANG:-26.2.5}" -SUFFIX="${SUFFIX:-alpine-3.19.1}" +ELIXIR="${ELIXIR:-1.17.3}" +ERLANG="${ERLANG:-27.1.2}" +SUFFIX="${SUFFIX:-alpine-3.20.3}" # Get the directory of the script SCRIPT_DIR=$(dirname "$(readlink -f "$0")") diff --git a/integration_test/mix.exs b/integration_test/mix.exs index 4c45c7fcfc..731c09dde6 100644 --- a/integration_test/mix.exs +++ b/integration_test/mix.exs @@ -10,7 +10,7 @@ defmodule Phoenix.Integration.MixProject do [ app: :phoenix_integration, version: "0.1.0", - elixir: "~> 1.14", + elixir: "~> 1.15", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, deps: deps() diff --git a/test/test_helper.exs b/test/test_helper.exs index 3202405518..ae30db4b73 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -26,7 +26,7 @@ assert_timeout = String.to_integer( ) excludes = - if Version.match?(System.version(), "~> 1.14") do + if Version.match?(System.version(), "~> 1.15") do [] else [:mix_phx_new]