Skip to content

Commit add6a97

Browse files
authored
chore: upgrade to elixir 1.20.0 (#913)
1 parent d20f5b8 commit add6a97

18 files changed

Lines changed: 168 additions & 39 deletions

File tree

.github/workflows/elixir.yml

Lines changed: 122 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,125 @@ on:
88
jobs:
99
test:
1010
name: Setup, Build, Test
11-
uses: brianmay/workflows/.github/workflows/elixir.yaml@b751c43c6ad3df6d5ef91a3ff5a263344169e332 # main
12-
with:
13-
plts_cache_postfix: "-5"
14-
apt_packages: "graphicsmagick-imagemagick-compat libimage-exiftool-perl ffmpeg exiftran libraw-bin"
15-
test_data: "https://www.dropbox.com/s/yg6jdk9lfewn8yf/penguin_memories.tar?dl=0"
16-
test_sha256: "1be2094961977dc393b7312b8799259b2026b4570c4591bc6759dbfbfb0fe146"
11+
runs-on: ubuntu-latest
12+
if: ${{ github.repository_owner != 'brianmay' || github.event_name != 'pull_request' }}
13+
14+
# Service containers to run with `container-job`
15+
services:
16+
# Label used to access the service container
17+
postgres:
18+
# Docker Hub image
19+
image: postgis/postgis
20+
ports: ["5432:5432"]
21+
# Provide the password for postgres
22+
env:
23+
POSTGRES_USER: postgres
24+
POSTGRES_PASSWORD: postgres
25+
POSTGRES_DB: test
26+
# Set health checks to wait until postgres has started
27+
options: >-
28+
--health-cmd pg_isready
29+
--health-interval 10s
30+
--health-timeout 5s
31+
--health-retries 5
32+
33+
strategy:
34+
matrix:
35+
elixir: [1.20.0-rc.6]
36+
otp: [29.0.1]
37+
38+
env:
39+
DATABASE_URL_TEST: postgresql://postgres:postgres@localhost/test?sslmode=disable
40+
MIX_ENV: test
41+
BUILD_WITHOUT_QUIC: true
42+
43+
steps:
44+
- uses: actions/checkout@v6
45+
- name: Install system dependancies
46+
run: |
47+
sudo apt-get update --yes
48+
sudo apt-get install --yes graphicsmagick-imagemagick-compat libimage-exiftool-perl ffmpeg exiftran libraw-bin
49+
- name: Setup elixir
50+
uses: erlef/setup-elixir@v1.24
51+
with:
52+
elixir-version: ${{ matrix.elixir }}
53+
otp-version: ${{ matrix.otp }}
54+
- name: Retrieve Mix Dependencies Cache
55+
uses: actions/cache@v5
56+
id: mix-cache # id to use in retrieve action
57+
with:
58+
path: deps
59+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('mix.lock') }}
60+
- name: Install Mix Dependencies
61+
if: ${{ steps.mix-cache.outputs.cache-hit != 'true' }}
62+
run: |
63+
mix local.rebar --force
64+
mix local.hex --force
65+
mix deps.get
66+
- name: Build
67+
run: |
68+
mix compile
69+
- name: Build NPM assets
70+
run: |
71+
npm install --prefix assets
72+
npm run deploy --prefix assets
73+
- name: Check Formatting
74+
run: mix format --check-formatted
75+
- name: Run Credo
76+
run: mix credo --strict
77+
- name: Download and extract test data
78+
run: |
79+
wget https://www.dropbox.com/s/yg6jdk9lfewn8yf/penguin_memories.tar?dl=0 -O test_data.tar
80+
echo "1be2094961977dc393b7312b8799259b2026b4570c4591bc6759dbfbfb0fe146 test_data.tar" | sha256sum --check
81+
tar -xvf test_data.tar
82+
- name: Run Tests
83+
run: mix test
84+
85+
dialyzer:
86+
runs-on: ubuntu-latest
87+
if: ${{ github.repository_owner != 'brianmay' || github.event_name != 'pull_request' }}
88+
89+
strategy:
90+
matrix:
91+
elixir: [1.20.0-rc.6]
92+
otp: [29.0.1]
93+
94+
env:
95+
MIX_ENV: test
96+
BUILD_WITHOUT_QUIC: true
97+
98+
steps:
99+
- uses: actions/checkout@v6
100+
- name: Setup elixir
101+
uses: erlef/setup-elixir@v1.24
102+
with:
103+
elixir-version: ${{ matrix.elixir }}
104+
otp-version: ${{ matrix.otp }}
105+
- name: Retrieve Mix Dependencies Cache
106+
uses: actions/cache@v5
107+
id: mix-cache # id to use in retrieve action
108+
with:
109+
path: deps
110+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('mix.lock') }}
111+
- name: Retrieve PLT Cache
112+
uses: actions/cache@v5
113+
id: plt-cache
114+
with:
115+
path: priv/plts
116+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles('mix.lock') }}-5
117+
- name: Install Mix Dependencies
118+
if: ${{ steps.mix-cache.outputs.cache-hit != 'true' }}
119+
run: |
120+
mix local.rebar --force
121+
mix local.hex --force
122+
mix deps.get
123+
- name: Build
124+
run: |
125+
mix compile
126+
- name: Create PLTs
127+
if: ${{ steps.plt-cache.outputs.cache-hit != 'true' }}
128+
run: |
129+
mkdir -p priv/plts
130+
mix dialyzer --plt
131+
- name: Run dialyzer
132+
run: mix dialyzer --no-check

