Skip to content

Commit

Permalink
Add more otp & elixir versions to matrix
Browse files Browse the repository at this point in the history
Support multiple otp & elixir version for tests
Support only newst version for static check.
Handle backward compability in tests
  • Loading branch information
Argonus committed May 5, 2022
1 parent 6e61a0a commit 2732384
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
strategy:
matrix:
elixir: ['1.12.3']
erlang: ['24.3']
elixir: ['1.13']
otp: ['24.3']

steps:
- name: Cancel previous runs
Expand All @@ -31,7 +31,7 @@ jobs:
uses: actions/setup-elixir@v1
with:
elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
otp-version: ${{matrix.erlang}} # Define the OTP version [required]
otp-version: ${{matrix.otp}} # Define the OTP version [required]
experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31

- name: Retrieve Cached Dependencies
Expand Down Expand Up @@ -64,8 +64,8 @@ jobs:
strategy:
fail-fast: false
matrix:
elixir: ['1.12.3']
erlang: ['24.3']
elixir: ['1.13']
otp: ['24.3']

steps:
- name: Cancel Previous Runs
Expand All @@ -82,7 +82,7 @@ jobs:
uses: actions/setup-elixir@v1
with:
elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
otp-version: ${{matrix.erlang}} # Define the OTP version [required]
otp-version: ${{matrix.otp}} # Define the OTP version [required]
experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31

- name: Retrieve Cached Dependencies
Expand Down
35 changes: 22 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ jobs:
MIX_ENV: test
strategy:
matrix:
elixir: ['1.12.3']
erlang: ['24.3']
pair:
- elixir: 1.13
otp: 24.3
- elixir: 1.11
otp: 21.3
- elixir: 1.6
otp: 20.3

steps:
- name: Cancel previous runs
Expand All @@ -27,23 +32,23 @@ jobs:
- name: Setup elixir & erlang enviroment
uses: actions/setup-elixir@v1
with:
elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
otp-version: ${{matrix.erlang}} # Define the OTP version [required]
elixir-version: ${{matrix.pair.elixir}} # Define the elixir version [required]
otp-version: ${{matrix.pair.otp}} # Define the OTP version [required]
experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31

- 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.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
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.otp }}-${{ matrix.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
- name: Install Mix Dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
Expand All @@ -66,32 +71,36 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- elixir: 1.12.3
erlang: 24.3
pair:
- elixir: 1.13
otp: 24.3
- elixir: 1.11
otp: 21.3
- elixir: 1.6
otp: 20.3

steps:
- uses: actions/checkout@v2
- name: Setup elixir & erlang enviroment
uses: actions/setup-elixir@v1
with:
elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
otp-version: ${{matrix.erlang}} # Define the OTP version [required]
elixir-version: ${{matrix.pair.elixir}} # Define the elixir version [required]
otp-version: ${{matrix.pair.otp}} # Define the OTP version [required]
experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31

- 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.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
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.otp }}-${{ matrix.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
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
Expand Down
13 changes: 12 additions & 1 deletion test/socket_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ defmodule KafkaEx.Socket.Test do
defp listen(socket) do
case :ssl.transport_accept(socket) do
{:ok, conn} ->
{:ok, _socket} = :ssl.handshake(conn)
# This should be dropped once we drop support for elixir 1.6 & otp 20.0
if opt_version_21_plus? do
{:ok, _socket} = :ssl.handshake(conn)
else
:ok = :ssl.ssl_accept(conn)
end

pid = spawn_link(fn -> recv(conn) end)
:ssl.controlling_process(socket, pid)

Expand All @@ -70,6 +76,11 @@ defmodule KafkaEx.Socket.Test do
:ok
end
end

defp opt_version_21_plus? do
{version, _} = System.otp_release() |> Float.parse()
version >= 21
end
end

setup_all do
Expand Down

0 comments on commit 2732384

Please sign in to comment.