Skip to content

Commit

Permalink
build(deps): supports elixir/erlang 1.14/24 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy authored Jun 11, 2024
1 parent 8b58364 commit f94409f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
lint: true
- elixir: '1.15'
erlang: '25.3.2.12'
- elixir: '1.14'
erlang: '24.3.4.17'
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand All @@ -36,8 +38,5 @@ jobs:
if: ${{ matrix.lint }}
- run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}
- run: mix compile
if: ${{ ! matrix.lint }}
- run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}
- run: mix test
27 changes: 24 additions & 3 deletions lib/tower_rollbar/rollbar/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ defmodule TowerRollbar.Rollbar.Client do
Jason.encode!(payload)
},
[
ssl: [
cacerts: :public_key.cacerts_get()
]
ssl: tls_client_options()
],
[]
) do
Expand All @@ -28,6 +26,29 @@ defmodule TowerRollbar.Rollbar.Client do
end
end

cond do
function_exported?(:public_key, :cacerts_get, 0) ->
# Included in Erlang 25+
defp tls_client_options do
[
verify: :verify_peer,
cacerts: :public_key.cacerts_get()
]
end

Code.ensure_loaded?(CAStore) ->
# Support Erlang < 25
defp tls_client_options do
[
verify: :verify_peer,
cacertfile: CAStore.file_path()
]
end

true ->
raise "Please include castore package in your dependencies to make tower_rollbar work for Erlang/OTP #{System.otp_release()} or upgrade to Erlang/OTP 25+"
end

defp access_token do
Application.fetch_env!(:tower_rollbar, :access_token)
end
Expand Down
9 changes: 6 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule TowerRollbar.MixProject do
app: :tower_rollbar,
description: @description,
version: @version,
elixir: "~> 1.15",
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package(),
Expand All @@ -25,7 +25,7 @@ defmodule TowerRollbar.MixProject do
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger, :public_key]
extra_applications: [:logger, :public_key, :inets]
]
end

Expand All @@ -34,7 +34,10 @@ defmodule TowerRollbar.MixProject do
[
{:jason, "~> 1.4"},
{:tower, github: "mimiquate/tower"},
{:plug, "~> 1.16"}
{:plug, "~> 1.16"},

# Only needed for Erlang < 25
{:castore, "~> 1.0", optional: true}
]
end

Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%{
"castore": {:hex, :castore, "1.0.7", "b651241514e5f6956028147fe6637f7ac13802537e895a724f90bf3e36ddd1dd", [:mix], [], "hexpm", "da7785a4b0d2a021cd1292a60875a784b6caef71e76bf4917bdee1f390455cf5"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"plug": {:hex, :plug, "1.16.0", "1d07d50cb9bb05097fdf187b31cf087c7297aafc3fed8299aac79c128a707e47", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cbf53aa1f5c4d758a7559c0bd6d59e286c2be0c6a1fac8cc3eee2f638243b93e"},
Expand Down

0 comments on commit f94409f

Please sign in to comment.