Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏹 Upgrade Elixir version #1024

Merged
merged 17 commits into from
Oct 29, 2024
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
Empty file removed .dialyzer.ignore-warnings
Empty file.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ npm-debug.log

# Screenshots taken by Wallaby
/test/integration/screenshots

.elixir_ls
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
elixir 1.14.5-otp-26
erlang 26.1.2
elixir 1.17.3-otp-27
erlang 27.1.2
nodejs 20.8.1
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG ELIXIR_VERSION=1.14.5
ARG ERLANG_VERSION=26.1.2
ARG DEBIAN_VERSION=bullseye-20230612
ARG ELIXIR_VERSION=1.17.3
ARG ERLANG_VERSION=27.1.2
ARG DEBIAN_VERSION=bullseye-20241016

FROM hexpm/elixir:$ELIXIR_VERSION-erlang-$ERLANG_VERSION-debian-$DEBIAN_VERSION as elixir-builder

Expand Down Expand Up @@ -39,6 +39,7 @@ COPY config/config.exs config/
COPY config/prod.exs config/

RUN mix deps.compile
RUN mix sentry.package_source_code

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COPY assets assets
RUN npm ci --prefix assets
Expand Down
5 changes: 2 additions & 3 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ if config_env() == :prod do
root_source_code_path: File.cwd!(),
tags: %{
env: sentry_env
},
included_environments: [sentry_env]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

config :logger, Sentry.LoggerBackend,
level: :warn,
level: :warning,
capture_log_messages: true
end

Expand Down
10 changes: 9 additions & 1 deletion lib/arrow/disruption_revision.ex
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ defmodule Arrow.DisruptionRevision do

Enum.all?(days_of_week, fn day ->
Enum.member?(
Enum.map(Date.range(start_date, end_date), fn date -> Date.day_of_week(date) end),
Enum.map(date_range(start_date, end_date), fn date -> Date.day_of_week(date) end),
DayOfWeek.day_number(day)
)
end) ->
Expand Down Expand Up @@ -285,4 +285,12 @@ defmodule Arrow.DisruptionRevision do
changeset
end
end

defp date_range(start_date, end_date) do
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address new deprecation warnings where it's required to provide a step of -1 if end_date > start_date

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code below is correct but what you meant in this comment was start_date > end_date for step of -1 (so it enumerates backwards in time from start_date to end_date)

if Date.compare(start_date, end_date) == :gt do
Date.range(start_date, end_date, -1)
else
Date.range(start_date, end_date)
end
end
end
4 changes: 2 additions & 2 deletions lib/arrow/gtfs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule Arrow.Gtfs do
:ok