dialyzer.ignore-warnings.exs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,15 @@
33
"The created anonymous function has no local return."},
44
{"lib/penguin_memories/photos/album_path.ex", "Function new_path/2 has no local return."},
55
{"lib/penguin_memories/photos/album_path.ex", "Function new_path/3 has no local return."},
6-
{"lib/penguin_memories/photos/album_path.ex", "The function call changeset will not succeed."}
6+
{"lib/penguin_memories/photos/album_path.ex", "The function call changeset will not succeed."},
7+
# Same root cause as the new_path entries above: dialyzer thinks the
8+
# changeset call cannot succeed, so the @spec no longer matches.
9+
{"lib/penguin_memories/photos/album_path.ex", :invalid_contract},
10+
# False positives on MapSet/Ecto.Multi opaque internals with the
11+
# OTP 29 / Elixir 1.20 PLT.
12+
{"lib/penguin_memories/database/impl/backend/album.ex", :call_without_opaque},
13+
{"lib/penguin_memories/database/index.ex", :call_without_opaque},
14+
{"lib/penguin_memories/database/path_compute.ex", :call_without_opaque},
15+
{"lib/penguin_memories/database/query.ex", :call_without_opaque},
16+
{"lib/penguin_memories/upload.ex", :call_without_opaque}
717
]

flake.nix

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,16 @@
2828
inherit (pkgs.lib) optional optionals;
2929
pkgs = nixpkgs.legacyPackages.${system};
3030

31-
elixir = pkgs.beam.packages.erlang_28.elixir_1_18;
32-
beamPackages = pkgs.beam.packagesWith pkgs.beam.interpreters.erlang_28;
31+
elixir = pkgs.beam.packages.erlang_29.elixir_1_20;
32+
beamPackages = pkgs.beam.packagesWith pkgs.beam.interpreters.erlang_29;
33+
34+
# rebar3 3.27 fails to compile under OTP 29 (new compiler warnings
35+
# are treated as errors in its build). Escripts built with OTP 28
36+
# run fine on OTP 29, so borrow them from the erlang_28 package set.
37+
rebarOverrides = {
38+
rebar = pkgs.beam.packages.erlang_28.rebar;
39+
rebar3 = pkgs.beam.packages.erlang_28.rebar3;
40+
};
3341

3442
src = ./.;
3543
version = "0.0.0";
@@ -40,7 +48,7 @@
4048
VCS_REF = "${self.shortRev or self.dirtyShortRev or "dirty"}";
4149
};
4250

