Skip to content

Commit ff79c38

Browse files
authored
Github Actions (#112)
* Swap to Github Actions * update * mix format * add dialyzer
1 parent e25b838 commit ff79c38

File tree

8 files changed

+94
-25
lines changed

8 files changed

+94
-25
lines changed

.github/workflows/elixir.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Elixir CI
2+
3+
on: push
4+
5+
env:
6+
MIX_ENV: test
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
elixir: ["1.13", "1.14", "1.15"]
15+
otp: ["25", "26"]
16+
exclude:
17+
- elixir: 1.13
18+
otp: 26
19+
- elixir: 1.14
20+
otp: 26
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
25+
- name: Setup elixir
26+
uses: erlef/setup-beam@v1
27+
with:
28+
elixir-version: ${{ matrix.elixir }}
29+
otp-version: ${{ matrix.otp }}
30+
31+
- name: Restore dependencies cache
32+
uses: actions/cache@v3
33+
id: mix-cache
34+
with:
35+
path: deps
36+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
37+
restore-keys: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
38+
39+
- name: Install dependencies
40+
if: steps.mix-cache.outputs.cache-hit != 'true'
41+
run: |
42+
mix local.rebar --force
43+
mix local.hex --force
44+
mix deps.get
45+
46+
- name: Compile & error on warning
47+
run: mix compile --warnings-as-errors
48+
49+
- name: Check formatting
50+
run: mix format --check-formatted
51+
52+
- name: Run credo
53+
run: mix credo --strict
54+
55+
- name: Retrieve PLT cache
56+
uses: actions/cache@v3
57+
id: plt-cache
58+
with:
59+
path: priv/plts
60+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
61+
restore-keys: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
62+
63+
- name: Create PLTs
64+
if: steps.plt-cache.outputs.cache-hit != 'true'
65+
run: |
66+
mkdir -p priv/plts
67+
mix dialyzer --plt
68+
69+
- name: Run dialyzer
70+
run: mix dialyzer --no-check --halt-exit-status
71+
72+
- name: Run tests
73+
run: mix coveralls.github

.travis.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/soap/request/params.ex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ defmodule Soap.Request.Params do
2121
Returns XML-like string.
2222
"""
2323

24-
@spec build_body(wsdl :: map(), operation :: String.t() | atom(), params :: map() | tuple(), headers :: map()) :: String.t()
24+
@spec build_body(wsdl :: map(), operation :: String.t() | atom(), params :: map() | tuple(), headers :: map()) ::
25+
String.t()
2526
def build_body(wsdl, operation, params, headers) do
2627
with {:ok, body} <- build_soap_body(wsdl, operation, params),
2728
{:ok, header} <- build_soap_header(wsdl, operation, headers) do
@@ -75,9 +76,7 @@ defmodule Soap.Request.Params do
7576
if Map.has_key?(val_map, k) do
7677
validate_param_attributes(val_map, k, v)
7778
else
78-
"Invalid SOAP message:Invalid content was found starting with element '#{k}'. One of {#{
79-
Enum.join(Map.keys(val_map), ", ")
80-
}} is expected."
79+
"Invalid SOAP message:Invalid content was found starting with element '#{k}'. One of {#{Enum.join(Map.keys(val_map), ", ")}} is expected."
8180
end
8281
end
8382
end

lib/soap/wsdl.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ defmodule Soap.Wsdl do
7676

7777
xpath(
7878
wsdl,
79-
~x"//#{ns("types", protocol_ns)}/#{ns("schema", schema_namespace)}/#{ns("import", schema_namespace)}[@namespace='#{
80-
value
81-
}']"
79+
~x"//#{ns("types", protocol_ns)}/#{ns("schema", schema_namespace)}/#{ns("import", schema_namespace)}[@namespace='#{value}']"
8280
) ->
8381
{string_key, %{value: value, type: :xsd}}
8482

@@ -91,9 +89,7 @@ defmodule Soap.Wsdl do
9189
def get_endpoint(wsdl, protocol_ns, soap_ns) do
9290
wsdl
9391
|> xpath(
94-
~x"//#{ns("definitions", protocol_ns)}/#{ns("service", protocol_ns)}/#{ns("port", protocol_ns)}/#{
95-
ns("address", soap_ns)
96-
}/@location"s
92+
~x"//#{ns("definitions", protocol_ns)}/#{ns("service", protocol_ns)}/#{ns("port", protocol_ns)}/#{ns("address", soap_ns)}/@location"s
9793
)
9894
end
9995

lib/soap/xsd.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ defmodule Soap.Xsd do
2727
@spec parse_from_url(String.t(), keyword()) :: {:ok, map()} | {:error, atom()}
2828
def parse_from_url(path, opts \\ []) do
2929
request_opts = Keyword.merge([follow_redirect: true, max_redirect: 5], opts)
30+
3031
case Request.get_http_client().get(path, [], request_opts) do
3132
{:ok, %HTTPoison.Response{status_code: 404}} -> {:error, :not_found}
3233
{:ok, %HTTPoison.Response{body: body}} -> parse_xsd(body)

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"mock": {:hex, :mock, "0.3.7", "75b3bbf1466d7e486ea2052a73c6e062c6256fb429d6797999ab02fa32f29e03", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "4da49a4609e41fd99b7836945c26f373623ea968cfb6282742bcb94440cf7e5c"},
2222
"nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
2323
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
24-
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
24+
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
2525
"sweet_xml": {:hex, :sweet_xml, "0.7.2", "4729f997286811fabdd8288f8474e0840a76573051062f066c4b597e76f14f9f", [:mix], [], "hexpm", "6894e68a120f454534d99045ea3325f7740ea71260bc315f82e29731d570a6e8"},
2626
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
2727
"xml_builder": {:hex, :xml_builder, "2.2.0", "cc5f1eeefcfcde6e90a9b77fb6c490a20bc1b856a7010ce6396f6da9719cbbab", [:mix], [], "hexpm", "9d66d52fb917565d358166a4314078d39ef04d552904de96f8e73f68f64a62c9"},

test/soap/request/params_test.exs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,20 @@ defmodule Soap.Request.ParamsTest do
9090
xml_body =
9191
"runTransaction-template.xml"
9292
|> Fixtures.load_xml()
93-
|> String.replace("{{BODY}}", ~s{<test><Person id="something"><firstName>Joe</firstName><lastName>Dirt</lastName></Person></test>})
93+
|> String.replace(
94+
"{{BODY}}",
95+
~s{<test><Person id="something"><firstName>Joe</firstName><lastName>Dirt</lastName></Person></test>}
96+
)
9497

9598
{_, wsdl} = Wsdl.parse_from_file(Fixtures.get_file_path("wsdl/CyberSourceTransaction.wsdl"))
96-
function_result = Params.build_body(wsdl, "runTransaction", %{test: {:Person, %{id: "something"}, %{firstName: "Joe", lastName: "Dirt"}}}, nil)
99+
100+
function_result =
101+
Params.build_body(
102+
wsdl,
103+
"runTransaction",
104+
%{test: {:Person, %{id: "something"}, %{firstName: "Joe", lastName: "Dirt"}}},
105+
nil
106+
)
97107

98108
assert function_result == xml_body
99109
end

test/soap/request_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ defmodule Soap.RequestTest do
6969
params = {%{token: "barbaz"}, {:body, %{foo: "bar"}, "Hello John"}}
7070

7171
with_mock HTTPoison, post: fn _, body, _, _ -> body end do
72-
assert Request.call(wsdl, operation, params) == String.replace(@request_with_header, "<body>", ~s{<body foo="bar">})
72+
assert Request.call(wsdl, operation, params) ==
73+
String.replace(@request_with_header, "<body>", ~s{<body foo="bar">})
7374
end
7475
end
7576
end

0 commit comments

Comments
 (0)