-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
200 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: CI Integration | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
setup: | ||
name: test | setup dependencies | ||
runs-on: ubuntu-20.04 | ||
env: | ||
MIX_ENV: test | ||
strategy: | ||
matrix: | ||
pair: | ||
- elixir: 1.16 | ||
otp: 26.1 | ||
|
||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout Github repo | ||
uses: actions/checkout@v2 | ||
- name: Setup elixir & erlang environment | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
elixir-version: ${{matrix.pair.elixir}} # Define the elixir version [required] | ||
otp-version: ${{matrix.pair.otp}} # Define the OTP version [required] | ||
|
||
- name: Retrieve Mix Dependencies Cache | ||
uses: actions/cache@v2 | ||
id: mix-cache # id to use in retrieve action | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
|
||
- name: Retrieve Mix Dependencies Compilation Cache | ||
uses: actions/cache@v2 | ||
id: mix-deps-compile-cache # id to use in retrieve action | ||
with: | ||
path: _build | ||
key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
- name: Install Mix Dependencies | ||
run: | | ||
mix local.rebar --force | ||
mix local.hex --force | ||
mix deps.get | ||
- name: Compile Mix Dependencies | ||
run: mix deps.compile | ||
|
||
test: | ||
name: runner / Test | ||
needs: [setup] | ||
|
||
runs-on: ubuntu-20.04 | ||
env: | ||
MIX_ENV: test | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
pair: | ||
- elixir: 1.16 | ||
otp: 26.1 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup elixir & erlang environment | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
elixir-version: ${{matrix.pair.elixir}} # Define the elixir version [required] | ||
otp-version: ${{matrix.pair.otp}} # Define the OTP version [required] | ||
|
||
- name: Retrieve Mix Dependencies Cache | ||
uses: actions/cache@v2 | ||
id: mix-cache # id to use in retrieve action | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
|
||
- name: Retrieve Mix Dependencies Compilation Cache | ||
uses: actions/cache@v2 | ||
id: mix-deps-compile-cache # id to use in retrieve action | ||
with: | ||
path: _build | ||
key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
|
||
- name: Docker-compose up | ||
run: ./scripts/docker_up.sh | ||
|
||
- name: Docker ps | ||
run: docker ps -a | ||
|
||
- name: Run Tests | ||
run: ./scripts/ci_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,4 @@ jobs: | |
run: docker ps -a | ||
|
||
- name: Run Tests | ||
run: ./scripts/ci_tests.sh | ||
run: mix test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/kafka_ex/new/structs/offset/partition_offset_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule KafkaEx.New.Structs.Offset.PartitionOffsetTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias KafkaEx.New.Structs.Offset.PartitionOffset | ||
|
||
describe "build/1" do | ||
test "returns struct with missing timestamp" do | ||
result = PartitionOffset.build(%{partition: 1, offset: 2}) | ||
|
||
assert result == %PartitionOffset{ | ||
partition: 1, | ||
offset: 2, | ||
timestamp: -1 | ||
} | ||
end | ||
|
||
test "returns struct with timestamp" do | ||
result = PartitionOffset.build(%{partition: 1, offset: 2, timestamp: 123}) | ||
|
||
assert result == %PartitionOffset{ | ||
partition: 1, | ||
offset: 2, | ||
timestamp: 123 | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
defmodule KafkaEx.New.Structs.OffsetTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias KafkaEx.New.Structs.Offset | ||
|
||
describe "from_list_offset/2" do | ||
test "creates offset with v0 partition responses" do | ||
result = Offset.from_list_offset("test-topic", [%{offset: 1, partition: 2}]) | ||
|
||
assert result == %Offset{ | ||
topic: "test-topic", | ||
partition_offsets: [ | ||
%Offset.PartitionOffset{offset: 1, partition: 2, timestamp: -1} | ||
] | ||
} | ||
end | ||
|
||
test "creates offset with v1 partition responses" do | ||
result = Offset.from_list_offset("test-topic", [%{offset: 1, partition: 2}]) | ||
|
||
assert result == %Offset{ | ||
topic: "test-topic", | ||
partition_offsets: [ | ||
%Offset.PartitionOffset{offset: 1, partition: 2, timestamp: -1} | ||
] | ||
} | ||
end | ||
|
||
test "creates offset with v2 partition responses" do | ||
result = Offset.from_list_offset("test-topic", [%{offset: 1, partition: 2, timestamp: 3}]) | ||
|
||
assert result == %Offset{ | ||
topic: "test-topic", | ||
partition_offsets: [ | ||
%Offset.PartitionOffset{offset: 1, partition: 2, timestamp: 3} | ||
] | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters