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

Resolve Dialyzer errors on Elixir 1.16 #643

Merged
merged 17 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
74 changes: 70 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ jobs:
version-type: strict
- name: Restore dependencies cache
uses: actions/cache@v4
id: cache
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
key: ${{matrix.otp}}-${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{matrix.otp}}-${{ runner.os }}-mix-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
env:
MIX_ENV: test
run: |
Expand All @@ -63,11 +65,13 @@ jobs:
version-type: strict
- name: Restore dependencies cache
uses: actions/cache@v4
id: cache
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('test/lockfiles/gun1.lock') }}
restore-keys: ${{ runner.os }}-mix-
key: ${{ runner.os }}-mix-gun-${{ hashFiles('test/lockfiles/gun1.lock') }}
restore-keys: ${{ runner.os }}-mix-gun-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
env:
MIX_ENV: test
LOCKFILE: gun1
Expand All @@ -79,3 +83,65 @@ jobs:
env:
LOCKFILE: gun1
run: mix test test/tesla/adapter/gun_test.exs --trace

dialyzer:
yordis marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
name: Dialyzer
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- otp: '25.3.2.12'
elixir: '1.15.8'
experimental: false
- otp: '26.2.5'
elixir: '1.16.3'
experimental: false
- otp: '27.0'
elixir: '1.17.1'
experimental: false
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
version-type: strict
- name: Restore dependencies cache
uses: actions/cache@v4
id: cache
with:
path: |
deps
_build
dialyzer
key: ${{matrix.otp}}-${{ runner.os }}-dialyzer-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{matrix.otp}}-${{ runner.os }}-dialyzer-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
env:
MIX_ENV: test
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
# Doesn't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
# Cache key based on Elixir & Erlang version.
- name: Restore PLT cache
uses: actions/cache@v2
id: plt_cache
with:
key: |
${{matrix.otp}}-${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
restore-keys: |
${{matrix.otp}}-${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
nathany-copia marked this conversation as resolved.
Show resolved Hide resolved
path: |
priv/plts
# Create PLTs if no cache was found
- name: Create PLTs
if: steps.plt_cache.outputs.cache-hit != 'true'
run: mix dialyzer --plt
- name: Run dialyzer
run: mix dialyzer --format github
8 changes: 7 additions & 1 deletion lib/tesla/multipart.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ defmodule Tesla.Multipart do
false -> headers
end

data = File.stream!(path, [], 2048)
nathany-copia marked this conversation as resolved.
Show resolved Hide resolved
data = stream_file!(path, 2048)
add_file_content(mp, data, filename, opts ++ [headers: headers])
end

Expand Down Expand Up @@ -194,4 +194,10 @@ defmodule Tesla.Multipart do
defp assert_part_value!(val) do
raise(ArgumentError, "#{inspect(val)} is not a supported multipart value.")
end

if Version.compare(System.version(), "1.16.0") in [:gt, :eq] do
defp stream_file!(path, bytes), do: File.stream!(path, bytes)
else
defp stream_file!(path, bytes), do: File.stream!(path, [], bytes)
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Tesla.Mixfile do
dialyzer: [
plt_core_path: "_build/#{Mix.env()}",
plt_add_apps: [:mix, :inets, :idna, :ssl_verify_fun, :ex_unit],
plt_add_deps: :project
yordis marked this conversation as resolved.
Show resolved Hide resolved
plt_add_deps: :apps_direct
],
docs: docs(),
preferred_cli_env: [coveralls: :test, "coveralls.html": :test]
Expand Down
Loading