43-
mixFodDeps = beamPackages.fetchMixDeps {
51+
mixFodDeps = (beamPackages.fetchMixDeps.override rebarOverrides) {
4452
TOP_SRC = src;
4553
pname = "${pname}-mix-deps";
4654
inherit src version;
@@ -77,7 +85,7 @@
7785
'';
7886
};
7987

80-
pkg = beamPackages.mixRelease {
88+
pkg = (beamPackages.mixRelease.override rebarOverrides) {
8189
TOP_SRC = src;
8290
inherit
8391
pname

lib/penguin_memories/actions.ex

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,8 @@ defmodule PenguinMemories.Actions do
132132
|> List.flatten()
133133
|> Enum.reject(fn file -> is_nil(file) end)
134134

135-
files =
136-
if original_file != nil do
137-
original_file = update_entry(original_file, photo.files)
138-
[original_file | files]
139-
else
140-
files
141-
end
135+
original_file = update_entry(original_file, photo.files)
136+
files = [original_file | files]
142137

143138
files =
144139
if raw_file != nil do

lib/penguin_memories/database/impl/backend/album.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ defmodule PenguinMemories.Database.Impl.Backend.Album do
176176
raw = Query.get_raw_from_result(result, Album)
177177
cursor = Paginator.cursor_for_record(result, get_cursor_fields())
178178

179+
%Album{} = album = result.o
180+
179181
obj = %Album{
180-
result.o
182+
album
181183
| photo_count: result.photo_count || 0,
182184
child_count: result.child_count || 0
183185
}

lib/penguin_memories/database/impl/backend/photo.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ defmodule PenguinMemories.Database.Impl.Backend.Photo do
199199
)
200200
|> Repo.all()
201201

202-
o = %Photo{result.o | related: related}
202+
%Photo{} = photo = result.o
203+
o = %Photo{photo | related: related}
203204
cursor = Paginator.cursor_for_record(result, get_cursor_fields())
204205

205206
%Query.Details{

lib/penguin_memories/database/query.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,6 @@ defmodule PenguinMemories.Database.Query do
438438
end
439439

440440
@spec get_photo_parents(albums :: list(struct())) :: list({integer(), list(Icon.t())})
441-
defp get_photo_parents([]), do: []
442-
443441
defp get_photo_parents([album]) do
444442
album_icon = query_icon_by_id(album.id, PenguinMemories.Photos.Album, "thumb")
445443

lib/penguin_memories/media.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ defmodule PenguinMemories.Media do
134134
[cmd | args] = cmdline
135135
{text, 0} = System.cmd(cmd, args, stderr_to_stdout: false)
136136
[size_text | _] = String.split(text, ":")
137-
[width, height] = String.split(size_text, "x", max_parts: 2)
137+
[width, height] = String.split(size_text, "x", parts: 2)
138138
{width, ""} = Integer.parse(width)
139139
{height, ""} = Integer.parse(height)
140140
%Size{width: width, height: height}

lib/penguin_memories/upload.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ defmodule PenguinMemories.Upload do
7272

7373
defp flash_used(mode) do
7474
cond do
75-
is_nil(mode) -> nil
7675
(mode &&& 1) != 0 -> true
7776
true -> false
7877
end
@@ -85,7 +84,6 @@ defmodule PenguinMemories.Upload do
8584
cond do
8685
number == "inf" -> nil
8786
number == "undef" -> nil
88-
is_nil(number) -> nil
8987
is_integer(number) -> number * 1.0
9088
is_float(number) -> number
9189
end

lib/penguin_memories/urls.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule PenguinMemories.Urls do
33
URL helper functions
44
"""
55
@spec url_merge(URI.t(), %{required(String.t()) => String.t()}, list(String.t())) :: URI.t()
6-
def url_merge(url, merge, delete) do
6+
def url_merge(%URI{} = url, merge, delete) do
77
query =
88
case url.query do
99
nil -> %{}

0 commit comments

Comments
 (0)