{:error, reason} = error ->
Logger.warn(
Logger.warning(
"GTFS import or validation failed #{job_logging_params(job)} reason=#{inspect(reason)}"
)

Expand All @@ -51,7 +51,7 @@ defmodule Arrow.Gtfs do
:ok

{:error, reason} = error ->
Logger.warn(
Logger.warning(
"GTFS import or validation failed #{job_logging_params(job)} reason=#{inspect(reason)}"
)

Expand Down
2 changes: 1 addition & 1 deletion lib/arrow/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Arrow.Repo do

Keyword.merge(config,
password: token,
ssl_opts: [
ssl: [
cacertfile: Path.join(:code.priv_dir(:arrow), "aws-cert-bundle.pem"),
verify: :verify_peer,
server_name_indication: String.to_charlist(hostname),
Expand Down
8 changes: 4 additions & 4 deletions lib/arrow_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule ArrowWeb do
def channel do
quote do
use Phoenix.Channel
import ArrowWeb.Gettext
use Gettext, backend: ArrowWeb.Gettext
end
end

Expand All @@ -41,7 +41,7 @@ defmodule ArrowWeb do
use Phoenix.Controller, namespace: ArrowWeb

import Plug.Conn
import ArrowWeb.Gettext
use Gettext, backend: ArrowWeb.Gettext
alias ArrowWeb.Router.Helpers, as: Routes

unquote(verified_routes())
Expand All @@ -63,7 +63,7 @@ defmodule ArrowWeb do
use Phoenix.HTML

import ArrowWeb.ErrorHelpers
import ArrowWeb.Gettext
use Gettext, backend: ArrowWeb.Gettext
alias ArrowWeb.Router.Helpers, as: Routes

# Import the `react_component` helper
Expand All @@ -77,7 +77,7 @@ defmodule ArrowWeb do
import Phoenix.HTML
# Core UI components and translation
import ArrowWeb.CoreComponents
import ArrowWeb.Gettext
use Gettext, backend: ArrowWeb.Gettext

# Shortcut for generating JS commands
alias Phoenix.LiveView.JS
Expand Down
2 changes: 1 addition & 1 deletion lib/arrow_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule ArrowWeb.CoreComponents do
use Phoenix.Component

alias Phoenix.LiveView.JS
import ArrowWeb.Gettext
use Gettext, backend: ArrowWeb.Gettext
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@doc """
Renders a modal.
Expand Down
2 changes: 1 addition & 1 deletion lib/arrow_web/controllers/api/gtfs_import_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ defmodule ArrowWeb.API.GtfsImportController do
json(conn, value)

{:error, status, message} ->
Logger.warn("GtfsImportController unsuccessful request message=#{inspect(message)}")
Logger.warning("GtfsImportController unsuccessful request message=#{inspect(message)}")
send_resp(conn, status, message)

{:error, message} ->
Expand Down
2 changes: 1 addition & 1 deletion lib/arrow_web/controllers/disruption_html/_table.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<tbody>
<%= for %{revisions: [revision]} = disruption <- @disruptions do %>
<tr class={if not revision.row_approved, do: 'bg-light-pink'}>
<tr class={if not revision.row_approved, do: "bg-light-pink"}>
<td>
<%= revision.title %>
</td>
Expand Down
5 changes: 0 additions & 5 deletions lib/arrow_web/controllers/shape_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ defmodule ArrowWeb.ShapeController do
conn
|> put_flash(:errors, reason)
|> render(:new_bulk, errors: reason, shapes_upload: reset_upload)

error ->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dialyzer flags this clause as unreachable, and I agree. parse_kml_from_file and shapes_from_kml will always return {:ok, _} or {:error, _}, and changeset will always return a changeset, so will always match.

conn
|> put_flash(:errors, error)
|> render(:new_bulk, errors: error, shapes_upload: reset_upload)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/arrow_web/gettext.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule ArrowWeb.Gettext do
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:

import ArrowWeb.Gettext
use Gettext, backend: ArrowWeb.Gettext

# Simple translation
gettext("Here is the string to translate")
Expand All @@ -20,5 +20,5 @@ defmodule ArrowWeb.Gettext do

See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :arrow
use Gettext.Backend, otp_app: :arrow
end
2 changes: 1 addition & 1 deletion lib/arrow_web/try_api_token_auth/cognito.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule ArrowWeb.TryApiTokenAuth.Cognito do
[]

response ->
:ok = Logger.warn("unexpected_aws_api_response: #{inspect(response)}")
:ok = Logger.warning("unexpected_aws_api_response: #{inspect(response)}")
[]
end

Expand Down
2 changes: 1 addition & 1 deletion lib/arrow_web/try_api_token_auth/keycloak.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule ArrowWeb.TryApiTokenAuth.Keycloak do
)
else
other ->
Logger.warn(
Logger.warning(
"unexpected response when logging #{auth_token.username} in via Keycloak API: #{inspect(other)}"
)

Expand Down
17 changes: 8 additions & 9 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ defmodule Arrow.MixProject do
releases: releases(),
dialyzer: [
plt_add_apps: [:mix],
plt_add_deps: :transitive,
plt_add_deps: :app_tree,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flags: [
:unmatched_returns
],
ignore_warnings: ".dialyzer.ignore-warnings"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dialyzer complained about could not read file stats ".dialyzer_ignore.exs": no such file or directory as long as this was present. I didn't figure out why, but we also aren't ignoring warnings (.dialyzer.ignore-warnings is blank) so I removed it.

]
],
preferred_cli_env: ["test.integration": :test],
test_coverage: [tool: LcovEx, ignore_paths: ["deps/"]]
Expand Down Expand Up @@ -60,11 +59,11 @@ defmodule Arrow.MixProject do
{:gettext, "~> 0.11"},
{:guardian, "~> 2.0"},
{:hackney, "~> 1.9"},
{:httpoison, "~> 1.6"},
{:httpoison, "~> 2.2"},
{:ja_serializer, github: "mbta/ja_serializer", branch: "master"},
{:jason, "~> 1.0"},
{:lcov_ex, "~> 0.2", only: [:dev, :test], runtime: false},
{:mox, "~> 1.0.0", only: :test},
{:mox, "~> 1.2", only: :test},
{:oban, "~> 2.18"},
{:phoenix_ecto, "~> 4.0"},
{:phoenix_live_reload, "~> 1.5", only: :dev},
Expand All @@ -76,17 +75,17 @@ defmodule Arrow.MixProject do
{:phoenix, "~> 1.7.12"},
{:plug_cowboy, "~> 2.1"},
{:telemetry, "~> 1.2", override: true},
{:telemetry_poller, "~> 0.4"},
{:telemetry_metrics, "~> 0.4"},
{:telemetry_poller, "~> 1.1"},
{:telemetry_metrics, "~> 1.0"},
{:postgrex, ">= 0.0.0"},
# If react_phoenix changes, check assets/src/ReactPhoenix.js, too
{:react_phoenix, "1.3.1"},
{:tzdata, "~> 1.1"},
{:ueberauth_cognito, "0.4.0"},
{:ueberauth_oidcc, "~> 0.4.0"},
{:ueberauth, "~> 0.10"},
{:wallaby, "~> 0.30.6", runtime: false, only: :test},
{:sentry, "~> 8.0"},
{:wallaby, "~> 0.30", runtime: false, only: :test},
{:sentry, "~> 10.7"},
{:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
{:heroicons,
github: "tailwindlabs/heroicons",
Expand Down
Loading
Loading