Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
51 changes: 31 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,65 @@ jobs:
runs-on: ubuntu-20.04
env:
MIX_ENV: test
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
include:
- pair:
elixir: 1.8.2
otp: 21.3.8.17
elixir: "1.8.2"
otp: "21.3.8.17"
- pair:
elixir: 1.14.3
otp: 24.3
elixir: "1.15.0"
otp: "25.3"
lint: lint
coverage: coverage
steps:
- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Start Docker
run: docker-compose up --detach

- uses: erlef/setup-beam@v1
- name: Install Erlang/OTP and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.pair.otp}}
elixir-version: ${{matrix.pair.elixir}}
otp-version: ${{ matrix.pair.otp }}
elixir-version: ${{ matrix.pair.elixir }}

- uses: actions/cache@v2
- name: Cache Mix dependencies
uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-${{ hashFiles('**/mix.lock') }}
key: |
${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-
${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-

- run: mix deps.get
- name: Fetch Mix dependencies
run: mix deps.get

- run: mix format --check-formatted
- name: Run the formatter
run: mix format --check-formatted
if: ${{ matrix.lint }}

- run: mix deps.unlock --check-unused
- name: Check for unused dependencies
run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}

- run: mix deps.compile
- name: Compile Mix dependencies
run: mix deps.compile

- run: mix compile --warnings-as-errors
- name: Compile code and check for warnings
run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}

- run: mix test
- name: Run tests
run: mix test
if: ${{ !matrix.coverage }}

- run: mix coveralls.github
if: ${{matrix.coverage}}
- name: Run tests with coverage
run: mix coveralls.github
if: ${{ matrix.coverage }}
2 changes: 1 addition & 1 deletion lib/broadway_rabbitmq/producer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ defmodule BroadwayRabbitMQ.Producer do
)

case reason do
{:auth_failure, 'Disconnected'} ->
{:auth_failure, ~c"Disconnected"} ->
handle_backoff(state)

{:socket_closed_unexpectedly, :"connection.start"} ->
Expand Down
5 changes: 4 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ defmodule BroadwayRabbitMQ.MixProject do
{:amqp, "~> 1.3 or ~> 2.0 or ~> 3.0"},
{:nimble_options, "~> 0.3.5 or ~> 0.4.0 or ~> 1.0"},
{:telemetry, "~> 0.4.3 or ~> 1.0"},

# Dev and test dependencies
{:ex_doc, ">= 0.25.0", only: :docs},
{:excoveralls, "~> 0.14.4", only: :test}
{:excoveralls, "~> 0.14.4", only: :test},
{:ssl_verify_fun, "~> 1.1.0", manager: :rebar3, override: true}
]
end

Expand Down
35 changes: 11 additions & 24 deletions test/broadway_rabbitmq/producer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,16 @@ defmodule BroadwayRabbitMQ.ProducerTest do
end

test "with auth_failure 'Disconnected'" do
assert capture_log(fn ->
broadway = start_broadway(connect_responses: [{:auth_failure, 'Disconnected'}])
assert_receive {:setup_channel, :error, _}
assert_receive {:setup_channel, :ok, _}
stop_broadway(broadway)
end) =~ "Cannot connect to RabbitMQ broker: {:auth_failure, 'Disconnected'}"
log =
capture_log(fn ->
broadway = start_broadway(connect_responses: [{:auth_failure, ~c"Disconnected"}])
assert_receive {:setup_channel, :error, _}
assert_receive {:setup_channel, :ok, _}
stop_broadway(broadway)
end)

assert log =~ "Cannot connect to RabbitMQ broker: {:auth_failure, 'Disconnected'}" or
log =~ "Cannot connect to RabbitMQ broker: {:auth_failure, ~c\"Disconnected\"}"
end

test "with socket_closed_unexpectedly" do
Expand All @@ -693,15 +697,6 @@ defmodule BroadwayRabbitMQ.ProducerTest do

describe "unsuccessful acknowledgement" do
test "raise when an error is thrown acknowledging" do
broadway =
start_broadway(
client: FlakyRabbitmqClient,
on_success: :ack,
on_failure: :reject
)

deliver_messages(broadway, [:fail_to_ack])

assert_raise(RuntimeError, fn ->
Message.ack_immediately(%Message{
data: :fail_to_ack,
Expand All @@ -718,15 +713,6 @@ defmodule BroadwayRabbitMQ.ProducerTest do
end

test "raise when an error is returned from amqp" do
broadway =
start_broadway(
client: FlakyRabbitmqClient,
on_success: :ack,
on_failure: :reject
)

deliver_messages(broadway, [:fail_to_ack])

msgs =
Enum.map(["failure one", "failure two"], fn data ->
%Message{
Expand Down Expand Up @@ -755,6 +741,7 @@ defmodule BroadwayRabbitMQ.ProducerTest do
end

test "close connection on terminate" do
Process.flag(:trap_exit, true)
broadway = start_broadway()
assert_receive {:setup_channel, :ok, _channel}
Process.exit(Process.whereis(broadway), :shutdown)
Expand Down