Skip to content

Commit

Permalink
Merge pull request #186 from peek-travel/otp24-updates
Browse files Browse the repository at this point in the history
Updates for OTP 24.0
  • Loading branch information
doughsay authored May 20, 2021
2 parents 4930523 + 3546ea0 commit 7ed0791
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 76 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: mix
directory: "/"
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10
194 changes: 147 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: push

env:
MIX_ENV: test
OTP_VERSION_SPEC: "24.0"
ELIXIR_VERSION_SPEC: "1.12.0"

jobs:
compile:
Expand All @@ -12,30 +14,40 @@ jobs:
runs-on: ubuntu-latest

steps:
# shared steps
- uses: actions/checkout@v2
- uses: actions/[email protected]
- uses: erlef/setup-elixir@v1
id: setup
with:
otp-version: 22.x
elixir-version: 1.9.x
- uses: actions/cache@v1
id: cache-mix
otp-version: ${{ env.OTP_VERSION_SPEC }}
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
- name: Cache Keys
id: keys
run: |
echo ::set-output name=deps_key::deps-${{ runner.os }}
echo ::set-output name=lockfile_key::${{ hashFiles('mix.lock') }}
echo ::set-output name=build_key::build-${{ runner.os }}-${{ env.MIX_ENV }}
echo ::set-output name=version_key::${{ steps.setup.outputs['otp-version'] }}-${{ steps.setup.outputs['elixir-version'] }}
echo ::set-output name=files_key::${{ hashFiles('apps/*/lib/**/*.ex','apps/*/test/**/*.ex','mix.lock') }}
- uses: actions/[email protected]
id: deps_cache
with:
path: deps
key: ${{ runner.os }}-mix-v5-${{ hashFiles('mix.lock') }}
key: ${{ steps.keys.outputs.deps_key }}-${{ steps.keys.outputs.lockfile_key }}
restore-keys: |
${{ runner.os }}-mix-v5-
- uses: actions/cache@v1
id: cache-build
${{ steps.keys.outputs.deps_key }}-
- uses: actions/cache@v2.1.3
id: build_cache
with:
path: _build
key: ${{ runner.os }}-build-v3-${{ hashFiles('lib/**/*.ex') }}${{ hashFiles('test/**/*.ex') }}${{ hashFiles('mix.lock') }}
key: ${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-${{ steps.keys.outputs.files_key }}
restore-keys: |
${{ runner.os }}-build-v3-
${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-
- name: Install dependencies
if: steps.cache-mix.outputs.cache-hit != 'true'
if: steps.deps_cache.outputs['cache-hit'] != 'true'
run: mix deps.get
- name: Compile
if: steps.cache-build.outputs.cache-hit != 'true'
if: steps.build_cache.outputs['cache-hit'] != 'true'
run: mix compile --warnings-as-errors

format:
Expand All @@ -46,15 +58,42 @@ jobs:
runs-on: ubuntu-latest

steps:
# shared steps
- uses: actions/checkout@v2
- uses: actions/[email protected]
- uses: erlef/setup-elixir@v1
id: setup
with:
otp-version: 22.x
elixir-version: 1.9.x
- uses: actions/cache@v1
otp-version: ${{ env.OTP_VERSION_SPEC }}
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
- name: Cache Keys
id: keys
run: |
echo ::set-output name=deps_key::deps-${{ runner.os }}
echo ::set-output name=lockfile_key::${{ hashFiles('mix.lock') }}
echo ::set-output name=build_key::build-${{ runner.os }}-${{ env.MIX_ENV }}
echo ::set-output name=version_key::${{ steps.setup.outputs['otp-version'] }}-${{ steps.setup.outputs['elixir-version'] }}
echo ::set-output name=files_key::${{ hashFiles('apps/*/lib/**/*.ex','apps/*/test/**/*.ex','mix.lock') }}
- uses: actions/[email protected]
id: deps_cache
with:
path: deps
key: ${{ runner.os }}-mix-v5-${{ hashFiles('mix.lock') }}
key: ${{ steps.keys.outputs.deps_key }}-${{ steps.keys.outputs.lockfile_key }}
restore-keys: |
${{ steps.keys.outputs.deps_key }}-
- uses: actions/[email protected]
id: build_cache
with:
path: _build
key: ${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-${{ steps.keys.outputs.files_key }}
restore-keys: |
${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-
- name: Install dependencies
if: steps.deps_cache.outputs['cache-hit'] != 'true'
run: mix deps.get
- name: Compile
if: steps.build_cache.outputs['cache-hit'] != 'true'
run: mix compile --warnings-as-errors
# job steps
- name: Check formatted
run: mix format --check-formatted

Expand All @@ -66,19 +105,39 @@ jobs:
runs-on: ubuntu-latest

steps:
# shared steps
- uses: actions/checkout@v2
- uses: actions/[email protected]
- uses: erlef/setup-elixir@v1
id: setup
with:
otp-version: 22.x
elixir-version: 1.9.x
- uses: actions/cache@v1
otp-version: ${{ env.OTP_VERSION_SPEC }}
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
- name: Cache Keys
id: keys
run: |
echo ::set-output name=deps_key::deps-${{ runner.os }}
echo ::set-output name=lockfile_key::${{ hashFiles('mix.lock') }}
echo ::set-output name=build_key::build-${{ runner.os }}-${{ env.MIX_ENV }}
echo ::set-output name=version_key::${{ steps.setup.outputs['otp-version'] }}-${{ steps.setup.outputs['elixir-version'] }}
echo ::set-output name=files_key::${{ hashFiles('apps/*/lib/**/*.ex','apps/*/test/**/*.ex','mix.lock') }}
- uses: actions/[email protected]
id: deps_cache
with:
path: deps
key: ${{ runner.os }}-mix-v5-${{ hashFiles('mix.lock') }}
- uses: actions/cache@v1
key: ${{ steps.keys.outputs.deps_key }}-${{ steps.keys.outputs.lockfile_key }}
restore-keys: |
${{ steps.keys.outputs.deps_key }}-
- uses: actions/[email protected]
id: build_cache
with:
path: _build
key: ${{ runner.os }}-build-v3-${{ hashFiles('lib/**/*.ex') }}${{ hashFiles('test/**/*.ex') }}${{ hashFiles('mix.lock') }}
key: ${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-${{ steps.keys.outputs.files_key }}
restore-keys: |
${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-
- name: Compile
if: steps.build_cache.outputs['cache-hit'] != 'true'
run: mix compile --warnings-as-errors
# job steps
- name: Run tests
run: mix coveralls.json
- uses: codecov/codecov-action@v1
Expand All @@ -94,19 +153,39 @@ jobs:
runs-on: ubuntu-latest

steps:
# shared steps
- uses: actions/checkout@v2
- uses: actions/[email protected]
- uses: erlef/setup-elixir@v1
id: setup
with:
otp-version: 22.x
elixir-version: 1.9.x
- uses: actions/cache@v1
otp-version: ${{ env.OTP_VERSION_SPEC }}
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
- name: Cache Keys
id: keys
run: |
echo ::set-output name=deps_key::deps-${{ runner.os }}
echo ::set-output name=lockfile_key::${{ hashFiles('mix.lock') }}
echo ::set-output name=build_key::build-${{ runner.os }}-${{ env.MIX_ENV }}
echo ::set-output name=version_key::${{ steps.setup.outputs['otp-version'] }}-${{ steps.setup.outputs['elixir-version'] }}
echo ::set-output name=files_key::${{ hashFiles('apps/*/lib/**/*.ex','apps/*/test/**/*.ex','mix.lock') }}
- uses: actions/[email protected]
id: deps_cache
with:
path: deps
key: ${{ runner.os }}-mix-v5-${{ hashFiles('mix.lock') }}
- uses: actions/cache@v1
key: ${{ steps.keys.outputs.deps_key }}-${{ steps.keys.outputs.lockfile_key }}
restore-keys: |
${{ steps.keys.outputs.deps_key }}-
- uses: actions/[email protected]
id: build_cache
with:
path: _build
key: ${{ runner.os }}-build-v3-${{ hashFiles('lib/**/*.ex') }}${{ hashFiles('test/**/*.ex') }}${{ hashFiles('mix.lock') }}
key: ${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-${{ steps.keys.outputs.files_key }}
restore-keys: |
${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-
- name: Compile
if: steps.build_cache.outputs['cache-hit'] != 'true'
run: mix compile --warnings-as-errors
# job steps
- name: Run credo
run: mix credo --strict

Expand All @@ -117,30 +196,51 @@ jobs:

env:
MIX_ENV: dev
# Change either of these if you want to bust the cache:
DEPS_CACHE_PREFIX: dialyzer-v2-
BUILD_CACHE_PREFIX: dialyzer-v2-

steps:
# shared steps
- uses: actions/checkout@v2
- uses: actions/[email protected]
- uses: erlef/setup-elixir@v1
id: setup
with:
otp-version: 22.x
elixir-version: 1.9.x
- uses: actions/cache@v1
id: cache-build-dev
otp-version: ${{ env.OTP_VERSION_SPEC }}
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }}
- name: Cache Keys
id: keys
run: |
echo ::set-output name=deps_key::deps-${{ runner.os }}
echo ::set-output name=lockfile_key::${{ hashFiles('mix.lock') }}
echo ::set-output name=build_key::build-${{ runner.os }}-${{ env.MIX_ENV }}
echo ::set-output name=version_key::${{ steps.setup.outputs['otp-version'] }}-${{ steps.setup.outputs['elixir-version'] }}
echo ::set-output name=files_key::${{ hashFiles('apps/*/lib/**/*.ex','apps/*/test/**/*.ex','mix.lock') }}
echo ::set-output name=deps_cache_prefix::${{ env.DEPS_CACHE_PREFIX }}
echo ::set-output name=build_cache_prefix::${{ env.BUILD_CACHE_PREFIX }}
- uses: actions/[email protected]
id: deps_cache
with:
path: _build
key: ${{ runner.os }}-build-dev-v3-${{ hashFiles('lib/**/*.ex') }}${{ hashFiles('test/**/*.ex') }}${{ hashFiles('mix.lock') }}
path: deps
key: ${{ steps.keys.outputs.deps_cache_prefix }}${{ steps.keys.outputs.deps_key }}-${{ steps.keys.outputs.lockfile_key }}
restore-keys: |
${{ runner.os }}-build-dev-v3-
- uses: actions/cache@v1
${{ steps.keys.outputs.deps_cache_prefix }}${{ steps.keys.outputs.deps_key }}-
- uses: actions/[email protected]
id: build_cache
with:
path: plts
key: ${{ runner.os }}-plts-v3-${{ hashFiles('lib/**/*.ex') }}${{ hashFiles('test/**/*.ex') }}${{ hashFiles('mix.lock') }}
path: _build
key: ${{ steps.keys.outputs.build_cache_prefix }}${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-${{ steps.keys.outputs.files_key }}
restore-keys: |
${{ runner.os }}-plts-v3-
${{ steps.keys.outputs.build_cache_prefix }}${{ steps.keys.outputs.build_key }}-${{ steps.keys.outputs.version_key }}-
- name: Install dependencies
if: steps.deps_cache.outputs['cache-hit'] != 'true'
run: mix deps.get
- name: Compile
if: steps.cache-build-dev.outputs.cache-hit != 'true'
run: mix compile
if: steps.build_cache.outputs['cache-hit'] != 'true'
run: mix compile --warnings-as-errors
# job steps
- name: PLTs
if: steps.build_cache.outputs['cache-hit'] != 'true'
run: mix dialyzer --plt --no-compile
- name: Run dialyzer
run: mix dialyzer
run: mix dialyzer --no-check --no-compile
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.10.3-otp-22
erlang 22.3.4.1
elixir 1.12.0-otp-24
erlang 24.0
2 changes: 1 addition & 1 deletion lib/sweet_xml/sweet_xml.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule SweetXmlFork do
def sigil_x(path, modifiers \\ '') do
%SweetXpath{
path: String.to_charlist(path),
is_value: not (?e in modifiers),
is_value: ?e not in modifiers,
is_list: ?l in modifiers,
is_keyword: ?k in modifiers,
is_optional: ?o in modifiers,
Expand Down
3 changes: 3 additions & 0 deletions lib/tipalti/api/payee.ex
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ defmodule Tipalti.API.Payee do
iex> update_or_create_payee_info("invalidname", %{first_name: "José", last_name: "Valim"}, skip_nulls: true, override_payable_country: false)
{:error, %Tipalti.ClientError{error_code: "ParameterError", error_message: "Invalid payee first name"}}
iex> update_or_create_payee_info("newpayee", %{first_name: "John", last_name: "Smith"}, [])
{:error, {:missing_required_option, :skip_nulls}}
"""
@spec update_or_create_payee_info(Tipalti.idap(), map(), keyword()) ::
:ok | {:error, ClientError.t()} | {:error, RequestError.t()}
Expand Down
7 changes: 7 additions & 0 deletions lib/tipalti/api/payer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ defmodule Tipalti.API.Payer do
iex> too_long_description = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
iex> create_or_update_invoices([%{idap: "somepayee", ref_code: "testinvoice3", due_date: "2018-05-01", date: "2018-06-01", description: too_long_description, currency: "USD", line_items: [%{amount: "100.00", description: "test line item"}]}])
{:error, %Tipalti.ClientError{error_code: "UnknownError", error_message: "Internal server errror"}}
iex> custom_fields = [%{key: "foo", value: "bar"}]
...> line_items = [%{amount: "100.00", description: "test line item", custom_fields: custom_fields}]
...> approvers = [%{name: "Mr. Approver", email: "[email protected]", order: 1}]
...> invoice = %{idap: "somepayee", ref_code: "testinvoice", due_date: "2018-06-01", date: "2018-05-01", subject: "test invoice", currency: "USD", line_items: line_items, custom_fields: custom_fields, approvers: approvers}
...> create_or_update_invoices([invoice])
{:ok, [%{error_message: nil, ref_code: "testinvoice", succeeded: true}]}
"""
@spec create_or_update_invoices([invoice()]) ::
{:ok, [%{error_message: String.t() | nil, ref_code: String.t(), succeeded: boolean()}]}
Expand Down
5 changes: 4 additions & 1 deletion lib/tipalti/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ defmodule Tipalti.Config do

def master_key, do: get_env(:master_key)

def build_hashkey(string), do: :sha256 |> :crypto.hmac(master_key(), string) |> Base.encode16(case: :lower)
def build_hashkey(string) do
:crypto.mac(:hmac, :sha256, master_key(), string)
|> Base.encode16(case: :lower)
end

def timestamp, do: Application.get_env(:tipalti, :system_time_module, SystemTime).timestamp()

Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Tipalti.MixProject do
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
extra_applications: [:logger, :xmerl]
]
end

Expand All @@ -58,9 +58,9 @@ defmodule Tipalti.MixProject do

defp dialyzer do
[
plt_file: {:no_warn, "plts/tipalti-elixir.plt"},
plt_add_deps: :project,
plt_add_apps: [:decimal, :xmerl],
plt_core_path: "_build/#{Mix.env()}",
flags: [:unmatched_returns, :error_handling, :underspecs]
]
end
Expand Down
Loading

0 comments on commit 7ed0791

Please sign in to comment.