Skip to content

Commit

Permalink
add: CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rhblind committed Sep 20, 2024
1 parent 21c0c31 commit 5e76ba3
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/elixir.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI Pipeline

on:
pull_request:
push:
branches: ["main"]

env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: read

jobs:
build:
name: Build and test
runs-on: ubuntu-20.04
services:
mosquitto:
image: eclipse-mosquitto:2.0
ports:
- "1883:1883"
- "1884:1884"
volumes:
- ${{ github.workspace }}/build/volume/.moquitto:/mosquitto/config
options: --name mqtt
strategy:
fail-fast: false
matrix:
include:
- elixir: "1.14"
otp: "23.0"

# Latest versions.
- elixir: "1.17"
otp: "27.0"
lint: lint
coverage: coverage
steps:
- name: Check out this repository
uses: actions/checkout@v4

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

# Ensure to restart MQTT after checkout to correctly bind the config volume
- name: Restart MQTT
uses: docker://docker
with:
args: docker restart mqtt

- name: Cache Mix dependencies
uses: actions/cache@v3
id: cache-deps
with:
path: |
deps
_build
key: |
mix-${{ runner.os }}-${{matrix.elixir}}-${{matrix.otp}}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
mix-${{ runner.os }}-${{matrix.elixir}}-${{matrix.otp}}-
- run: mix do deps.get --check-locked, deps.compile
if: steps.cache-deps.outputs.cache-hit != 'true'

- run: mix format --check-formatted
if: ${{ matrix.lint }}

- run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}

- run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}

- run: mix coveralls.github
if: ${{ matrix.coverage }}
12 changes: 5 additions & 7 deletions test/off_broadway/emqtt/producer_test.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
defmodule OffBroadway.EMQTT.ProducerTest do
use ExUnit.Case, async: false
# import ExUnit.CaptureLog

@broadway_opts buffer_size: 10000,
@broadway_opts buffer_size: 10_000,
buffer_overflow_strategy: :drop_head,
config: [
# host: "localhost",
host: "test.mosquitto.org",
host: "localhost",
# host: "test.mosquitto.org",
port: 1884,
username: "rw",
password: "readwrite",
Expand Down Expand Up @@ -90,7 +89,7 @@ defmodule OffBroadway.EMQTT.ProducerTest do
],
batchers: [
default: [
batch_size: 1000,
batch_size: 100,
batch_timeout: 50,
concurrency: 10
]
Expand Down Expand Up @@ -133,7 +132,7 @@ defmodule OffBroadway.EMQTT.ProducerTest do
name = unique_name()
{:ok, pid} = start_broadway(nil, name, @broadway_opts ++ [topics: [{"#", 0}]])

Process.sleep(:timer.seconds(60))
# Process.sleep(:timer.seconds(60))
stop_process(pid)
end

Expand All @@ -142,7 +141,6 @@ defmodule OffBroadway.EMQTT.ProducerTest do
{:ok, message_server} = MessageServer.start_link()
{:ok, pid} = start_broadway(message_server, name, @broadway_opts ++ [topics: [{"#", :at_least_once}]])

IO.puts("Pushing messages")
MessageServer.push_messages(message_server, "test", 1..5)

Process.sleep(100)
Expand Down

0 comments on commit 5e76ba3

Please sign in to comment.